3

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:

  1. Set the application to pairing mode to start scanning.
  2. Start pairing of A&D BLE device following each instruction manual.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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 !!

2 Answers 2

3

There's an Android Open Source Project example that does precisely this, easiest option would be to clone the android-BluetoothLeGatt code, build and compare it to your own. If you can't spot the difference / issue simply deploy both app's and step through both sets of code. Having some known working code will also help to rule out the possibility that the HRM is not functioning properly.

1
  • Thanks for this link, i see this project, the problem is that the device i'm working on need write operations and this project doesn't show we can write values and descriptors
    – user4844052
    Jul 29, 2015 at 8:40
1

Do you have and example , i try this with equal device and i cant obtain the information y try with

public String response() {
if (mConnected) {
    mBluetoothLeService.readCharacteristic(characteristica);
    byte response[] = characteristica.getValue();
    String respuesta = ReadBytes(response);
    mBluetoothLeService.disconnect();
    return respuesta;
} else {
    return null;
}
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.