C#でBLE通信を行うWPFアプリを製作しています。
セントラルはWPFでペリフェラル側はAndroid端末となっています。
環境
- Visual Studio2019 Community
- 参照設定にWindos.winmd、System.Runtime.Windows.Runtime.dllを追加
- Bluetooth4.0使用
現在確認していること
- ディスクリプターを読んだ際、戻り値として"ProtocolError"が返ってくる。
- Write、Readは問題ない
- iOSの"BLE Scanner"アプリにてNotify受信確認済み
- Android(Peripheral側)のCharacteristic config uuidを何度か変更しても変化なし
C#
1if (properties.HasFlag(GattCharacteristicProperties.Notify)) 2{ 3 var currentDescriptor = await characteristics.Characteristics.FirstOrDefault().ReadClientCharacteristicConfigurationDescriptorAsync(); 4 5 if ((currentDescriptor.Status != GattCommunicationStatus.Success) || 6 (currentDescriptor.ClientCharacteristicConfigurationDescriptor != GattClientCharacteristicConfigurationDescriptorValue.Notify)) 7 { 8 GattCommunicationStatus status = await characteristics.Characteristics.FirstOrDefault().WriteClientCharacteristicConfigurationDescriptorAsync( 9 GattClientCharacteristicConfigurationDescriptorValue.Notify); 10 if (status == GattCommunicationStatus.Success) 11 { 12 characteristics.Characteristics.FirstOrDefault().ValueChanged += OnCharacteristicChanged; 13 } 14 }
WriteClientCharacteristicConfigurationDescriptorAsyncメソッド実行後に、以下のエラーになります。
例外がスローされました: 'System.Exception' (mscorlib.dll の中)
属性を書き込めません。 (HRESULT からの例外:0x80650003)
解決方法わかる方がいましたら、よろしくお願いします。
現在、同じ現象で難儀をしております。
1年以上前の投稿のようですが、解決されてのでしょうか?
現在確認していること
```ここに言語を入力
var status = await attr.characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(GattClientCharacteristicConfigurationDescriptorValue.Notify);
```
上記codeの戻り値が
success
でない場合、
属性を書き込めません。 (HRESULT からの例外:0x80650003)
となります。
しかし、
Custom Characteristics: Read, Notify
のBLEデバイスであれば、 success となり、正常動作です。
Readのみだと、異常動作です。
なので、BLEデバイス側の設定の変更を考えています。
徒労に帰す
でしょうか?
環境
Visual Studio2019 Community
で下記をbuildしました。
[リンク内容](https://github.com/sensboston/BLEConsole)
記憶が曖昧ですが、当時の記録を確認したところ
Androidアプリ側のDescriptor UUIDが、CCCDのUUIDではなかったので
書き込みに失敗していた。
CCCDのUUIDに変更すると書き込めるようになった。
という文言が記載されていました。ペリフェラル側のUUIDに問題があったようです。
お役に立てれば幸いです。
ありがとうございます。
あなたの回答
tips
プレビュー