-
-
Notifications
You must be signed in to change notification settings - Fork 563
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
Don't log error message when decoding valid discovery packets #1832
Don't log error message when decoding valid discovery packets #1832
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1832 +/- ##
==========================================
+ Coverage 80.80% 80.87% +0.07%
==========================================
Files 192 193 +1
Lines 18546 18599 +53
Branches 4012 4021 +9
==========================================
+ Hits 14986 15042 +56
+ Misses 3282 3279 -3
Partials 278 278
... and 3 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of simple changes and this is good to go, thanks! 👍
miio/protocol.py
Outdated
if obj == b"": | ||
return b"" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if obj == b"": | |
return b"" | |
if not obj: | |
return obj |
miio/protocol.py
Outdated
# if there is no payload, decode to 0 bytes. Missing payload is expected for discovery messages. | ||
# note that we don't have "token" in the context for discovery replies so we couldn't decode it | ||
# anyway. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# if there is no payload, decode to 0 bytes. Missing payload is expected for discovery messages. | |
# note that we don't have "token" in the context for discovery replies so we couldn't decode it | |
# anyway. | |
# Missing payload is expected for discovery messages. |
let's keep it simple here, also, there are some (very) old devices that actually respond with a valid token :-)
Proposed changes applied. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks again! 👍
Fix
Unable to decrypt, returning raw bytes
warning message when decoding Discovery messages. Fixes #1824I opted for a quick surgical fix here rather than rework the whole message parsing. While separating the Discovery messages from normal data messages is quite easy in the context of miioprotocol, there's a quite bit of uses of the
Message
in other places too. I didn't feel confident in changing those.Additionally, it doesn't even seem desirable to separate Discovery-Ack and Data messages. It seems useful in some cases to be able to parse any message without knowing ahead of time what kind of data it might contain. (I doesn't really matter right now as the token, i.e. decryption key, must be supplied ahead of time, but it is conceivable that a parser might first match the ID of the reply to the request and then parse the contents. )
Fixes #1824