private async void AncsManagerOnOnNotification(PlainNotification o) { await this.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () => { this.DataList.Add(o); }); Show(new ToastContent() { Visual = new ToastVisual() { TitleText = new ToastText() { Text = o.Title }, BodyTextLine1 = new ToastText() { Text = o.Message } }, Scenario = ToastScenario.Default, Actions = new ToastActionsCustom() { Buttons = { new ToastButtonDismiss("Ok") } } }); }
public async void OnAction(PlainNotification notification, bool positive) { //Relay notification action back to device var not = new NotificationActionData { CommandId = 0x02, //CommandIDPerformNotificationAction NotificationUID = notification.Uid, ActionId = positive ? ActionId.Positive : ActionId.Negative }; var bytes = StructureToByteArray(not); try { var status = await this.ControlPointCharacteristic.WriteValueAsync(bytes.AsBuffer(), GattWriteOption.WriteWithResponse); } catch (Exception) { } }
private async void DataSourceCharacteristicOnValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args) { var stream = args.CharacteristicValue.AsStream(); var br = new BinaryReader(stream); var cmdId = br.ReadByte(); var notUid = br.ReadUInt32(); var attr1 = (NotificationAttribute)br.ReadByte(); var attr1len = br.ReadUInt16(); var attr1val = br.ReadChars(attr1len); var attr2 = (NotificationAttribute) br.ReadByte(); var attr2len = br.ReadUInt16(); var attr2val = br.ReadChars(attr2len); EventFlags? flags = null; if(FlagCache.ContainsKey(notUid)) { flags = FlagCache[notUid]; } var not = new PlainNotification() { EventFlags = flags, Uid = notUid, Title = new string(attr1val), Message = new string(attr2val) }; OnNotification?.Invoke(not); }