Browse Source

lwm2m: fix bug progileID is null after reboot if sleep

pull/14403/head
nickAS21 10 months ago
parent
commit
4ece91a0fd
  1. 2
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java
  2. 58
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/ota/DefaultLwM2MOtaUpdateService.java

2
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java

@ -360,7 +360,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
@Override @Override
public Lwm2mDeviceProfileTransportConfiguration getProfile(Registration registration) { public Lwm2mDeviceProfileTransportConfiguration getProfile(Registration registration) {
UUID profileId = getClientByEndpoint(registration.getEndpoint()).getProfileId(); UUID profileId = getClientByEndpoint(registration.getEndpoint()).getProfileId();
return doGetAndCache(profileId); return profileId != null ? doGetAndCache(profileId) : null;
} }
private Lwm2mDeviceProfileTransportConfiguration doGetAndCache(UUID profileId) { private Lwm2mDeviceProfileTransportConfiguration doGetAndCache(UUID profileId) {

58
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/ota/DefaultLwM2MOtaUpdateService.java

@ -201,35 +201,39 @@ public class DefaultLwM2MOtaUpdateService extends LwM2MExecutorAwareService impl
} }
var clientSettings = clientContext.getProfile(client.getRegistration()).getClientLwM2mSettings(); var clientSettings = clientContext.getProfile(client.getRegistration()).getClientLwM2mSettings();
initFwStrategy(client, clientSettings); if (clientSettings != null) {
initSwStrategy(client, clientSettings); initFwStrategy(client, clientSettings);
initSwStrategy(client, clientSettings);
if (!attributesToFetch.isEmpty()) {
var future = attributesService.getSharedAttributes(client, attributesToFetch);
DonAsynchron.withCallback(future, attrs -> { if (!attributesToFetch.isEmpty()) {
if (fwInfo.isSupported()) { var future = attributesService.getSharedAttributes(client, attributesToFetch);
Optional<String> newFwTitle = getAttributeValue(attrs, FIRMWARE_TITLE); DonAsynchron.withCallback(future, attrs -> {
Optional<String> newFwVersion = getAttributeValue(attrs, FIRMWARE_VERSION); if (fwInfo.isSupported()) {
Optional<String> newFwTag = getAttributeValue(attrs, FIRMWARE_TAG); Optional<String> newFwTitle = getAttributeValue(attrs, FIRMWARE_TITLE);
Optional<String> newFwUrl = getAttributeValue(attrs, FIRMWARE_URL); Optional<String> newFwVersion = getAttributeValue(attrs, FIRMWARE_VERSION);
if (newFwTitle.isPresent() && newFwVersion.isPresent() && !isOtaDownloading(client) && !UPDATING.equals(fwInfo.status)) { Optional<String> newFwTag = getAttributeValue(attrs, FIRMWARE_TAG);
onTargetFirmwareUpdate(client, newFwTitle.get(), newFwVersion.get(), newFwUrl, newFwTag); Optional<String> newFwUrl = getAttributeValue(attrs, FIRMWARE_URL);
if (newFwTitle.isPresent() && newFwVersion.isPresent() && !isOtaDownloading(client) && !UPDATING.equals(fwInfo.status)) {
onTargetFirmwareUpdate(client, newFwTitle.get(), newFwVersion.get(), newFwUrl, newFwTag);
}
} }
} if (swInfo.isSupported()) {
if (swInfo.isSupported()) { Optional<String> newSwTitle = getAttributeValue(attrs, SOFTWARE_TITLE);
Optional<String> newSwTitle = getAttributeValue(attrs, SOFTWARE_TITLE); Optional<String> newSwVersion = getAttributeValue(attrs, SOFTWARE_VERSION);
Optional<String> newSwVersion = getAttributeValue(attrs, SOFTWARE_VERSION); Optional<String> newSwTag = getAttributeValue(attrs, SOFTWARE_TAG);
Optional<String> newSwTag = getAttributeValue(attrs, SOFTWARE_TAG); Optional<String> newSwUrl = getAttributeValue(attrs, SOFTWARE_URL);
Optional<String> newSwUrl = getAttributeValue(attrs, SOFTWARE_URL); if (newSwTitle.isPresent() && newSwVersion.isPresent()) {
if (newSwTitle.isPresent() && newSwVersion.isPresent()) { onTargetSoftwareUpdate(client, newSwTitle.get(), newSwVersion.get(), newSwUrl, newSwTag);
onTargetSoftwareUpdate(client, newSwTitle.get(), newSwVersion.get(), newSwUrl, newSwTag); }
} }
}
}, throwable -> { }, throwable -> {
if (fwInfo.isSupported()) { if (fwInfo.isSupported()) {
update(fwInfo); update(fwInfo);
} }
}, executor); }, executor);
}
} }
} }

Loading…
Cancel
Save