use of nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.GetBatteryLevelRequest in project Gadgetbridge by Freeyourgadget.
the class LefunDeviceSupport method initializeDevice.
@Override
protected TransactionBuilder initializeDevice(TransactionBuilder builder) {
builder.setGattCallback(this);
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
// Enable notification
builder.notify(getCharacteristic(LefunConstants.UUID_CHARACTERISTIC_LEFUN_NOTIFY), true);
// Init device (get version info, battery level, and set time)
try {
GetFirmwareInfoRequest firmwareReq = new GetFirmwareInfoRequest(this, builder);
firmwareReq.perform();
inProgressRequests.add(firmwareReq);
SetTimeRequest timeReq = new SetTimeRequest(this, builder);
timeReq.perform();
inProgressRequests.add(timeReq);
GetBatteryLevelRequest batReq = new GetBatteryLevelRequest(this, builder);
batReq.perform();
inProgressRequests.add(batReq);
sendAmPmSettingIfNecessary(builder);
sendUnitsSetting(builder);
sendUserProfile(builder);
} catch (IOException e) {
GB.toast(getContext(), "Failed to initialize Lefun device", Toast.LENGTH_SHORT, GB.ERROR, e);
}
return builder;
}
Aggregations