Skip to content

api call failed, not waiting for ('onCharacteristicRead', 42) #1662

Closed Answered by MarkusPiotrowski
9acca9 asked this question in Q&A
Discussion options

You must be logged in to vote

Python is a dynamically typed language, that means in contrast to C# or Java or .... you are not defining variables statically.
The syntax you are using in your function definitions shows 'type hints' and these are indeed only hints for someone who reads the code or code linters
So it doesn't matter if you write data: bytearray or data: str, you can even omit it and just write (sender, data).
Also, the variables which are received by the callback function have the type that they have. You cannot magically convert them by just writing another type hint to them.
So the data come in as bytestring, and if you want them to be strings, you must decode them (as you did).

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by 9acca9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants