-
Notifications
You must be signed in to change notification settings - Fork 40
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
Windows 10 not reporting BLE UUID #3
Comments
On Windows and Linux, the "id" will be a Bluetooth address (looks like MAC, but technically not the same thing). Only on macOS will the the "id" be a UUID. (Apple thinks that for security/privacy reasons that they should not let us know the Bluetooth address, so we can't make it work the same on all OSes). So, I think this should work for you:
Although there is one place in the code where it looks like it might try to convert this to a UUID and cause an error. bricknil/bricknil/ble_queue.py Line 209 in 9bd7723
|
I was thinking about putting that uuid conversion into a try block, and then falling back to just using the ble_id if it throws a ValueError, but that's starting to get a little hacky. I could've sworn bleak under Linux could also return UUIDs (device.id, as opposed to device.address), but I need to go back and refresh my memory. I've started refactoring the whole ble_queue code to make it into sub classes based on the platform, which is something I was hoping to avoid, but I think the current code in that class is starting to turn into a bit of kludge if I don't. I'm trying to update a windows 10 tablet right now, so hopefully I will be able to test whatever change I make before pushing a new release. Perhaps a few more days before it's ready. |
How about? if sys.platform == 'darwin':
# Apple uses UUID instead of Bluetooth address
ble_id = uuid.UUID(hub.ble_id) if hub.ble_id else None
else:
# Bluetooth address
ble_id = hub.ble_id.upper() |
Also just double-checked Linux and it uses Bluetooth address, not UUID. |
@dlech @Entalyan I have pushed a new version with this fix (cough hack) as v0.8.1 to PyPI. On Linux and Win, just use a string containing the 6 bytes of network ID as mentioned above by @dlech:
Let me know if it works, and I'll close this. As an aside, ideally, I'd prefer a way to make it consistently use the BLE address across all platforms, so I'm just jotting down this idea for the future: It looks like the hub can be queried for its network address after connecting to its characteristic. My initial thought is to have the ble_queue object create a pool of hubs by connecting to all available devices with the Lego service, then query the hub for the network address, and then assign the hub object to the matching device. The connection and messaging logic would need some updates to handle this type of flow. But it would enable Mac hosts to connect to BLE addresses instead of UUIDs. |
I can confirm this now works with the new version. When using the correct ID it finds my device, and with the wrong ID it gracefully ignores it. This can be closed on my account, thanks very much! |
Hello, i still have the issue using Windows 10
here is my code
|
For now, uninstall |
Thank you, I'll try this the next days.. |
I removed bleak / bricknil-bleak and bricknil and reinstalled bricknil. Than following error occours:
This Error caused me to install bleak, since it fixed the other issue :). |
It sounds like pythonnet is not working. I don't think pythonnet supports Python 3.7 yet, so you need to use Python 3.6 on Windows. |
I had huge problems getting pythonnet installed in the first place, so I had to use an alternative build of it. The alternative/unofficial build I am using came from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#pythonnet On my machine this all works, with Python 3.7.3 (32-bit I think) and: bluebrick-Adafruit-BluefruitLE==0.9.13 I also tested with bricknil 0.9.1, just not on this machine. Same result though. |
FWIW, the following works on my Win10 tablet (32-bit) with Python 3.6.8: bluebrick-Adafruit-BluefruitLE==0.9.13 |
I am having that same issue, have you fixed this? System is Windows 10 latest x64, bluebrick-Adafruit-BluefruitLE==0.9.13 |
I am experiencing the same problem as @positron96. I have tried updating my packages to match above suggestions, but no luck so far. I would really love to try out this library (and I'm sure many other Windows users would too!), so adding a reliable installation procedure for windows to the documentation would be greatly appreciated. In the mean time, I will see if I can get it working on my raspberry pi, as this has a clear set of instructions to follow. |
I experience also the same issue. Unfortunately I am not experienced enough with python to drill down to the source of the issue but I am happy to provide information or testing when instructed. |
I am attaching patch to make Bricknil compatible with Bleak 0.13 (latest up to date) on Windows 10. Tested with latest Bricknil code base (commit a908b98) on Windows 10 with Python 3.10.0 |
On my machine (Win10) the UUID is not actually showing, instead a MAC-like address is given. This has made it hard to select a specific device. From inside the main run() method in Train I have added
self.message_info("BLE_ID:"+self.ble_id)
which outputs
INFO:GreenCargoTrain.2:BLE_ID:90:84:2B:0B:DD:BF
I have tried setting the logging to DEBUG, and using all the UUID's that are in there, including the Device advertised UUID, but no luck. For example, without setting a specific UUID it finds the train:
But when putting any of those UUID's in there (the first one in this example) I get:
A debug log file of a successful connect and execution to the same device looks like this:
PUP_Debug_Success.log
This is on Microsoft Windows [Version 10.0.17763.379], using Python 3.7.3
The text was updated successfully, but these errors were encountered: