Search in sources :

Example 1 with LwM2MClientSwOtaInfo

use of org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo 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)

Example 2 with LwM2MClientSwOtaInfo

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

the class DefaultLwM2MOtaUpdateService method onTargetSoftwareUpdate.

@Override
public void onTargetSoftwareUpdate(LwM2mClient client, String newSoftwareTitle, String newSoftwareVersion, Optional<String> newSoftwareUrl, Optional<String> newSoftwareTag) {
    LwM2MClientSwOtaInfo fwInfo = getOrInitSwInfo(client);
    fwInfo.updateTarget(newSoftwareTitle, newSoftwareVersion, newSoftwareUrl, newSoftwareTag);
    update(fwInfo);
    startSoftwareUpdateIfNeeded(client, fwInfo);
}
Also used : LwM2MClientSwOtaInfo(org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo)

Example 3 with LwM2MClientSwOtaInfo

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

the class DefaultLwM2MOtaUpdateService method isOtaDownloading.

@Override
public boolean isOtaDownloading(LwM2mClient client) {
    String endpoint = client.getEndpoint();
    LwM2MClientFwOtaInfo fwInfo = fwStates.get(endpoint);
    LwM2MClientSwOtaInfo swInfo = swStates.get(endpoint);
    if (fwInfo != null && (DOWNLOADING.equals(fwInfo.getStatus()))) {
        return true;
    }
    if (swInfo != null && (DOWNLOADING.equals(swInfo.getStatus()))) {
        return true;
    }
    return false;
}
Also used : LwM2MClientSwOtaInfo(org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo) LwM2MClientFwOtaInfo(org.thingsboard.server.transport.lwm2m.server.ota.firmware.LwM2MClientFwOtaInfo)

Example 4 with LwM2MClientSwOtaInfo

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

the class DefaultLwM2MOtaUpdateService method initSwStrategy.

private LwM2MClientSwOtaInfo initSwStrategy(LwM2mClient client, OtherConfiguration configuration) {
    LwM2MClientSwOtaInfo swInfo = getOrInitSwInfo(client);
    swInfo.setStrategy(LwM2MSoftwareUpdateStrategy.fromStrategySwByCode(configuration.getSwUpdateStrategy()));
    swInfo.setBaseUrl(configuration.getSwUpdateResource());
    return swInfo;
}
Also used : LwM2MClientSwOtaInfo(org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo)

Example 5 with LwM2MClientSwOtaInfo

use of org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo 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

LwM2MClientSwOtaInfo (org.thingsboard.server.transport.lwm2m.server.ota.software.LwM2MClientSwOtaInfo)7 OtaPackageUpdateStatus (org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus)2 LwM2MClientFwOtaInfo (org.thingsboard.server.transport.lwm2m.server.ota.firmware.LwM2MClientFwOtaInfo)2 ArrayList (java.util.ArrayList)1 SoftwareUpdateResult (org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateResult)1 SoftwareUpdateState (org.thingsboard.server.transport.lwm2m.server.ota.software.SoftwareUpdateState)1