AncsNotifier.AncsManager.NotificationSourceCharacteristicOnValueChanged C# (CSharp) Method

NotificationSourceCharacteristicOnValueChanged() private method

private NotificationSourceCharacteristicOnValueChanged ( GattCharacteristic sender, GattValueChangedEventArgs args ) : void
sender GattCharacteristic
args GattValueChangedEventArgs
return void
        private async void NotificationSourceCharacteristicOnValueChanged(GattCharacteristic sender, GattValueChangedEventArgs args)
        {
            //Received 8 bytes about some kind of notification
            var valueBytes = args.CharacteristicValue.ToArray();
            var dat = ByteArrayToNotificationSourceData(valueBytes);


            if (dat.EventFlags.HasFlag(EventFlags.EventFlagPreExisting))
            {
                //We dont care about old notifications
                return;
            }


            FlagCache[dat.NotificationUID] = dat.EventFlags;

            //Ask for more data through the control point characteristic
            var attributes = new GetNotificationAttributesData
            {
                CommandId = 0x0,
                NotificationUID = dat.NotificationUID,
                AttributeId1 = (byte) NotificationAttribute.Title,
                AttributeId1MaxLen = 16,
                AttributeId2 = (byte) NotificationAttribute.Message,
                AttributeId2MaxLen = 32
            };

            var bytes = StructureToByteArray(attributes);

            try
            {
                var status =
                    await
                        this.ControlPointCharacteristic.WriteValueAsync(bytes.AsBuffer(),
                            GattWriteOption.WriteWithResponse);
            }
            catch (Exception)
            {
                
            }
        }