3

「A&D UA-651BLE」デバイスのHRMの値を取得したいです。これは、HRM値を取得するためにこのデバイスのデータシートに書かれているものです:

  1. アプリケーションをペアリングモードに設定して、スキャンを開始します。
  2. 各取扱説明書に従って、A&D BLE デバイスのペアリングを開始します。
  3. ペアリング モードでは、アプリケーションは時刻と日付、およびその他のデバイス設定を A&D BLE デバイスに設定する必要があります。ペアリングが成功すると、A&D BLE デバイスの画面に「End」が表示されます。
  4. 測定を行い、測定を終了すると、A&D BLE デバイスはアドバタイジングで BLE 接続を開始します。アプリケーションは、A&D BLE デバイスのアドバタイジングをできるだけ早くキャッ​​チできるように、適切な間隔でスキャンを開始します。
  5. アプリケーションは、初期接続時またはペアリング時に CCCD (Client Characteristic Configuration Descriptor) に「2」を設定し、A&D BLE デバイスが Indication で測定データを送信するようにします。
  6. A&D デバイスは接続後 5 秒以内に CCCD に「2」が設定され、時刻と日付が同期されていることを認識した後、Indication でデータを送信します。
  7. タイムアウト セット CCCD と時刻と日付が期限切れになると、A&D BLE デバイスはデータを送信せず、データをメモリに保存します。A&D BLE デバイスに保存されたデータは、次の成功した接続を送信できます。

これは私のサービスコードです:

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);
        }
    }

これはデータを読み取るメソッドです。

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);
            }

問題は、このコードがデータを返さないことです!!

4

2 に答える 2