Mistake about compare two Bluetooth.UUID() instance. #15136
-
I'm trying to discover characteristic's descriptor, and passing characteristic's start_handle & end_handle to bluetooth.BLE.gattc_discover_descriptors function. I could receive many For this reason, I want to filter them out, i.e. values other than from bluetooth import UUID
a = UUID(0x2803)
b = UUID(0x2900)
c = UUID(0x2911)
a > b # True ?????
a > c # False My question is how to fix this issue? Or how to receive discriptor correctly? My mpy version Update: It looks as if it swaps the high and low bytes when comparing two UUIDs, this code gets the right result. from bluetooth import UUID
a = UUID(0x0328)
b = UUID(0x0029)
c = UUID(0x1129)
a > b # False
a > c # False |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
I've written BLE code using these functions without problem. I use code that tests for equality between the returned UUID and the one's I want to test for. Using > & < for UUIDs and the like is problematic unless the behaviour of these operators is explicitly defined as it is for Strings say. Regards Paul |
Beta Was this translation helpful? Give feedback.
-
Just for now. # if UUID(0x2900) <= uuid <= UUID(0x2911):
# print(uuid)
if uuid == UUID(0x2900) or\
uuid == UUID(0x2901) or\
uuid == UUID(0x2902) or\
uuid == UUID(0x2903) or\
uuid == UUID(0x2904) or\
uuid == UUID(0x2905) or\
uuid == UUID(0x2906) or\
uuid == UUID(0x2907) or\
uuid == UUID(0x2908) or\
uuid == UUID(0x2909) or\
uuid == UUID(0x290a) or\
uuid == UUID(0x290b) or\
uuid == UUID(0x290c) or\
uuid == UUID(0x290d) or\
uuid == UUID(0x290e) or\
uuid == UUID(0x2910) or\
uuid == UUID(0x2911):
pass |
Beta Was this translation helpful? Give feedback.
Update: