class

MqttCrystal::Packet::Connect

Inherits MqttCrystal::Packet / Reference / Object

Constants

CFLAG_CLEAN_SESSION = 2_u8
CFLAG_PASSWORD = 64_u8
CFLAG_USERNAME = 128_u8
CFLAG_WILL = 4_u8
CFLAG_WILL_RETAIN = 32_u8
PROTOCOL = "MQTT"

Constructors

new(client_id : String = UUID.random.to_s, username : String | Nil = nil, password : String | Nil = nil, protocol_level : UInt8 = 4_u8, keep_alive : UInt16 = 15_u16, clean_session : Bool = true, will_retain : Bool = false, will_topic : String | Nil = nil, will_qos : UInt8 = 0_u8, will_message : String | Nil = nil, flags : Array(Bool) = [false, false, false, false], body_length : UInt64 = 0_u64)
Source

Instance methods

clean_session
Source
clean_session=(clean_session : Bool)
Source
client_id
Source
client_id=(client_id : String)
Source
encode_body
Source
keep_alive
Source
keep_alive=(keep_alive : UInt16)
Source
parse_body(buffer : Array(UInt8))

byte[2..5] = 'MQTT' byte[6] = Protocol requires 4 for MQTTv3.1.1 byte[7] = cflags 7 - User Name Flag - is there a username 0x80 6 - Password Flag - is there a password 0x40 5 - Will Retain 0x20 - Sould the will be retained 4 - Will QoS 0x10 - 0b10 (qos2),0b01 (qos1), 0b00 (qos0) 3 - Will QoS 0x08 2 - Will Flag 0x04 - Should there be a will message published 1 - Clean Session 0x02 0 - RESERVED (always 0) 0x00 byte[8,9] = Keepalive (seconds) from ehre on 2 byte length N bytes payload, in order: Client Identifier, Will Topic, Will Message, User Name, Password

Source
password
Source
password=(password : Nil | String)
Source
protocol_level
Source
protocol_level=(protocol_level : UInt8)
Source
username
Source
username=(username : Nil | String)
Source
will_message
Source
will_message=(will_message : Nil | String)
Source
will_qos
Source
will_qos=(will_qos : UInt8)
Source
will_retain
Source
will_retain=(will_retain : Bool)
Source
will_topic
Source
will_topic=(will_topic : Nil | String)
Source