use of org.thingsboard.server.transport.lwm2m.server.ota.firmware.FirmwareUpdateState in project thingsboard by thingsboard.
the class DefaultLwM2MOtaUpdateService method onCurrentFirmwareStateUpdate.
@Override
public void onCurrentFirmwareStateUpdate(LwM2mClient client, Long stateCode) {
log.debug("[{}] Current fw state: {}", client.getEndpoint(), stateCode);
LwM2MClientFwOtaInfo fwInfo = getOrInitFwInfo(client);
FirmwareUpdateState state = FirmwareUpdateState.fromStateFwByCode(stateCode.intValue());
if (FirmwareUpdateState.DOWNLOADED.equals(state)) {
executeFwUpdate(client);
}
fwInfo.setUpdateState(state);
Optional<OtaPackageUpdateStatus> status = toOtaPackageUpdateStatus(state);
if (FirmwareUpdateState.IDLE.equals(state) && DOWNLOADING.equals(fwInfo.getStatus())) {
fwInfo.setFailedPackageId(fwInfo.getTargetPackageId());
status = Optional.of(FAILED);
}
status.ifPresent(otaStatus -> {
fwInfo.setStatus(otaStatus);
sendStateUpdateToTelemetry(client, fwInfo, otaStatus, "Firmware Update State: " + state.name());
});
update(fwInfo);
}
Aggregations