Skip to content

Incorporate BlueKitchen BTstack as an alternative stack to NimBLE for ubluetooth module #5672

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

Merged
merged 15 commits into from
Mar 9, 2020

Conversation

dpgeorge
Copy link
Member

This adds support for BTstack as a bluetooth stack. From the user's point of view, use of the ubluetooth module should be transparent and not depend on the stack being used.

Work done in collaboration with @jimmo.

@dpgeorge dpgeorge added extmod Relates to extmod/ directory in source port-stm32 labels Feb 20, 2020
@tve
Copy link
Contributor

tve commented Feb 20, 2020

Dumb question: what's the advantage over nimble?

@jimmo
Copy link
Member

jimmo commented Feb 20, 2020

Dumb question: what's the advantage over nimble?

Dual stack (i.e. BT Classic)

@dpgeorge
Copy link
Member Author

what's the advantage over nimble?

In addition to dual stack it's also qualified with the Bluetooth SIG. It should also be noted that it's free only for non-commercial use. For commercial use you must purchase a license from BlueKitchen: http://bluekitchen-gmbh.com/

@dpgeorge
Copy link
Member Author

@mringwal FYI

@dpgeorge dpgeorge force-pushed the extmod-bluetooth-btstack branch from 6d57f24 to 91ddc6b Compare February 21, 2020 05:43
@dmazzella
Copy link
Contributor

Is pairing and bonding planned for this new stack?

@andrewleech
Copy link
Contributor

@dmazzella pairing and bonding is certainly planned for nimble, I can't see why it wouldn't also be implemented here too (eventually). I believe pairing already works, just bonding isn't set up yet.
It's pretty straightforward to add really, just need to implement the interface between the bonding stack api and a micropython file interface, and some configuration around this.

@dpgeorge FYI nimble is also Bluetooth SIG pre-certified. https://cwiki.apache.org/confluence/display/MYNEWT/RN-NimBLE-1.1.0

Controller is now qualifiable and passes all required tests cases for BT 5.0 certification (including Extended Advertising scanner and advertiser)
Qualification ID (QDID) is 128686
Listing details can be found at https://launchstudio.bluetooth.com/ListingDetails/82155)
Host continues to be qualifiable and passes all required PTS test cases
Qualification ID (QDID) is 111164

@dpgeorge
Copy link
Member Author

FYI nimble is also Bluetooth SIG pre-certified.

Oh, great, thanks for the info. Note that the controller seems to be qualified only for nRF52, but what we want is the host part. That looks to have an older QDID here: https://launchstudio.bluetooth.com/ListingDetails/59050

@andrewleech
Copy link
Contributor

Often the QDID's are listed as Version X.Y and higher to automatically cover new releases.
Also,to the best of my understanding, to certify an end product you need QDID's that cover off all the separate layers of the stack in use.

To get some more QDID codes to use you can go here and search for NimBLE: https://launchstudio.bluetooth.com/Listings/Search

https://launchstudio.bluetooth.com/ListingDetails/82155 from before covers off the layers

4.0 Host Controller Interface
Low Energy Link Layer
Low Energy RF PHY

While this controller cert mentions nrf52 in the description I believe that doesn't matter for the certification, this should cover its use on any pre-certified radio hardware. Though the listing of PHY in this does give me pause, I think the Low Energy Link Layer is the main one needed from this listing.

This newer testing of the host looks quite relevant too,
https://launchstudio.bluetooth.com/ListingDetails/86270 covering:

Attribute Protocol
Generic Access Profile
Generic Attribute Profile
Logical Link Control and Adaption Protocol
Mesh Model
Mesh Profile
Security Manager Protocol

Of note it says: Software Version Number | 1.x (1.2.0 and higier)

I believe to get your end product certified you need to pay for your BT SIG membership, then download and run their certification application and follow its wizard. This will involve punching in any QDID's that cover off your radio, controller/low level layers and host stack and it'll tell you how much if any extra testing you need to do.

@mringwal
Copy link

Here's my quick summary (off-topic): There's a free Bluetooth SIG membership and a paid one ($8000 USD/year). With the free one, each declaration (QDID) costs $8000 USD, while it's $4000 with the paid (if you list more than 2 designs a year, the paid membership pays off).

With such a declaration, you list a "Design", which usually consists of a Bluetooth Host Subsystem (aka the Bluetooth Host Stack) and a Bluetooth Controller. You can then add any number of actual devices to that QDID, as long as they use the same stack and Bluetooth Controller. If you can refer to already listed stacks / controllers, you can reference them without additional testing. You may also ask your local Bluetooth Qualification Consultant (BQC)... :)

@dpgeorge dpgeorge force-pushed the extmod-bluetooth-btstack branch 2 times, most recently from f58a34f to 4b12c54 Compare March 3, 2020 10:59
@mringwal
Copy link

mringwal commented Mar 3, 2020

What would be needed to try this with the MP unix port e.g. with USB Bluetooth dongle? I can take care of the BTstack configuration, but it needs to link against libusb and the BTstack setup seems to be confined to the STM32 realm. (no hurry, just curious here).

@jimmo
Copy link
Member

jimmo commented Mar 4, 2020

@mringwal I picked up a USB dongle this morning and tested it with the btstack examples (e.g. le_counter, gap_le_advertisements), so should be fairly easy to make this work in the Unix port. Will update soon.

Thanks for the really quick turnaround on bluekitchen/btstack#272 !

@mringwal
Copy link

mringwal commented Mar 4, 2020

@jimmo excellent. for usb, the default config is to find a suitable usb bluetooth dongle and use it for. For other, e.g. UART bluetooth modules, more config would be needed. I guess the config could be done via optional parameters or additional python method calls. (but this really can wait, usb is the dominant use case on desktops)

dpgeorge added 2 commits March 6, 2020 12:35
The bluetooth stack has its own dedicated polling function, see
mod_bluetooth_nimble_poll_wrapper().
Move extmod/modbluetooth_nimble.* to extmod/nimble.  And move common
Makefile lines to extmod/nimble/nimble.mk (which was previously only used
by stm32).  This allows (upcoming) btstack to follow a similar structure.

Work done in collaboration with Jim Mussared aka @jimmo.
@dpgeorge dpgeorge force-pushed the extmod-bluetooth-btstack branch 2 times, most recently from f8299fa to c68d43b Compare March 7, 2020 11:35
This makes a cleaner separation between the: driver, HCI UART and BT stack.
Also updated the naming to be more consistent (mp_bluetooth_hci_*).

Work done in collaboration with Jim Mussared aka @jimmo.
For use by other stacks, if they need it.

Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Work done in collaboration with Jim Mussared aka @jimmo.
Now all HCI specific code (eg UART vs WB55 internal messaging) is confined
to modbluetooth_hci.c.
@dpgeorge dpgeorge force-pushed the extmod-bluetooth-btstack branch from c68d43b to ecee6f2 Compare March 9, 2020 15:00
@dpgeorge dpgeorge merged commit ecee6f2 into micropython:master Mar 9, 2020
@dpgeorge dpgeorge deleted the extmod-bluetooth-btstack branch March 9, 2020 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source port-stm32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants