Adafruit_IO_Arduino
Adafruit_IO_Arduino copied to clipboard
put AIO_AUTH_FAILED to use and fix AIO_ERROR_PRINT
This change distinguishes a failure due to authorization from other connection failure reasons. The source defines AIO_AUTH_FAILED but can't return it under any circumstances (only reference is in AdafruitIO::statusText()).
The changes are in AdafruitIO::mqttStatus which is where the mqtt->connect() is called and it's return result is translated to an AIO_ status result.
The main risk to this change is if library client's test for AIO_CONNECT_FAILED precisely. This seems unlikely since the library can return other failures (like AIO_DISCONNECTED here and other status's elsewhere in the code). The examples use < AIO_CONNECTED to mean failure or >= AIO_CONNECTED to be success.
The other part of this change is to make the AIO_ERROR_PRINT's in this routine more useful. There are two problems with the ones added by 0074998:
First, it uses an AIO status code to send to the routine that expects an mqtt status code (connectErrorString) and it only sends that when it is known to be AIO_CONNECT_FAILED which always produces the result "Unknown".
Second, it prints the result when a quick return is to occur and no change in outcome possible (rather than when the error occurred).
I've moved the ERROR_PRINT's to where the error occurred and used the correct status code to generate the string.