adds MQTT 3.1.1 connect packet changes
This commit is contained in:
parent
ea779b1daa
commit
a3925bdb6b
@ -96,25 +96,6 @@ Adafruit_MQTT::Adafruit_MQTT(const __FlashStringHelper *server, uint16_t port, c
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Adafruit_MQTT::Adafruit_MQTT(char *server, uint16_t port, char *cid, char *user, char *pass) {
|
||||
strncpy(servername, server, SERVERNAME_SIZE);
|
||||
servername[SERVERNAME_SIZE-1] = 0;
|
||||
portnum = port;
|
||||
serverip = 0;
|
||||
|
||||
strncpy(clientid, cid, CLIENTID_SIZE);
|
||||
clientid[CLIENTID_SIZE-1] = 0;
|
||||
|
||||
strncpy(username, user, USERNAME_SIZE);
|
||||
username[USERNAME_SIZE-1] = 0;
|
||||
|
||||
strncpy(password, pass, PASSWORD_SIZE);
|
||||
password[PASSWORD_SIZE-1] = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
int8_t Adafruit_MQTT::connect() {
|
||||
// Connect to the server.
|
||||
if (!connectServer())
|
||||
@ -287,7 +268,10 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {
|
||||
p+=2;
|
||||
// fill in packet[1] last
|
||||
|
||||
p = stringprint_P(p, PSTR("MQIsdp"));
|
||||
if(MQTT_PROTOCOL_LEVEL == 3)
|
||||
p = stringprint_P(p, PSTR("MQIsdp"));
|
||||
else
|
||||
p = stringprint_P(p, PSTR("MQTT"));
|
||||
|
||||
p[0] = MQTT_PROTOCOL_LEVEL;
|
||||
p++;
|
||||
@ -305,7 +289,13 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {
|
||||
p[0] = MQTT_CONN_KEEPALIVE & 0xFF;
|
||||
p++;
|
||||
|
||||
p = stringprint_P(p, clientid, 23); // Limit client ID to first 23 characters.
|
||||
if(MQTT_PROTOCOL_LEVEL == 3) {
|
||||
p = stringprint_P(p, clientid, 23); // Limit client ID to first 23 characters.
|
||||
} else {
|
||||
if (pgm_read_byte(clientid) != 0) {
|
||||
p = stringprint_P(p, clientid);
|
||||
}
|
||||
}
|
||||
|
||||
if (pgm_read_byte(username) != 0) {
|
||||
p = stringprint_P(p, username);
|
||||
|
Loading…
Reference in New Issue
Block a user