class MQTT::SN::Packet::Connack

Attributes

return_code[RW]

Public Instance Methods

encode_body() click to toggle source
# File lib/qubitro-mqtt/sn/packet.rb, line 286
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/qubitro-mqtt/sn/packet.rb, line 292
def parse_body(buffer)
  self.return_code = buffer.unpack('C')[0]
end
return_msg() click to toggle source

Get a string message corresponding to a return code

# File lib/qubitro-mqtt/sn/packet.rb, line 271
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