How to simultaneously scan and advertise during a connection for STM32WB55
Hi all,
I am designing a system of microcontrollers for a research project that take RSSI measurements from each other and send the collected data to a connected android device. All of the microcontrollers in the system are flashed with the same or similar program since some of the microcontrollers are Nucleo-64 and others are USB Dongle. All of the microcontrollers in the system are connected to the android device through a BLE connection that is initiated by the android device. I developed the code for the microcontrollers by altering code generated by CubeMX.
Currently, I am using the RSSI received from advertising packets as the RSSI data to be sent to the android device. When I tried to run a scan while advertising I got the error 0x82 (No valid slot). When I tried to advertise during a scan I got the error 0x0C (Command disallowed). I am able to simultaneously scan and advertise when the microcontrollers are not connected to the android device, so I am assuming this issue relates to the connection timing as mentioned in Part 5 of the STM32WB BLE stack programming guidelines (PM0271).
I was able to work around this issue by alternating between scanning and advertising, with the scanning performed for a random period of time. This approach works well, but occasionally misses measurements within the desired time frame, so I would still like to scan and advertise simultaneously if possible.
My scan has the following parameters:
aci_gap_start_observation_proc(0x0010, 0x0010, 0x00, 0x00, 0x00, 0x01);
My advertising has the following parameters:
aci_gap_set_discoverable(ADV_IND, 0x0020, 0x0020, 0x00, ADV_FILTER, 0, 0, 0, 0, 0, 0);
The advertising data is set using the code generated by CubeMX.
Keep in mind that I am new to BLE and microcontrollers in general, so if you need any more information or clarification, please let me know.