Class: MQTT::SN::Packet::Connack
- Inherits:
-
MQTT::SN::Packet
- Object
- MQTT::SN::Packet
- MQTT::SN::Packet::Connack
- Defined in:
- lib/mqtt/sn/packet.rb
Constant Summary
Constants inherited from MQTT::SN::Packet
Instance Attribute Summary collapse
-
#return_code ⇒ Object
Returns the value of attribute return_code.
Attributes inherited from MQTT::SN::Packet
#clean_session, #duplicate, #qos, #request_will, #retain, #topic_id_type
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 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
#return_code ⇒ Object
Returns the value of attribute return_code.
268 269 270 |
# File 'lib/mqtt/sn/packet.rb', line 268 def return_code @return_code end |
Instance Method Details
#encode_body ⇒ Object
286 287 288 289 290 |
# File 'lib/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) ⇒ Object
292 293 294 |
# File 'lib/mqtt/sn/packet.rb', line 292 def parse_body(buffer) self.return_code = buffer.unpack('C')[0] end |
#return_msg ⇒ Object
Get a string message corresponding to a return code
271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
# File 'lib/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 |