2

i have issue with ble getting disconnecting, below is my code i changes it based on some answer earlier is used to get response which show data from ble device to my phone ,

but after code change i can not get data from device i think it has to do something with "ENABLE_INDICATION_VALUE" and "ENABLE_NOTIFICATION_VALUE"

can i call both at same time

public void setCharacteristicNotification(BluetoothGattCharacteristic bluetoothgattcharacteristic, boolean flag)
{
    if(mBluetoothAdapter == null || mBluetoothGatt == null)
    {
        Log.w(TAG, "BluetoothAdapter not initialized");
    } else
    {
        mBluetoothGatt.setCharacteristicNotification(bluetoothgattcharacteristic, flag);
        BluetoothGattDescriptor bluetoothgattdescriptor = bluetoothgattcharacteristic.getDescriptor(UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
        if(bluetoothgattdescriptor != null)
        {       bluetoothgattdescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            mBluetoothGatt.writeDescriptor(bluetoothgattdescriptor);
            return;
        }
    }
}

later based on given stackoverflow question:

enter link description here

i changed below line

bluetoothgattdescriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);

to bluetoothgattdescriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);

Community
  • 1
  • 1
mydeve
  • 553
  • 1
  • 14
  • 39

0 Answers0