You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While developing our software which needs to receive input from several Bluetooth devices, we have run into a strange problem.
Any help would be very appreciated.
Problem Description:
An ESP32-S3-DevKitC-1-N32R8V connects to two peripheral devices (A and B). After detecting a device, its peripheral object is stored in a global std::unordered_map. Once both devices are detected, the std::unordered_map contains two elements, each representing an instance of the PeripheralDevice class.
The PeripheralDevice constructor performs the following actions:
Stores the passed peripheral object from BLE.available().
Connects to the device.
Connects to a service and subscribes to a characteristic.
Sets up an event handler of type BLEUpdated using the setEventHandler method.
Upon successful connection, event handlers for each characteristic are set. The BLE devices send data arrays of 60 bytes approximately 60 times per second.
Expected Behavior:
The event handler Handler_A in instance A should receive data only from Device A.
The event handler Handler_B in instance B should receive data only from Device B.
Actual Problem:
When changes occurs on Device A (e.g., a button press), the Handler_B of instance B also sometimes receives events and data originating from Device A, in an undefined order. This remains consistent with different numbers of devices (three or more) as well.
Additional Observations:
The issue persists even if polling the devices directly instead of subscribing to BLE notifications. When using direct functions like valueUpdated() and canRead() to read data in each instance (A and B), reading data via Instance B still appears to receive data from Device B and vice versa. Each instance uses its own reading functions, which are expected to operate independently.
Code Overview:
Connection Description:
Two identical peripheral devices (A and B) connect to the Arduino board, which retrieves data from them.
While developing our software which needs to receive input from several Bluetooth devices, we have run into a strange problem.
Any help would be very appreciated.
Problem Description:
An ESP32-S3-DevKitC-1-N32R8V connects to two peripheral devices (A and B). After detecting a device, its
peripheral
object is stored in a globalstd::unordered_map
. Once both devices are detected, thestd::unordered_map
contains two elements, each representing an instance of thePeripheralDevice
class.The
PeripheralDevice
constructor performs the following actions:peripheral
object fromBLE.available()
.BLEUpdated
using thesetEventHandler
method.Upon successful connection, event handlers for each characteristic are set. The BLE devices send data arrays of 60 bytes approximately 60 times per second.
Expected Behavior:
Handler_A
in instanceA
should receive data only from Device A.Handler_B
in instanceB
should receive data only from Device B.Actual Problem:
When changes occurs on Device A (e.g., a button press), the
Handler_B
of instanceB
also sometimes receives events and data originating from Device A, in an undefined order. This remains consistent with different numbers of devices (three or more) as well.Additional Observations:
The issue persists even if polling the devices directly instead of subscribing to BLE notifications. When using direct functions like
valueUpdated()
andcanRead()
to read data in each instance (A
andB
), reading data via Instance B still appears to receive data from Device B and vice versa. Each instance uses its own reading functions, which are expected to operate independently.Code Overview:
Connection Description:
Two identical peripheral devices (A and B) connect to the Arduino board, which retrieves data from them.
After scanning, peripherals are stored in:
PeripheralDevice
Constructor:Store
peripheral
in the instance:PeripheralDevice::PeripheralDevice(BLEDevice &_peripheral) { peripheral = _peripheral; }
Connect to the device:
Discover and connect to a service:
if (peripheral.discoverService(UUID_CUSTOM_SERVICE) && (service = peripheral.service(UUID_CUSTOM_SERVICE))) { ... }
Connect to a characteristic:
Subscribe to the characteristic:
Set up an event handler:
Steps to Reproduce:
PeripheralDevice
class to manage each connection and subscribe to their characteristics.Environment:
The text was updated successfully, but these errors were encountered: