use of org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateState in project thingsboard by thingsboard.
the class DefaultLwM2MOtaUpdateService method onCurrentSoftwareStateUpdate.
@Override
public void onCurrentSoftwareStateUpdate(LwM2mClient client, Long stateCode) {
log.debug("[{}] Current sw state: {}", client.getEndpoint(), stateCode);
LwM2MClientSwOtaInfo swInfo = getOrInitSwInfo(client);
SoftwareUpdateState state = SoftwareUpdateState.fromUpdateStateSwByCode(stateCode.intValue());
if (SoftwareUpdateState.INITIAL.equals(state)) {
startSoftwareUpdateIfNeeded(client, swInfo);
} else if (SoftwareUpdateState.DELIVERED.equals(state)) {
executeSwInstall(client);
}
swInfo.setUpdateState(state);
Optional<OtaPackageUpdateStatus> status = toOtaPackageUpdateStatus(state);
status.ifPresent(otaStatus -> sendStateUpdateToTelemetry(client, swInfo, otaStatus, "Firmware Update State: " + state.name()));
update(swInfo);
}
Aggregations