GrumpyOldPizza / ArduinoCore-stm32wb

Arduino Core for STM32WB
19 stars 10 forks source link

BLE Central Implementation #2

Open BigCorvus opened 2 years ago

BigCorvus commented 2 years ago

Hi, is there a way of implementing BLE central functionality ideally concurrently with peripheral role on your core? I have a use case that requres a connection to multiple BLE peripherals while acting as a peripheral at the same time. I'd love to see how the WB55 performs on this task. Keep up the great work! Best, Arthur

nguyenmanhthao996tn commented 1 year ago

I have the same question! I just need to scan the available devices and get their ID. I tried to use examples from BLE folder with following steps:

The _aci_gap_start_general_discoveryproc function seems to work. Because it's always return BLE_STATUS_NOT_ALLOWED before the scan timeout (10.24 seconds) and BLE_STATUS_SUCCESS after the scan!

However, the events that used to retrieve data are never called! Don't know if I miss something. Tried to check with the stack from STM32 but they always use polling + switch/case.

GrumpyOldPizza commented 1 year ago

I need to add that hopefully soon than later. There are a few issues though. Main one is the API ... ArduinoBLE uses (I think) ::available() ... That just feels wrong. Scanned devices get discovered async, so how to allocate the backing object ...

The BLE class itself uses a switch statement to process it's events (BLELocalDevice::process()). So hooking in the ST style callback functions is not supported. I'd think it should be possible to write some small piece of code to bypass the whole BLE class and use ST's stack directly (raw event-callback and raw request functions).

BigCorvus commented 1 year ago

Cool! Meh, BLE code without callbacks is like soldering without heat. Who needs the ArduinoBLE library anyway? ;)