-
I have the following code: // Make sure the characteristic supports Notify
notifyCharacteristic.AssertNotify();
// Make sure the device is connected
System.Diagnostics.Debug.Assert(peripheral.IsConnected());
// Notify - is this all I have to do?
notifyCharacteristicResult = peripheral.NotifyCharacteristic(notifyCharacteristic);
int timesWaited = 0;
while(notifyCharacteristic.IsNotifying == false)
{
// Check every second for the notify to be set to true...
await Task.Delay(1_000);
Console.WriteLine($"Waiting for notify to be true {timesWaited} seconds");
timesWaited++;
notifyCharacteristic = await peripheral
.GetCharacteristicAsync(notifyCharacteristic.Service.Uuid, notifyCharacteristic.Uuid);
} This produces the following output:
My expectation is that the code above would either result in
as shown here: https://github.com/orgs/shinyorg/discussions/1277 Can anyone help me understand what I might be doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For future readers, I believe the reason this wasn't working is because I wasn't subscribing to the NotifyCharacterstic response. The code should be: peripheral.NotifyCharacteristic(notifyCharacteristic).Subscribe(HandleNotificationSubscription);
...
private void HandleNotificationSubscription(BleCharacteristicResult result)
{
int m = 3;
} Unfortunately I struggled with this longer than probably would have been necessary but the docs are incomplete here: But the following line provides clues:
|
Beta Was this translation helpful? Give feedback.
For future readers, I believe the reason this wasn't working is because I wasn't subscribing to the NotifyCharacterstic response. The code should be:
Unfortunately I struggled with this longer than probably would have been necessary but the docs are incomplete here:
https://shinylib.net/client/ble/gatt/
But the following line provides clues: