I currently have a working Android App (code snippet posted down below) that scans for BLE devices but uses hard-coded UUID's to only work with 1 specific device. While the app successfully connects and reads data that has read permissions, it seems as though the data I want comes with NOTIFY and WRITE NO RESPONSE only and therefore cannot be read normally. I am looking for a solution to work around this barrier. I have already tried reading from all other Services and their respective characteristics to see if my wanted data is there and so far no luck.
I have scanned the device to get all of its services and characteristics (Screenshot of all services provided):
https://imgur.com/a/mYWnAwO
Keep in mind I am aware that I am showcasing the devices mac address. However, knowing what type of device it is this will not matter.
as well as put together an android app to read the information from these services. Currently, I have the UUID's hardcoded in and connected to a readable service/characteristic however its value is always 0100 (clearly not what I want).
public void readCustomCharacteristic() {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
/*check if the service is available on the device*/
BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("0000feba-0000-1000-8000-00805f9b34fb"));
if(mCustomService == null){
Log.w(TAG, "Custom BLE Service not found");
return;
}
/*get the read characteristic from the service*/
BluetoothGattCharacteristic mReadCharacteristic = mCustomService.getCharacteristic(UUID.fromString("0000fa12-0000-1000-8000-00805f9b34fb"));
if(mBluetoothGatt.readCharacteristic(mReadCharacteristic) == false){
Log.w(TAG, "Failed to read characteristic");
}
}
public void writeCustomCharacteristic(int value) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
/*check if the service is available on the device*/
BluetoothGattService mCustomService = mBluetoothGatt.getService(UUID.fromString("0000feba-0000-1000-8000-00805f9b34fb"));
if(mCustomService == null){
Log.w(TAG, "Custom BLE Service not found");
return;
}
/*get the read characteristic from the service*/
BluetoothGattCharacteristic mWriteCharacteristic = mCustomService.getCharacteristic(UUID.fromString("0000fa11-0000-1000-8000-00805f9b34fb"));
mWriteCharacteristic.setValue(value,android.bluetooth.BluetoothGattCharacteristic.FORMAT_UINT8,0);
if(mBluetoothGatt.writeCharacteristic(mWriteCharacteristic) == false){
Log.w(TAG, "Failed to write characteristic");
}
}
The number that appears on my server (peripheral) needs to be the value captured via BLE and most certainly should be under one of these services and one specific characteristic. However, it's all a matter of finding it and deciphering it so it becomes human-readable on my end (Android App).