读取BLE中的特征

时间:2018-11-15 13:20:35

标签: android bluetooth

我有一种使用Bluetooth Gatt读取特定特征的方法。

public void ReadNotificationCommand(BluetoothGatt gatt)
        {
            try
            {
                var a = UUID.FromString("503C2500-802E-11E8-AF7D-0800200C9A66");
                var b = UUID.FromString("503C2503-802E-11E8-AF7D-0800200C9A66");

                var x = gatt.GetService(a).GetCharacteristic(b);

                gatt.ReadCharacteristic(x);
            }
            catch (Exception ex)
            {

            }
        }

如何在以下覆盖方法中触发此方法ReadNotificationCommand

  public override void OnCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, [GeneratedEnum] GattStatus status)
        {

            base.OnCharacteristicRead(gatt, characteristic, status);
        }

方法ReadNotificationCommand向我返回一个值。我想在我的视图中访问此值。请帮忙。

0 个答案:

没有答案
相关问题