Hello,
Is there a way to read a characteristic on a peripheral using the handle number rather than having to perform the discovery process? I am building a pseudo-mesh network with BLE devices and I find that Particle.io’s BLE stack is quite limited because it requires that a discovery be performed prior to reading a remote characteristic. On other MCUs I am able to skip that step.
When connecting to a peripheral with one Service and one Characteristic. (These times increase if there are more characteristics to discover)
connect(auto = true) – About 1440ms to execute
peer = BLE.connect(ble_address, true); // 1400ms to execute
peer.getCharacteristicByUUID(characteristic, characteristic_uuid); // 40ms to execute
connect(auto = false) – About 1440ms to execute
peer = BLE.connect(ble_address, true); // 40ms to execute
peer.discoverAllCharacteristics(); // 1360ms to execute
peer.getCharacteristicByUUID(characteristic, characteristic_uuid); // 40ms to execute
The bulk of the time to perform the connection, read the characteristic and disconnect is spent in the discovery phase.
On other MCUs where I can read a characteristic using the handle number, I am able to complete this entire process in under 200ms. The handle numbers stay static. So what I would like to do is perform a discovery the first time I connect to a device, and then use a cached handle number for future connections.
I have been looking through the BLE class code (https://github.com/particle-iot/device-os/blob/b64994ea79ac8363fb973113f64335071f13a583/wiring/src/spark_wiring_ble.cpp) without any luck of finding a solution. But maybe there is a process in there I missed.
Any thoughts would be appreciated. Thank you.