class Bravtroller::Remote
Constants
- IRCC_URN
- LIST_METHODS_PARAMS
Public Class Methods
new(host, ircc_client_factory = IrccClientFactory.new(host))
click to toggle source
# File lib/bravtroller/remote.rb, line 47 def initialize(host, ircc_client_factory = IrccClientFactory.new(host)) @bravia_client = Bravtroller::Client.new(host) @ircc_client_factory = ircc_client_factory end
Public Instance Methods
power_on(hw_addr = nil)
click to toggle source
# File lib/bravtroller/remote.rb, line 52 def power_on(hw_addr = nil) hw_addr = @bravia_client.hw_addr if hw_addr.nil? if hw_addr.nil? raise RuntimeError.new "Couldn't determine hw_addr for TV host from ARP. " << 'Specify it manually in the call to power_on.' end addr = ['<broadcast>', 9] sock = UDPSocket.new sock.setsockopt(Socket::SOL_SOCKET, Socket::SO_BROADCAST, true) packet_data = (([255] * 6) + (hw_addr.split(':').map(&:hex) * 16)).pack('C*') sock.send(packet_data, 0, addr[0], addr[1]) true end
Private Instance Methods
ircc_codes()
click to toggle source
# File lib/bravtroller/remote.rb, line 81 def ircc_codes return @ircc_codes unless @ircc_codes.nil? response = JSON.parse(@bravia_client.post_request('/sony/system', LIST_METHODS_PARAMS).body) action_code_pairs = response['result'][1].map do |action| [ action['name'], action['value'] ] end Hash[ action_code_pairs ] end