예제 #1
0
 public RXGattClientCharacteristic(RXGattClient rxGattClient, Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic win10Characteristic)
 {
     RXGattClient                      = rxGattClient;
     Win10Characteristic               = win10Characteristic;
     GattCharacteristicConfiguration   = new RXClientCharacteristicConfiguration(this);
     Win10Characteristic.ValueChanged += Win10Characteristic_ValueChanged;
     //Win10Characteristic.GetDescriptorsForUuidAsync()
 }
예제 #2
0
        private void Win10Characteristic_ValueChanged(Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic sender, Windows.Devices.Bluetooth.GenericAttributeProfile.GattValueChangedEventArgs args)
        {
            var reader = DataReader.FromBuffer(args.CharacteristicValue);

            byte[] valueBytes = new byte[reader.UnconsumedBufferLength];
            reader.ReadBytes(valueBytes);
            OnNotified?.Invoke(this, valueBytes);
        }
예제 #3
0
        //Play Animation Finished 0x76
        //Miposour Status	0x79

        internal override void CharacteristicsNotify_ValueChanged(Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic sender, Windows.Devices.Bluetooth.GenericAttributeProfile.GattValueChangedEventArgs args)
        {
            var data      = args.CharacteristicValue.ToArray();
            var hexstring = UTF8Encoding.UTF8.GetString(data, 0, data.Count());
            var bytes     = StringToByteArray(hexstring);

            switch (bytes[0])
            {
            case 0x76:     //GetCurrentMIPGameMode
                OnAnimationFinishedRecieved(bytes[1]);
                break;
            }
        }
예제 #4
0
        // Set the alert-level characteristic on the remote device
        public async Task SetAlertLevelCharacteristic()
        {
            // try-catch block protects us from the race where the device disconnects
            // just after we've determined that it is connected.
            try
            {
                byte[] data = new byte[1];
                data[0] = (byte)alertLevel;

                // The LinkLoss service should contain exactly one instance of the AlertLevel characteristic
                GattCharacteristic characteristic = linkLossService.GetCharacteristics(GattCharacteristicUuids.AlertLevel)[0];

                await characteristic.WriteValueAsync(data.AsBuffer(), GattWriteOption.WriteWithResponse);
            }
            catch (Exception)
            {
                // ignore exception
            }
        }
예제 #5
0
 private GattCharacteristic(Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic characteristic)
 {
     _characteristic = characteristic;
 }
예제 #6
0
 private void _characteristic_ValueChanged(Windows.Devices.Bluetooth.GenericAttributeProfile.GattCharacteristic sender, Windows.Devices.Bluetooth.GenericAttributeProfile.GattValueChangedEventArgs args)
 {
     valueChanged?.Invoke(this, args);
 }