Search in sources :

Example 1 with SoftwareUpdateState

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);
}
Also used : LwM2MClientSwOtaInfo(org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo) OtaPackageUpdateStatus(org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus) SoftwareUpdateState(org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateState)

Aggregations

OtaPackageUpdateStatus (org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus)1 LwM2MClientSwOtaInfo (org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo)1 SoftwareUpdateState (org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateState)1