Class: MQTT::SN::Packet::Gwinfo

Inherits:
MQTT::SN::Packet show all
Defined in:
lib/mqtt/sn/packet.rb

Constant Summary collapse

DEFAULTS =
{
  gateway_id: 0,
  gateway_address: nil
}.freeze

Instance Attribute Summary collapse

Attributes inherited from MQTT::SN::Packet

#clean_session, #duplicate, #qos, #request_will, #retain, #topic_id_type

Instance Method Summary collapse

Methods inherited from MQTT::SN::Packet

#initialize, parse, #to_s, #type_id, #update_attributes

Constructor Details

This class inherits a constructor from MQTT::SN::Packet

Instance Attribute Details

#gateway_addressObject

Returns the value of attribute gateway_address.



212
213
214
# File 'lib/mqtt/sn/packet.rb', line 212

def gateway_address
  @gateway_address
end

#gateway_idObject

Returns the value of attribute gateway_id.



212
213
214
# File 'lib/mqtt/sn/packet.rb', line 212

def gateway_id
  @gateway_id
end

Instance Method Details

#encode_bodyObject



219
220
221
# File 'lib/mqtt/sn/packet.rb', line 219

def encode_body
  [gateway_id, gateway_address].pack('Ca*')
end

#parse_body(buffer) ⇒ Object



223
224
225
226
227
228
229
230
# File 'lib/mqtt/sn/packet.rb', line 223

def parse_body(buffer)
  if buffer.length > 1
    self.gateway_id, self.gateway_address = buffer.unpack('Ca*')
  else
    self.gateway_id, _ignore = buffer.unpack('C')
    self.gateway_address = nil
  end
end