put AIO_AUTH_FAILED to use and fix AIO_ERROR_PRINT #164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.