Search in sources :

Example 1 with SoftwareUpdateResult

use of org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateResult in project thingsboard by thingsboard.

the class DefaultLwM2MOtaUpdateService method onCurrentSoftwareResultUpdate.

@Override
public void onCurrentSoftwareResultUpdate(LwM2mClient client, Long code) {
    log.debug("[{}] Current sw result: {}", client.getEndpoint(), code);
    LwM2MClientSwOtaInfo swInfo = getOrInitSwInfo(client);
    SoftwareUpdateResult result = SoftwareUpdateResult.fromUpdateResultSwByCode(code.intValue());
    Optional<OtaPackageUpdateStatus> status = toOtaPackageUpdateStatus(result);
    status.ifPresent(otaStatus -> sendStateUpdateToTelemetry(client, swInfo, otaStatus, "Software Update Result: " + result.name()));
    if (result.isAgain() && swInfo.getRetryAttempts() <= 2) {
        swInfo.setRetryAttempts(swInfo.getRetryAttempts() + 1);
        startSoftwareUpdateIfNeeded(client, swInfo);
    } else {
        swInfo.update(result);
    }
    update(swInfo);
}
Also used : LwM2MClientSwOtaInfo(org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo) OtaPackageUpdateStatus(org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus) SoftwareUpdateResult(org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateResult)

Aggregations

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