I have a problem with the implementation of BLE with my ExpLoRer card. I have written my code based on the example code called “BLE_Peripheral.ino” provided by Microchip:
const char* myDeviceName = "Proto01" ; // Custom Device name const char* myPrivateServiceUUID = "AD11CF40063F11E5BE3E0002A5D5C51B" ; // Custom private service UUID const char* temperatureCharacteristicUUID = "BF3FBD80063F11E59E690002A5D5C501" ; // custom characteristic GATT const uint8_t temperatureCharacteristicLen = 2 ; // data length (in bytes) const uint16_t temperatureHandle = 0x72 ; char temperaturePayload[temperatureCharacteristicLen*2] ; float temperature_s ; uint8_t newTempValue_u8 = 0 ; uint8_t prevTempValue_u8 = 0 ; const char* ledCharacteristicUUID = "BF3FBD80063F11E59E690002A5D5C503" ; // custom characteristic GATT const uint8_t ledCharacteristicLen = 6 ; uint16_t ledHandle = 0x75 ; const char* ledPayload ;
I works well, though I cannot understand the value of “handles”. Indeed, I want to have 2 services (one for battery level, uses GATT standards 180F for service UUID and 2A19 for batteryLevel UUID - and one private “lockState”, with my own 128-bit UUIDs (for service and characteristics).
To do so, I reuse the temperature stuff for the battery, which works Ok, but then for the “lockState”, I just want a boolean, so I change the ledCharacteristicLen to 1, but then the ledHandle is wrong, and I can’t figure out how to find the right handle …
Here’s my code for declarations:
const char* myDeviceName = "Proto01" ; // Custom Device name const char* batteryServiceUUID = "180F" ; // Custom private service UUID const char* batteryLevelCharacteristicUUID = "2A19" ; // public characteristic GATT const uint8_t batteryCharacteristicLen = 2 ; // data length (in bytes) const uint16_t batteryHandle = 0x72 ; char batteryPayload[batteryCharacteristicLen*2] ; const char* lockStateServiceUUID = "AD11CF40063F11E5BE3E0002A5D5C51B" ; // Custom private service UUID const char* lockStateCharacteristicUUID = "BF3FBD80063F11E59E690002A5D5C503" ; // custom characteristic GATT const uint8_t lockStateCharacteristicLen = 1 ; uint16_t lockStateHandle = 0x75 ; // ??? const char* lockStatePayload ;
I just know that the “handle” seem to be an address in which the characteristic value is stored.
Could you please help me about these handles and characteristic lengths ?
Thank you so much in advance!