次の問題があります。アプリケーションが動作するときに、特性 (BluetoothGattCharacteristic) の記述子 (BluetoothGattDescriptor) を動的に変更する必要があります。
残念ながら、BluetoothGattServer の関数 notifyCharacteristicChanged() は、特性の値のみを更新します (Andoird ソースでこの関数を検索しました - https://github.com/android/platform_frameworks_base/blob/master/core/java/android/bluetooth/BluetoothGattServer.java )、記述子は無視されます。
私の記述子は、接続が確立されたときに一度だけ読み取られます。しかし、動的に変更したいので、毎回再接続することはできません。
UUID が同じで記述子が異なる 2 つのサービスまたは特性を追加しても、問題は解決しませんでした。それらを区別することはできませんでした。
誰もが同様の問題に直面しましたか?
これはコードです:
BluetoothGattCharacteristic bc = mBluetoothGattServer.getService(service).getCharacteristic(characteristic);
bc.setValue(data);
bc.getDescriptor(descriptor).setValue(new byte[]{0, 0}); <- no effect here
mBluetoothGattServer.notifyCharacteristicChanged(connectedDevice, bc, false);
アドバイスありがとうございます!