Class: MQTT::SN::Packet::Connack
Constant Summary
Constants inherited from Packet
Instance Attribute Summary collapse
-
#return_code ⇒ Object
Returns the value of attribute return_code.
Attributes inherited from Packet
#body_length, #flags, #id, #version
Instance Method Summary collapse
- #encode_body ⇒ Object
- #parse_body(buffer) ⇒ Object
-
#return_msg ⇒ Object
Get a string message corresponding to a return code.
Methods inherited from Packet
create_from_header, #dup, #initialize, #inspect, #message_id, #message_id=, parse, parse_header, read, read_byte, #to_s, #type_id, #type_name, #update_attributes, #validate_flags
Constructor Details
This class inherits a constructor from MQTT::Packet
Instance Attribute Details
#return_code ⇒ Object
Returns the value of attribute return_code.
262 263 264 |
# File 'lib/mqtt/sn/packet.rb', line 262 def return_code @return_code end |
Instance Method Details
#encode_body ⇒ Object
280 281 282 283 284 |
# 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) ⇒ Object
286 287 288 |
# File 'lib/mqtt/sn/packet.rb', line 286 def parse_body(buffer) self.return_code = buffer.unpack1("C") end |
#return_msg ⇒ Object
Get a string message corresponding to a return code
265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# 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 |