embassy icon indicating copy to clipboard operation
embassy copied to clipboard

WIP: cyw43 / Pico W bluetooth, take 2

Open Dirbaio opened this issue 1 year ago • 3 comments

Based on #1820, rebased and cleaned up a bit.

cc issue #1516

Current status is

  • Bluetooth init works
  • Sending/receiving HCI packets works
  • There's an example using the trouble bluetooth stack that works up to advertising. There's some impedance mismatch in how to glue it with trouble's HCI traits.

Major roadblocks left are:

  • Properly integrate bluetooth into the cyw43 event loop, so you can concurrently use it with WiFi. It'd probably need setting up HCI packet queues with ZerocopyChannel similar to how ethernet packets are handled, allowing the user to run Trouble in a separate "bluetooth task"
  • Design a good API for constructing the cyw43 driver in either "just wifi", "just bluetooth" or "wifi+bluetooth" modes. The API should be designed so that you don't pay for what you don't use, ie if you initialize just wifi you don't need bluetooth firmware on flash, and the bluetooth-specific code from cyw43 doesn't get compiled-in. Can be done with either "mode" generics, or Cargo features. Cargo features is probably easier.
  • Get it properly hooked up to Trouble, so that more than just advertising works.

I don't have the bandwidth to work on this, and probably won't for a while (months). If you want to jump in and carry this over the finish line, ping me on Embassy's Matrix chat.

Dirbaio avatar Apr 24 '24 17:04 Dirbaio

Quick update: i've update the bluetooth_trouble example to use the latest developments from trouble and bt-hci would should simplify the integration quite a bit.

lulf avatar Apr 24 '24 18:04 lulf

nie :rocket:

(note: when this is finished, we probably want the example to live in the trouble repo. I think that's where most of the "API evolution" will be, so it'll be easier to keep it up to date there. The cyw43 API is just "hci read, hci write" so probably won't change much once done.)

Dirbaio avatar Apr 24 '24 18:04 Dirbaio

Would you be interested in merging this (so it doesn't go stale) now and let the "combined WiFi mode" related features sit in a backlog?

I'm down to try this part:

Get it properly hooked up to Trouble, so that more than just advertising works.

brandonros avatar Apr 26 '24 13:04 brandonros

So, what still needs done, here? I'm hesitant to commit myself to helping, since I'm not very experienced with rust and have a mediocre track record with volunteer projects, but I'm considering it.

Erhannis avatar Jul 31 '24 14:07 Erhannis

Advertising works, connecting works, GATT works.

Things left for the future:

  • Interrupts aren't working for some reason. The driver falls back to hot polling if you enable bluetooth.
  • No way to initialize bluetooth only yet.

Dirbaio avatar Aug 05 '24 19:08 Dirbaio

Apparently, this PR broke WiFi support for rp: wifi_tcp_server example, please see: #3237.

marxin avatar Aug 07 '24 14:08 marxin