Context: RAK-4631/RUI3 BLE Custom Service example
I’m trying to run @beegee 's example code and have hit a few questions.
1/ Is there no way to set the Device UUID? How is it generated? The reason I ask is that I’d like to be able to filter the list of advertised devices (to contain just my RAK 4631 devices) prior to making the connection, but if they are randomly assigned then I can’t filter on device UUID.
2/ The BLE_CONNECT and BLE_DISCONNECT event callbacks don’t appear to work. I’ve used them in previous BLE UART serial tests successfully. All I do is turn the BLUE_LED on or off so they’re not complicated handlers. I added the Serial text just in case.
void cbConnected( void ) {
Serial.println("BLE Connected");
digitalWrite(BLUE_LED, 1);
}
void cbDisconnected( void ) {
Serial.println("BLE Disconnected");
digitalWrite(BLUE_LED, 0);
}
...
pinMode(BLUE_LED, OUTPUT);
...
api.ble.registerCallback (BLE_CONNECTED, cbConnected );
api.ble.registerCallback (BLE_DISCONNECTED, cbDisconnected );
3/ When I connect to the RAK 4631 device and then click to enable notify for the Heart Rate Measurement (HRM) Service, the serial terminal shows the println output expected from cccd_callback, and then it crashes.
The “still going yeah” line is generated in the main loop:
void loop()
{
Serial.println("still going yeah");
delay(1000);
}
Notice that it manages just one more output after the cccd_callback generated text.
The “central” that I’m using is my iPhone. I have tried several Apps and they all produce this same behavior.
nRF Toolbox looking for the heart rate service (HRS) successfully filters to show only the 4631 service. (If, for example, I look for blood pressure monitoring, it doesn’t list any service, but it finds the HRS just fine). However, as soon as I click connect, nRF Toolbox reports that it can’t parse the data. While this is a problem, it’s not as big a problem as the peripheral side (ie the 4631) crashing, with follow up downloads locked out until a hard reset.
The other two Apps I have used are Renasys’s GATT Browser and BluetoothDemo by Itsuki. All three Apps generate the same peripheral behaviour. These last two allow more control over the connection. The crash happens when Notify is enabled.
ie Both Renesys and Itsuki apps can issue a read of the sensor location (ID:2A38) that triggers the “send_callback” text and data (0x02). Most importantly, the read action does not crash the BLE demo code.
It’s always possible that I’m missing something, but I’ve tried to isolate the issues as best I can.