我正在開發一個應用程序,我必須連接到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 –