Tôi đang phát triển một ứng dụng mà tôi phải kết nối với thiết bị Bluetooth trên Android 4.3.Cách lấy mức pin sau khi kết nối với thiết bị BLE?
Và tôi muốn lấy mức pin bằng cách sử dụng Battery_Service và Pin_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););
}
Nhưng giá trị của mBluetoothGatt.readCharacteristic(batteryLevel);
không phải là giá trị mức pin
Làm thế nào để đọc pin ????
bạn nhận được giá trị nào? –
giá trị của mBluetoothGatt.readCharacteristic (pinLevel); là "true" – Wun
xin lỗi, tôi không nghĩ rằng tôi có thể giúp ... có thể điều này sẽ: http://developer.samsung.com/forum/board/thread/view.do?boardName=SDK&messageId=240110 –