Module: MaxCube::Messages::TCP::Serializer::MessageT
- Defined in:
- lib/maxcube/messages/tcp/type/t.rb
Overview
Command to delete one or more devices from the Cube. Acknowledgement (A) follows.
Constant Summary
- KEYS =
Mandatory hash keys.
count
key would cause ambuigity if it was optional due torf_addresses
has variable size. %i[count force rf_addresses].freeze
Instance Method Summary collapse
- #serialize_tcp_t(hash) ⇒ Object private
Instance Method Details
#serialize_tcp_t(hash) ⇒ Object (private)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/maxcube/messages/tcp/type/t.rb', line 16 def serialize_tcp_t(hash) force = to_bool('force mode', hash[:force]) ? '1' : '0' rf_addresses = to_ints(0, 'RF addresses', *hash[:rf_addresses]) count = to_int(0, 'count', hash[:count]) unless count == rf_addresses.size raise InvalidMessageBody .new(@msg_type, 'count and number of devices mismatch: ' \ "#{count} != #{rf_addresses.size}") end if count.zero? raise InvalidMessageBody .new(@msg_type, 'no device specified') end addrs = encode(serialize(*rf_addresses, esize: 3)) [format('%02x', count), force, addrs].join(',') end |