class MQTT::SN::Packet::Connack

Attributes

return_code[RW]

Public Instance Methods

encode_body() click to toggle source
# File lib/mqtt/sn/packet.rb, line 280
def encode_body
  raise 'return_code must be an Integer' unless return_code.is_a?(Integer)

  [return_code].pack('C')
end
parse_body(buffer) click to toggle source
# File lib/mqtt/sn/packet.rb, line 286
def parse_body(buffer)
  self.return_code = buffer.unpack1('C')
end
return_msg() click to toggle source

Get a string message corresponding to a return code

# File lib/mqtt/sn/packet.rb, line 265
def return_msg
  case return_code
  when 0x00
    'Accepted'
  when 0x01
    'Rejected: congestion'
  when 0x02
    'Rejected: invalid topic ID'
  when 0x03
    'Rejected: not supported'
  else
    "Rejected: error code #{return_code}"
  end
end