Class: GoogleAnymote::Pair
- Inherits:
-
Object
- Object
- GoogleAnymote::Pair
- Defined in:
- lib/google_anymote/pair.rb
Overview
Class to send events to a connected GoogleTV
Instance Attribute Summary collapse
-
#cert ⇒ Object
readonly
Returns the value of attribute cert.
-
#gtv ⇒ Object
readonly
Returns the value of attribute gtv.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#pair ⇒ Object
readonly
Returns the value of attribute pair.
Instance Method Summary collapse
-
#complete_pairing(code) ⇒ Object
Complete the pairing process.
-
#initialize(cert, host, client_name = '', service_name = 'AnyMote') ⇒ Object
constructor
Initializes the Pair class.
-
#start_pairing ⇒ Object
Start the pairing process.
Constructor Details
#initialize(cert, host, client_name = '', service_name = 'AnyMote') ⇒ Object
Initializes the Pair class
21 22 23 24 25 26 27 |
# File 'lib/google_anymote/pair.rb', line 21 def initialize(cert, host, client_name = '', service_name = 'AnyMote') @pair = PairingRequest.new @cert = cert @host = host @pair.client_name = client_name @pair.service_name = service_name end |
Instance Attribute Details
#cert ⇒ Object (readonly)
Returns the value of attribute cert.
11 12 13 |
# File 'lib/google_anymote/pair.rb', line 11 def cert @cert end |
#gtv ⇒ Object (readonly)
Returns the value of attribute gtv.
11 12 13 |
# File 'lib/google_anymote/pair.rb', line 11 def gtv @gtv end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/google_anymote/pair.rb', line 11 def host @host end |
#pair ⇒ Object (readonly)
Returns the value of attribute pair.
11 12 13 |
# File 'lib/google_anymote/pair.rb', line 11 def pair @pair end |
Instance Method Details
#complete_pairing(code) ⇒ Object
Complete the pairing process
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/google_anymote/pair.rb', line 67 def complete_pairing(code) # Send secret code to the TV to compete the pairing process secret = Secret.new secret.secret = encode_hex_secret(code) outer = (secret, OuterMessage::MessageType::MESSAGE_TYPE_SECRET) # Clean up @gtv.ssl_client.close raise PairingFailed, outer.status unless OuterMessage::Status::STATUS_OK == outer.status end |
#start_pairing ⇒ Object
Start the pairing process
Once the TV recieves the pairing request it will display a 4 digit number. This number needs to be feed into the next step in the process, complete_pairing().
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/google_anymote/pair.rb', line 36 def start_pairing @gtv = GoogleAnymote::TV.new(@cert, host, 9551 + 1) # Let the TV know that we want to pair with it (pair, OuterMessage::MessageType::MESSAGE_TYPE_PAIRING_REQUEST) # Build the options and send them to the TV = Options.new encoding = Options::Encoding.new encoding.type = Options::Encoding::EncodingType::ENCODING_TYPE_HEXADECIMAL encoding.symbol_length = 4 .input_encodings << encoding .output_encodings << encoding (, OuterMessage::MessageType::MESSAGE_TYPE_OPTIONS) # Build configuration and send it to the TV config = Configuration.new encoding = Options::Encoding.new encoding.type = Options::Encoding::EncodingType::ENCODING_TYPE_HEXADECIMAL config.encoding = encoding config.encoding.symbol_length = 4 config.client_role = Options::RoleType::ROLE_TYPE_INPUT outer = (config, OuterMessage::MessageType::MESSAGE_TYPE_CONFIGURATION) raise PairingFailed, outer.status unless OuterMessage::Status::STATUS_OK == outer.status end |