Skip to content

put AIO_AUTH_FAILED to use and fix AIO_ERROR_PRINT #164

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/AdafruitIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,9 +428,7 @@ char *AdafruitIO::userAgent() {
aio_status_t AdafruitIO::mqttStatus(bool fail_fast) {
// if the connection failed,
// return so we don't hammer IO
if (_status == AIO_CONNECT_FAILED) {
AIO_ERROR_PRINT("mqttStatus() failed to connect");
AIO_ERROR_PRINTLN(_mqtt->connectErrorString(_status));
if (_status == AIO_CONNECT_FAILED || _status == AIO_AUTH_FAILED) {
return _status;
}

Expand All @@ -441,14 +439,20 @@ aio_status_t AdafruitIO::mqttStatus(bool fail_fast) {
if (_last_mqtt_connect == 0 ||
millis() - _last_mqtt_connect > AIO_THROTTLE_RECONNECT_INTERVAL) {
_last_mqtt_connect = millis();
switch (_mqtt->connect(_username, _key)) {
int connect_status = _mqtt->connect(_username, _key);
if (connect_status != 0) {
AIO_ERROR_PRINT("_mqtt->connect() failed to connect: ");
AIO_ERROR_PRINTLN(_mqtt->connectErrorString(connect_status));
}
switch (connect_status) {
case 0:
return AIO_CONNECTED;
case 1: // invalid mqtt protocol
case 2: // client id rejected
case 4: // malformed user/pass
case 5: // unauthorized
return AIO_CONNECT_FAILED;
case 5: // unauthorized
return AIO_AUTH_FAILED;
case 3: // mqtt service unavailable
case 6: // throttled
case 7: // banned -> all MQTT bans are temporary, so eventual retry is
Expand Down