java蓝牙当前电池百分比
你好!我能成功地连接到GATT服务吗?我做到了:
public override void OnServicesDiscovered(BluetoothGatt Gatt, [GeneratedEnum] GattStatus Status)
{
base.OnServicesDiscovered(Gatt, Status);
if (Status == GattStatus.Success)
{
if(Service.Uuid.Equals(UUID.FromString("0000180f-0000-1000-8000-00805f9b34fb")))
{
BluetoothGattCharacteristic characteristic = Service.GetCharacteristic(UUID.FromString("00002a19-0000-1000-8000-00805f9b34fb"));
if(characteristic!=null)
{
Gatt.ReadCharacteristic(characteristic);
}
}
}
}
else
{
MainActivity.AppendLog("onServicesDiscovered received: " + Status);
}
}
然后,阅读
public override void OnCharacteristicRead(BluetoothGatt Gatt, BluetoothGattCharacteristic Characteristic, [GeneratedEnum] GattStatus Status)
{
base.OnCharacteristicRead(Gatt, Characteristic, Status);
var batteryData = Characteristic.GetValue();
}
我只得到77,这不是电池百分比(0-64)。设备总是发送这个号码,我试着给设备充电并等待低电量的电池,但总是收到这个号码。谢谢你的帮助
共 (0) 个答案