Я использую Android Nexus 7 для подключения устройства по каналу Bluetooth Low Energy. Я могу подключить устройство и оставаться на связи, если я не свяжусь с устройством.
Однако, если я включу уведомление об одном конкретном признаке, нажав кнопку, устройство отключится от планшета через несколько секунд передачи данных.
Кто-нибудь знает, в чем проблема? Большое вам спасибо!
Здесь мой код:
    public boolean setCharacteristicNotification(boolean enabled){
      if (mBluetoothAdapter == null || mBluetoothGatt == null) {
          Log.w(TAG, "BluetoothAdapter not initialized");
               return false;      
      }
      BluetoothGattService Service = mBluetoothGatt.getService(UUID_MY_SERVICE);
      if (Service == null) {
          Log.e(TAG, "service not found!");
          return false;
      }
      BluetoothGattCharacteristic characteristic = Service.getCharacteristic(UUID_MY_CHARACTERISTIC);
      final int charaProp = characteristic.getProperties();
      if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) > 0) {
          mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
            BluetoothGattDescriptor descriptor = characteristic.getDescriptor(
                    UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 
            mBluetoothGatt.writeDescriptor(descriptor);
          return true;
      }
    return false;
}
