I am trying to develop a WPF app on windows 10 to communicate to a BLE device. I am using advertisement watcher class to scan for new devices. I am expected to authenticate (proprietary) to the device before reading the data. Reading the data happens by subscribing to the client characteristic configuration descriptor of a particular characteristic.
The first time I find a device (which is of course Un bonded / Un paired) authentication works
The 2 way authentication happens by exchanging data over cccd of a particular characteristic which always works.
GattCommunicationStatus status = await **authenticationCharacteristic**.WriteClientCharacteristicConfigurationDescriptorAsync(
GattClientCharacteristicConfigurationDescriptorValue.Notify);
if(status == GattCommunicationStatus.Success)
{
//always success
}
The second step is to perform bonding using
DevicePairingResult result = await customPairing.PairAsync(ceremoniesSelected, protectionLevel);
Which succeeds. After bonding is successful, the next step is to subscribe to cccd to receive data.
GattCommunicationStatus status = await **dataCharacteristic**.WriteClientCharacteristicConfigurationDescriptorAsync(
GattClientCharacteristicConfigurationDescriptorValue.Notify);
if(status == GattCommunicationStatus.Success)
{
}
This always throws an exception
**Exception:Thrown: "The attribute cannot be written. (Exception from HRESULT: 0x80650003)" **
But in the subsequent connections when the devices are already bonded I am able to write to the client characteristic configuration descriptor and be notified about the data.
The issue is only when a new device is found and it is non bonded, writing to the data cccd always fails.
Is there a known issue?
Thanks in advance for the help.
User contributions licensed under CC BY-SA 3.0