Currently i am working with an application where it involves reading data from the ble device. I am trying to read data from Andesfit Thermometer, Andesfit Blood Pressure, Andesfit Body Weight Scale.
For that i need to notify using Characteristic UUID. The notification stuff works fine and i am receiving data properly when any of the devices emits data.
Think about a situation where the user has already taken a measurement using the blood pressure machine. Then he picked up his device, got connected. I should be able to retrieve the last record and show it in the device.
In order to show the last record i need to read the characteristic using UUID
In iOS i am can retrieve the last record & notify using the same characteristic UUID and it is working fine.
characteristic UUID is 2A1C
peripheral.setNotifyValue(true, for: characteristic)
peripheral.readValue(for: characteristic)
But in Android if i try to read using the characteristic UUID that used for notify it gives me exception.
rxBleDevice.establishConnection(false, Timeout(12000, TimeUnit.MILLISECONDS))
.flatMapSingle { rxBleConnection ->
rxBleConnection.readCharacteristic(UUID.fromString("00002a1c-0000-1000-8000-00805f9b34fb"))
.subscribe({bytes ->
},{t: Throwable? ->
var mess = t!!.localizedMessage
t.printStackTrace()
})
Exception message is
GATT exception from MAC address F4:5E:AB:0D:7B:93, with type BleGattOperation{description='CHARACTERISTIC_READ'}
Here is my service discovery operation in Android
In my service discovery i can clearly see that this characteristic UUID is just meant for notify.
V/RxBle#ServiceDiscoveryOperation: Primary Service - Health Thermometer (00001809-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Instance ID: 51
V/RxBle#ServiceDiscoveryOperation: -> Characteristics:
V/RxBle#ServiceDiscoveryOperation: * Temperature Measurement (00002a1c-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Properties: [ INDICATE ]
V/RxBle#ServiceDiscoveryOperation: -> Descriptors:
V/RxBle#ServiceDiscoveryOperation: * Client Characteristic Configuration (00002902-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: * Characteristic Presentation Format (00002904-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: * Temperature Type (00002a1d-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Properties: [ READ ]
V/RxBle#ServiceDiscoveryOperation: * Intermediate Temperature (00002a1e-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Properties: [ NOTIFY ]
V/RxBle#ServiceDiscoveryOperation: -> Descriptors:
V/RxBle#ServiceDiscoveryOperation: * Client Characteristic Configuration (00002902-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: * Measurement Interval (00002a21-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Properties: [ READ WRITE INDICATE ]
V/RxBle#ServiceDiscoveryOperation: -> Descriptors:
V/RxBle#ServiceDiscoveryOperation: * Client Characteristic Configuration (00002902-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: * Valid Range (00002906-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Primary Service - Battery Service (0000180f-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Instance ID: 65
V/RxBle#ServiceDiscoveryOperation: -> Characteristics:
V/RxBle#ServiceDiscoveryOperation: * Battery Level (00002a19-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: Properties: [ READ NOTIFY ]
V/RxBle#ServiceDiscoveryOperation: -> Descriptors:
V/RxBle#ServiceDiscoveryOperation: * Client Characteristic Configuration (00002902-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: * Report Reference (00002908-0000-1000-8000-00805f9b34fb)
V/RxBle#ServiceDiscoveryOperation: --------------- ====== Finished peripheral content ====== ---------------