很好的一天!可以 t get battery percentage in percent. I
我们成功地连接到关贸总协定服务,并做到了:
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)。设备总是发送这个号码,我试图充电设备,等待低水平的电池,但总是得到这个。谢谢你的帮助。
暂无答案!
目前还没有任何答案,快来回答吧!