Esempio n. 1
0
        private void OnAttributeValue(object sender, AttributeValueEventArgs e)
        {
            var notifyOrIndicate = e.Type == AttributeValueType.Notify || e.Type == AttributeValueType.Indicate;

            if (!notifyOrIndicate ||
                !_peripherals.TryGetValue(e.Connection, out var peripheral) ||
                !peripheral.Services.TryGetValue(e.AttHandle, out var service) ||
                !peripheral.Characteristics.TryGetValue(e.AttHandle, out var characteristic))
            {
                return;
            }
            var eventArgs = new GattCharacteristicValueEventArgs(peripheral, service, characteristic, e.Value);

            CharacteristicValueChanged?.Invoke(this, eventArgs);
        }
 public override void OnCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic)
 {
     CharacteristicValueChanged?.Invoke(gatt, characteristic);
 }