onkyo_eiscp_ruby 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ onkyo_eiscp_ruby
2
+ ================
3
+
4
+ A Ruby implementation of eISCP for controlling Onkyo receivers.
5
+
6
+ **This code is still under heavy development and using it might make you sick.**
7
+ * Create ISCP messages and eISCP packets
8
+ * Automatically discover receiver's in the broadcast domain
9
+ * Send/Recieve eISCP messages
10
+ * Open a TCP socket to send commands and receive solicited and non-solicited status updates.
11
+ * Mock reciever (currently only responds to discovery)
12
+
13
+ **Inspired by https://github.com/miracle2k/onkyo-eiscp
14
+
15
+ Usage
16
+ ________________
17
+
18
+ # require the library
19
+
20
+ require 'eiscp'
21
+
22
+
23
+ # Discover local receivers
24
+ EISCP.discover
25
+
26
+
27
+ # Open a TCP connection to monitor solicited updates
28
+ eiscp = EISCP.new('10.0.0.1')
29
+ eiscp.connect
30
+
31
+ # You can also pass a block and operate on received packet strings:
32
+ eiscp.connect do |data|
33
+ puts EISCPPacket.parse(data).iscp_message
34
+ end
35
+
36
+ # Turn on the receiver
37
+ iscp_message = ISCPMessage.new("PWR", "01")
38
+ eiscp_packet = EISCPPacket.new(iscp_message.message)
39
+ eiscp.send(eiscp_packet.to_s)
40
+
41
+
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/bin/onkyo.rb ADDED
@@ -0,0 +1,84 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'eiscp'
4
+ require 'optparse'
5
+ require 'ostruct'
6
+
7
+ class Options
8
+ DEFAULT_OPTIONS = { verbose: true, all: false }
9
+ USAGE = ' Usage: onkyo_rb [options]'
10
+
11
+ def self.parse(args)
12
+ @options = OpenStruct.new
13
+
14
+ options = OptionParser.new do |opts|
15
+
16
+ opts.banner = USAGE
17
+
18
+ opts.on '-d', '--discover', 'Find Onkyo Receivers on the local broadcast domain' do |d|
19
+ @options.discover = d
20
+ end
21
+
22
+ opts.on '-a', '--all', 'Send command to all Onkyo Receivers instead of just the first one' do |a|
23
+ @options.all = a
24
+ end
25
+
26
+ opts.on '-h', '--help', 'Show this message' do |h|
27
+ @options.help = h
28
+ end
29
+
30
+ opts.on '-l', '--list', 'List commands compatible for each discovered model' do |l|
31
+ @options.list = l
32
+ end
33
+
34
+ opts.on '-L', '--list-all', 'List all commands regardless of model compatibility' do |l|
35
+ @options.list_all = l
36
+ end
37
+
38
+ opts.on '-c', '--connect', 'Connect to the first discovered reciever and show updates' do |c|
39
+ @options.connect = c
40
+ end
41
+
42
+ end
43
+
44
+ options.parse!(args)
45
+
46
+ if @options == nil && ARGV == []
47
+ puts options
48
+ end
49
+
50
+ if @options.discover
51
+ EISCP.discover.each do |receiver|
52
+ puts EISCPPacket.parse(receiver[0]).to_s
53
+ end
54
+ exit 0
55
+ end
56
+
57
+ if @options.help
58
+ puts options
59
+ exit 0
60
+ end
61
+
62
+ if @options.connect
63
+ eiscp = EISCP.new(EISCP.discover[0][1])
64
+ eiscp.connect
65
+ end
66
+
67
+ if ARGV == []
68
+ puts options
69
+ exit 0
70
+ end
71
+ end
72
+
73
+ end
74
+
75
+
76
+ @options = Options.parse(ARGV)
77
+
78
+
79
+ eiscp = EISCP.new(EISCP.discover[0][1])
80
+ eiscp.send_recv(EISCPPacket.new(ISCPMessage.new(ARGV[0], ARGV[1]).message).to_s)
81
+
82
+
83
+
84
+