use of nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetTimeRequest 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;
}
use of nodomain.freeyourgadget.gadgetbridge.service.devices.lefun.requests.SetTimeRequest in project Gadgetbridge by Freeyourgadget.
the class LefunDeviceSupport method onSetTime.
@Override
public void onSetTime() {
try {
TransactionBuilder builder = performInitialized(SetTimeRequest.class.getSimpleName());
SetTimeRequest request = new SetTimeRequest(this, builder);
request.perform();
inProgressRequests.add(request);
performConnected(builder.getTransaction());
} catch (IOException e) {
GB.toast(getContext(), "Failed to set time", Toast.LENGTH_SHORT, GB.ERROR, e);
}
}
Aggregations