I want to get the value of the HRM of an "A&D UA-651BLE" device. this is what's written in the datasheet of this device to get the HRM value:
- Set the application to pairing mode to start scanning.
- Start pairing of A&D BLE device following each instruction manual.
- At pairing mode, the application should set time and date and any other device settings to A&D BLE device. After successful pairing, A&D BLE device shows “End” on the screen.
- Take a measurement and finish the measurement, then A&D BLE device start BLE connection with advertising. The application starts scanning with suitable interval so that the application catches the advertising of A&D BLE device as soon as it can.
- At initial connection or pairing, the Application set “2” to CCCD (Client Characteristic Configuration Descriptor) so that A&D BLE device sends a measurement data with Indication.
- After A&D device recognizes to be set “2” to CCCD and to be synchronized time and date within 5 seconds after connected, send the data with Indication.
- If the timeout set CCCD and time and date is expired, A&D BLE device will not send data and store the data in memory. The stored data in A&D BLE device can send next successful connection.
this is my service code:
public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic,
boolean enabled) {
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
Log.w(TAG, "BluetoothAdapter not initialized");
return;
}
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
// This is specific to Heart Rate Measurement.
if (UUID_HEART_RATE_MEASUREMENT.equals(characteristic.getUuid())) {
BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
mBluetoothGatt.writeDescriptor(descriptor);
}
}
and this is the method that read data:
final byte[] data = characteristic.getValue();
if (data != null && data.length > 0) {
final StringBuilder stringBuilder = new StringBuilder(data.length);
for(byte byteChar : data)
stringBuilder.append(String.format("%02X ", byteChar));
Log.e("HRM value",stringBuilder.toString());
dataComposition.put(characteristic.getUuid().toString(),stringBuilder.toString());
intent.putExtra(EXTRA_DATA,dataComposition);
}
the problem is that this code doesn't return any data !!