당신은 가능한 모든 특성의 목록을 가지고있다. 당신은 GATT 콜백의 특성을받을 때
다음
// All BLE characteristic UUIDs are of the form:
// 0000XXXX-0000-1000-8000-00805f9b34fb
// The assigned number for the Heart Rate Measurement characteristic UUID is
// listed as 0x2A37, which is how the developer of the sample code could arrive at:
// 00002a37-0000-1000-8000-00805f9b34fb
public static class Characteristic {
final static public UUID HEART_RATE_MEASUREMENT = UUID.fromString("00002a37-0000-1000-8000-00805f9b34fb");
final static public UUID CSC_MEASUREMENT = UUID.fromString("00002a5b-0000-1000-8000-00805f9b34fb");
final static public UUID MANUFACTURER_STRING = UUID.fromString("00002a29-0000-1000-8000-00805f9b34fb");
final static public UUID MODEL_NUMBER_STRING = UUID.fromString("00002a24-0000-1000-8000-00805f9b34fb");
final static public UUID FIRMWARE_REVISION_STRING = UUID.fromString("00002a26-0000-1000-8000-00805f9b34fb");
final static public UUID APPEARANCE = UUID.fromString("00002a01-0000-1000-8000-00805f9b34fb");
final static public UUID BODY_SENSOR_LOCATION = UUID.fromString("00002a38-0000-1000-8000-00805f9b34fb");
final static public UUID BATTERY_LEVEL = UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb");
final static public UUID CLIENT_CHARACTERISTIC_CONFIG = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb");
}
, (목록에 대해) 확인하려고 그것이 특징 :
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
...
@Override
public void onCharacteristicRead(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic,
int status) {
if (status == BluetoothGatt.GATT_SUCCESS) {
getCharacteristicValue(characteristic);
}
}
@Override
public void onCharacteristicChanged(BluetoothGatt gatt,
BluetoothGattCharacteristic characteristic) {
getCharacteristicValue(characteristic);
}
}
private void getCharacteristicValue(BluetoothGattCharacteristic characteristic) {
if(characteristic.getUuid().equals(Characteristic.HEART_RATE_MEASUREMENT)) {
if (mType == Accessory.Type.HRM && mBtLeGattServiceHeartrate != null) {
mBtLeGattServiceHeartrate.onCharacteristicChanged(mContext, BtLeDevice.this, characteristic);
}
}
}
희망이 여기에 그 중 일부를 포함하는 클래스입니다 도움이됩니다.
BluetoothGatt.getServices() 원격 장치에서 제공하는 GATT 서비스 목록을 반환합니다. 그 후에 서비스를 통해 각 서비스의 특성을 파악할 수 있습니다. idk 당신이 잘못하고있는 일. 가능한 경우 일부 코드를 공유하십시오. –