Module: MaxCube::Messages::TCP::Parser::MessageN

Defined in:
lib/maxcube/messages/tcp/type/n.rb

Overview

New device (pairing) message.

Constant Summary

KEYS =

Mandatory hash keys.

%i[device_type rf_address serial_number unknown].freeze

Instance Method Summary collapse

Instance Method Details

#parse_tcp_n(body) ⇒ Object (private)



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/maxcube/messages/tcp/type/n.rb', line 13

def parse_tcp_n(body)
  @io = StringIO.new(decode(body), 'rb')

  {
    device_type: device_type(read(1, true)),
    rf_address: read(3, true),
    serial_number: read(10),
    unknown: read(1),
  }
rescue IOError
  raise InvalidMessageBody
    .new(@msg_type, 'unexpected EOF reached')
end