-
- All Implemented Interfaces:
-
android.os.Parcelable,no.nordicsemi.android.ble.callback.DataReceivedCallback,no.nordicsemi.android.ble.callback.profile.ProfileDataCallback,no.nordicsemi.android.ble.common.profile.battery.BatteryLevelCallback
public final class BatteryLevelResponse extends BatteryLevelDataCallback implements Parcelable
Response class that could be used as a result of a synchronous request. The data received are available through getters, instead of a callback.
Usage example:
try { BatteryLevelResponse response = readCharacteristic(characteristic) .awaitValid(BatteryLevelResponse.class); int batteryLevel = response.getBatteryLevel(); ... } catch (RequestFailedException e) { Log.w(TAG, "Request failed with status " + e.getStatus(), e); } catch (InvalidDataException e) { Log.w(TAG, "Invalid data received: " + e.getResponse().getRawData()); }
-
-
Field Summary
Fields Modifier and Type Field Description public final static Parcelable.Creator<BatteryLevelResponse>CREATOR
-
Constructor Summary
Constructors Constructor Description BatteryLevelResponse()
-
Method Summary
Modifier and Type Method Description voidonBatteryLevelChanged(@NonNull() BluetoothDevice device, int batteryLevel)Callback received each time the Battery Level value was read or has changed usinga notification. intgetBatteryLevel()Returns the battery level value received. voidwriteToParcel(@NonNull() Parcel dest, int flags)-
Methods inherited from class no.nordicsemi.android.ble.common.callback.battery.BatteryLevelDataCallback
onDataReceived -
Methods inherited from class no.nordicsemi.android.ble.callback.profile.ProfileReadResponse
isValid, onInvalidDataReceived, writeToParcel -
Methods inherited from class no.nordicsemi.android.ble.response.ReadResponse
describeContents, getBluetoothDevice, getRawData, onDataReceived -
Methods inherited from class no.nordicsemi.android.ble.common.profile.battery.BatteryLevelCallback
onBatteryLevelChanged -
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
onBatteryLevelChanged
void onBatteryLevelChanged(@NonNull() BluetoothDevice device, int batteryLevel)
Callback received each time the Battery Level value was read or has changed usinga notification.
- Parameters:
device- the target device.batteryLevel- the battery value in percent.
-
getBatteryLevel
int getBatteryLevel()
Returns the battery level value received.
-
writeToParcel
void writeToParcel(@NonNull() Parcel dest, int flags)
-
-
-
-