Blazm.Bluetooth
Blazm.Bluetooth copied to clipboard
Missing CancelNotifyAsync()
There is a SetupNotifyAsync() call but no matching CancelNotifyAsync() - the best workaround I can figure is to ignore the characteristic within the notify handler even long after that characteristic is no longer relevant.
I'm new to C#+javascript and bluetooth but a quick search leads me to believe the javascript could look like:
export async function cancelNotify(deviceId, serviceId, characteristicId)
{
var device = getDevice(deviceId);
var service = await device.gatt.getPrimaryService(serviceId);
var characteristic = await service.getCharacteristic(characteristicId);
characteristic.removeEventListener('characteristicvaluechanged', handleCharacteristicValueChanged);
await characteristic.stopNotifications();
}
and the C# could be (in the BluetootNavigator class):
public async Task TeardownNotifyAsync(Device device, string serviceId, string characteristicId)
{
var module = await moduleTask.Value;
await module.InvokeVoidAsync("cancelNotify", device.Id, serviceId.ToLowerInvariant(), characteristicId.ToLowerInvariant());
}
but I really don't know how the List<DotNetObjectReference<Device>> NotificationHandlers in the setup notifications code fits in so am leery of trying this...
I have totally missed this, kinda embarrassing =) I'll take a look and try to implement that. Thanks for the code!