/// <summary> /// Listen for NOTIFY events on this characteristic. /// </summary> public static IDisposable NotifyCharacteristicValue(this IBleGattServer server, Guid service, Guid characteristic, Action <Tuple <Guid, Byte[]> > onNotify, Action <Exception> onError = null) { Contract.Requires <ArgumentNullException>(server != null); // ReSharper disable once PossibleNullReferenceException return(server.NotifyCharacteristicValue(service, characteristic, Observer.Create(onNotify, null, onError))); }
/// <summary> /// Listen for NOTIFY events on this characteristic. /// </summary> public static IDisposable NotifyCharacteristicValue(this IBleGattServer server, Guid service, Guid characteristic, Action <Byte[]> onNotify, Action <Exception> onError = null) { return(server.NotifyCharacteristicValue( service, characteristic, Observer.Create((Tuple <Guid, Byte[]> tuple) => onNotify(tuple.Item2), null, onError))); }
private void EnableNotifications() { if (m_notificationSubscription == null) { try { m_notificationSubscription = m_gattServer.NotifyCharacteristicValue( m_serviceGuid, m_characteristicGuid, UpdateDisplayedValue); } catch (GattException ex) { m_dialogManager.Toast(ex.Message); } } RaisePropertyChanged(nameof(NotifyEnabled)); }
private void EnableNotifications() { if (m_unsubscribe == null) { Log.Trace("EnableNotifications"); try { m_unsubscribe = m_device.NotifyCharacteristicValue( m_service, m_characteristic, Observer.Create <Tuple <Guid, Byte[]> >(res => Update(res.Item1, res.Item2))); } catch (GattException ex) { m_dialogs.Toast(ex.Message); } } RaisePropertyChanged(nameof(NotifyEnabled)); }