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
}

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.



217
218
219
# File 'lib/mqtt/sn/packet.rb', line 217

def gateway_address
  @gateway_address
end

#gateway_idObject

Returns the value of attribute gateway_id.



216
217
218
# File 'lib/mqtt/sn/packet.rb', line 216

def gateway_id
  @gateway_id
end

Instance Method Details

#encode_bodyObject



223
224
225
# File 'lib/mqtt/sn/packet.rb', line 223

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

#parse_body(buffer) ⇒ Object



227
228
229
230
231
232
233
234
# File 'lib/mqtt/sn/packet.rb', line 227

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