2017-05-03 3 views
1

BLE 장치 (pulsometer) 값은 항상 동일합니다. 신호가 onCharacteristicChanged로 이동하지만 값이 변경되지 않고 다른 방식으로 값을 얻으려고 시도합니다.GATT 특성 값이 변경되지 않음

@Override 
public void onServicesDiscovered(BluetoothGatt gatt, int status) { 
super.onServicesDiscovered(gatt, status); 
    BluetoothGattCharacteristic characteristic3 = gatt.getService(UUID.fromString("0000180f-0000-1000-8000-00805f9b34fb")) 
        .getCharacteristic(UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb")); 
    gatt.setCharacteristicNotification(characteristic3, true); 
    gatt.readCharacteristic(characteristic3); 
} 

@Override 
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) { 
    super.onCharacteristicRead(gatt, characteristic, status); 
    UUID uuid = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"); 
    BluetoothGattDescriptor descriptor = characteristic.getDescriptor(uuid); 
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 
    gatt.writeDescriptor(descriptor); 
} 

@Override 
public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { 
    super.onCharacteristicChanged(gatt, characteristic); 
    Log.e(TAG, "pulse: " + characteristic.getIntValue(BluetoothGattCharacteristic.FORMAT_UINT8, 0)); 
} 

logcat

+0

확인이 HTTPS :/도움이된다면 /github.com/devunwired/accessory-samples/blob/master/BluetoothGatt/src/com/example/bluetoothgatt/MainActivity.java. – Raghunandan

답변

0

결정 :

@Override 
    public void onServicesDiscovered(BluetoothGatt gatt, int status) { 
    super.onServicesDiscovered(gatt, status); 

    BluetoothGattCharacteristic characteristic2 = gatt.getService(UUID.fromString("0000180d-0000-1000-8000-00805f9b34fb")) 
        .getCharacteristic(UUID.fromString("00002a37-0000-1000-8000-00805f9b34fb")); 

    gatt.setCharacteristicNotification(characteristic2, true); 

    // 1 !!!!!! 
    UUID uuid = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"); 
    BluetoothGattDescriptor descriptor = characteristic2.getDescriptor(uuid); 
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 
    gatt.writeDescriptor(descriptor); 

    // 2 !!!!!! 
    gatt.readCharacteristic(characteristic2); 
} 

Helped , 변화의 UUID (it can be found) 및 LIB GET 값 - SmartGattLib, 모든 작업)