Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow connection to brokers with no authentication #128

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions Adafruit_MQTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ bool Adafruit_MQTT::ping(uint8_t num) {
// small differences in the protocol):
// http://public.dhe.ibm.com/software/dw/webservices/ws-mqtt/mqtt-v3r1.html#connect
uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {
String nullString = "";
uint8_t *p = packet;
uint16_t len;

Expand Down Expand Up @@ -589,10 +590,12 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {

}

if (pgm_read_byte(username) != 0)
if (!(nullString.equals(username)) && pgm_read_byte(username) != 0){
p[0] |= MQTT_CONN_USERNAMEFLAG;
if (pgm_read_byte(password) != 0)
}
if (!(nullString.equals(password)) && pgm_read_byte(password) != 0){
p[0] |= MQTT_CONN_PASSWORDFLAG;
}
p++;

p[0] = MQTT_CONN_KEEPALIVE >> 8;
Expand All @@ -619,10 +622,10 @@ uint8_t Adafruit_MQTT::connectPacket(uint8_t *packet) {
p = stringprint(p, will_payload);
}

if (pgm_read_byte(username) != 0) {
if (!(nullString.equals(username)) && pgm_read_byte(username) != 0) {
p = stringprint(p, username);
}
if (pgm_read_byte(password) != 0) {
if (!(nullString.equals(password)) && pgm_read_byte(password) != 0) {
p = stringprint(p, password);
}

Expand Down