我正在开发一个应用程序,我必须连接到Android 4.3上的蓝牙设备。如何在连接到BLE设备后获取电池电量?
我想通过使用Battery_Service和Battery_Level来获得电池电量。
public class BluetoothLeService extends Service {
private static final UUID Battery_Service_UUID = UUID.fromString("0000180F-0000-1000-8000-00805f9b34fb");
private static final UUID Battery_Level_UUID = UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb");
public void getbattery() {
BluetoothGattService batteryService = mBluetoothGatt.getService(Battery_Service_UUID);
if(batteryService == null) {
Log.d(TAG, "Battery service not found!");
return;
}
BluetoothGattCharacteristic batteryLevel = batteryService.getCharacteristic(Battery_Level_UUID);
if(batteryLevel == null) {
Log.d(TAG, "Battery level not found!");
return;
}
mBluetoothGatt.readCharacteristic(batteryLevel);
// What should I do that I can get the battery level ??
Log.d(TAG, "Battery level " + mBluetoothGatt.readCharacteristic(batteryLevel););
}
但mBluetoothGatt.readCharacteristic(batteryLevel);
值是不是电池的电平值
如何读取电池????
你会得到什么样的价值? –
mBluetoothGatt.readCharacteristic(batteryLevel)的值;是“真的” – Wun
对不起,我不认为我可以帮助...也许这会:http://heveloper.samsung.com/forum/board/thread/view.do?boardName=SDK&messageId=240110 –