put AIO_AUTH_FAILED to use and fix AIO_ERROR_PRINT#164
Open
markwal wants to merge 1 commit intoadafruit:masterfrom
Open
put AIO_AUTH_FAILED to use and fix AIO_ERROR_PRINT#164markwal wants to merge 1 commit intoadafruit:masterfrom
markwal wants to merge 1 commit intoadafruit:masterfrom
Conversation
also, fix mqtt connect status error printing
Author
|
TL/DR of above: Before change code passes AIO status code to _mqtt->connectErrorString() which clearly expects a mqtt->connect() return value. Before change, the library can never return AIO_AUTH_FAILED because it always translates auth failure to AIO_CONNECT_FAILED. So, if you're implementing AIO for the first time and you've got your auth wrong, you're missing an easily available clue. Or if auth changes for some reason. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.