2022-06-29 06:04 AM
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.
2022-06-29 07:27 AM
Wouldn't BLE Mesh be more appropriate here?
2022-06-29 07:38 AM
I have looked into using BLE Mesh for this, but for this system I need all devices to receive measurements directly from the other devices without a relay in between. For this reason, I decided not to use it.
2022-06-30 09:37 AM
Hello,
In order to be able to scan and advertise during a connection, you have to tune some parameters like scan interval, scan window, advertising interval and connection interval. For more details about the commands you can look this document which describe each command and the parameters of these commands. And have a look into ble_conf.h file to define the role of your device:
/**
* This setting shall be set to '1' if the device needs to support the Peripheral Role
* In the MS configuration, both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL shall be set to '1'
*/
#define BLE_CFG_PERIPHERAL 1
/**
* This setting shall be set to '1' if the device needs to support the Central Role
* In the MS configuration, both BLE_CFG_PERIPHERAL and BLE_CFG_CENTRAL shall be set to '1'
*/
#define BLE_CFG_CENTRAL 0
Best Regards