How to build and use Bluetooth enabled variant of unix port #10234
Replies: 5 comments
-
Hi, I've actually written unix ble variant's a couple of times but always found a reason to not push/pr it... usually because I hadn't made the time to write enough supporting docs to make it useful :-/ Micropython supports two different stacks on unix, btstack and nimble. btstack is free for open source use, but needs to be licenced for commercial use. Nimble is free for anyone to use. btstack in theory supports generic usb bluetooth dongles (build with Both stacks support "HCI over (usb) Uart" where you have a bluetooth micro set up to basically proxy the HCI commands from usb/uart to the ble controller. I put together firmware for the Nordic nrf52840 dongle to do this: https://gitlab.com/alelec/nrf52810_zephyr_hci_controller a build of which can be downloaded here: https://gitlab.com/alelec/zephyr_bluetooth_hci_usb_uart/-/jobs/793847460/artifacts/download @jimmo has since cleaned up my code for this and submitted it as an official zephyr sample application so it can now be build from there: zephyrproject-rtos/zephyr#50453 You can also use an stm32wb55 nucleo dongle with Transparant VCP firmware aka #9046 If you're using a Windows PC and want to test with WSL, you can connect your USB devices through to WSL with https://gitlab.com/alelec/wsl-usb-gui To build micropython unix port with BLE:
|
Beta Was this translation helpful? Give feedback.
-
hi @mogenson Every time I go to make a PR to add BLE variants for Unix I end up going down a rabbit hole of trying to build "sub variant" support -- i.e. "standard with nimble" or "standard with btstack". I do regularly use the Unix port with BLE support though for testing and development of BLE on MicroPython. The exact build instructions @andrewleech posted above should work. I mostly use the nRF-dongle-running-zephyr (using the example firmware that Andrew linked to -- referenced in the README here https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/bluetooth/hci_uart#using-a-usb-cdc-acm-uart). This works with NimBLE and btstack. I also occasionally use the WB55 transparent mode that Andrew mentioned. For btstack in usb mode, I also have a USB dongle based on a BCM20702. It would also be possible in theory to use your host BLE (via bluez btproxy), but the MicroPython hci code would need to be updated to be able to talk to the btproxy socket. If you want to use aioble on the Unix port, then you also need
in your mpconfigvariant.h. I'm not sure adding a variant is necessary, but we would definitely welcome any documentation updates! |
Beta Was this translation helpful? Give feedback.
-
Thank you for the great information! I'll give this a try! |
Beta Was this translation helpful? Give feedback.
-
Hello, how do I build and use the unix port with Bluetooth enabled?
I see there's some nimble and btstack source files in the unix port directory, some commits by @jimmo prototyping initial Bluetooth support on unix, a few mentions of using the unix port to test BLE, and an open PR for a Windows micropython-ble variant by @andrewleech .
What configs/defines need to be enabled to attach the micropython unix interpreter to a BT controller over UART or USB HCI? How is this setup at runtime? Are both the btstack and nimble stacks supported equally?
Finally, would a PR be welcome to create a BLE variant for the unix port and add some getting started documentation or command line help?
Beta Was this translation helpful? Give feedback.
All reactions