Commit 4776e3b6476a2d551dca9b8770aa3d90b8aa9597

Authored by Andrii Shvaika
2 parents 52a9c44a 2aba74a3

Merge with LwM2M branch

... ... @@ -196,8 +196,8 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
196 196 .setSubscribeToRPC(TransportProtos.SubscribeToRPCMsg.newBuilder().build())
197 197 .build();
198 198 transportService.process(msg, null);
199   - this.getInfoFirmwareUpdate(lwM2MClient);
200   - this.getInfoSoftwareUpdate(lwM2MClient);
  199 + this.getInfoFirmwareUpdate(lwM2MClient, null);
  200 + this.getInfoSoftwareUpdate(lwM2MClient, null);
201 201 this.initLwM2mFromClientValue(registration, lwM2MClient);
202 202 this.sendLogsToThingsboard(LOG_LW2M_INFO + ": Client create after Registration", registration.getId());
203 203 } else {
... ... @@ -285,7 +285,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
285 285 @Override
286 286 public void setCancelObservationsAll(Registration registration) {
287 287 if (registration != null) {
288   - lwM2mTransportRequest.sendAllRequest(registration, null, OBSERVE_CANCEL_ALL,
  288 + this.lwM2mTransportRequest.sendAllRequest(registration, null, OBSERVE_CANCEL_ALL,
289 289 null, null, this.config.getTimeout(), null);
290 290 }
291 291 }
... ... @@ -334,7 +334,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
334 334 READ, pathIdVer, value);
335 335 this.sendLogsToThingsboard(msg, registration.getId());
336 336 rpcRequest.setValueMsg(String.format("%s", value));
337   - this.sentRpcRequest(rpcRequest, response.getCode().getName(), (String) value, LOG_LW2M_VALUE);
  337 + this.sentRpcResponse(rpcRequest, response.getCode().getName(), (String) value, LOG_LW2M_VALUE);
338 338 }
339 339
340 340 /**
... ... @@ -351,7 +351,8 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
351 351 @Override
352 352 public void onAttributeUpdate(AttributeUpdateNotificationMsg msg, TransportProtos.SessionInfoProto sessionInfo) {
353 353 LwM2mClient lwM2MClient = clientContext.getClient(sessionInfo);
354   - if (msg.getSharedUpdatedCount() > 0) {
  354 + if (msg.getSharedUpdatedCount() > 0 && lwM2MClient != null) {
  355 + log.warn ("2) OnAttributeUpdate, SharedUpdatedList() [{}]", msg.getSharedUpdatedList());
355 356 msg.getSharedUpdatedList().forEach(tsKvProto -> {
356 357 String pathName = tsKvProto.getKv().getKey();
357 358 String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName);
... ... @@ -360,12 +361,12 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
360 361 && (!valueNew.equals(lwM2MClient.getFwUpdate().getCurrentVersion())))
361 362 || (OtaPackageUtil.getAttributeKey(OtaPackageType.FIRMWARE, OtaPackageKey.TITLE).equals(pathName)
362 363 && (!valueNew.equals(lwM2MClient.getFwUpdate().getCurrentTitle())))) {
363   - this.getInfoFirmwareUpdate(lwM2MClient);
  364 + this.getInfoFirmwareUpdate(lwM2MClient, null);
364 365 } else if ((OtaPackageUtil.getAttributeKey(OtaPackageType.SOFTWARE, OtaPackageKey.VERSION).equals(pathName)
365 366 && (!valueNew.equals(lwM2MClient.getSwUpdate().getCurrentVersion())))
366 367 || (OtaPackageUtil.getAttributeKey(OtaPackageType.SOFTWARE, OtaPackageKey.TITLE).equals(pathName)
367 368 && (!valueNew.equals(lwM2MClient.getSwUpdate().getCurrentTitle())))) {
368   - this.getInfoSoftwareUpdate(lwM2MClient);
  369 + this.getInfoSoftwareUpdate(lwM2MClient, null);
369 370 }
370 371 if (pathIdVer != null) {
371 372 ResourceModel resourceModel = lwM2MClient.getResourceModel(pathIdVer, this.config
... ... @@ -386,7 +387,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
386 387 }
387 388
388 389 });
389   - } else if (msg.getSharedDeletedCount() > 0) {
  390 + } else if (msg.getSharedDeletedCount() > 0 && lwM2MClient != null) {
390 391 msg.getSharedUpdatedList().forEach(tsKvProto -> {
391 392 String pathName = tsKvProto.getKv().getKey();
392 393 Object valueNew = getValueFromKvProto(tsKvProto.getKv());
... ... @@ -396,6 +397,9 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
396 397 });
397 398 log.info("[{}] delete [{}] onAttributeUpdate", msg.getSharedDeletedList(), sessionInfo);
398 399 }
  400 + else if (lwM2MClient == null) {
  401 + log.error ("OnAttributeUpdate, lwM2MClient is null");
  402 + }
399 403 }
400 404
401 405 /**
... ... @@ -442,6 +446,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
442 446 public void onToDeviceRpcRequest(TransportProtos.ToDeviceRpcRequestMsg toDeviceRpcRequestMsg, SessionInfoProto sessionInfo) {
443 447 // #1
444 448 this.checkRpcRequestTimeout();
  449 + log.warn ("4) toDeviceRpcRequestMsg: [{}], sessionUUID: [{}]", toDeviceRpcRequestMsg, new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB()));
445 450 String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null";
446 451 LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName());
447 452 UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB());
... ... @@ -478,7 +483,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
478 483 rpcSubscriptionsToRemove.forEach(rpcSubscriptions::remove);
479 484 }
480 485
481   - public void sentRpcRequest(Lwm2mClientRpcRequest rpcRequest, String requestCode, String msg, String typeMsg) {
  486 + public void sentRpcResponse(Lwm2mClientRpcRequest rpcRequest, String requestCode, String msg, String typeMsg) {
482 487 rpcRequest.setResponseCode(requestCode);
483 488 if (LOG_LW2M_ERROR.equals(typeMsg)) {
484 489 rpcRequest.setInfoMsg(null);
... ... @@ -501,6 +506,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
501 506
502 507 @Override
503 508 public void onToDeviceRpcResponse(TransportProtos.ToDeviceRpcResponseMsg toDeviceResponse, SessionInfoProto sessionInfo) {
  509 + log.warn ("5) onToDeviceRpcResponse: [{}], sessionUUID: [{}]", toDeviceResponse, new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB()));
504 510 transportService.process(sessionInfo, toDeviceResponse, null);
505 511 }
506 512
... ... @@ -881,10 +887,16 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
881 887 */
882 888 private Object getResourceValueFormatKv(LwM2mClient lwM2MClient, String pathIdVer) {
883 889 LwM2mResource resourceValue = this.getResourceValueFromLwM2MClient(lwM2MClient, pathIdVer);
884   - ResourceModel.Type currentType = resourceValue.getType();
885   - ResourceModel.Type expectedType = this.helper.getResourceModelTypeEqualsKvProtoValueType(currentType, pathIdVer);
886   - return this.converter.convertValue(resourceValue.getValue(), currentType, expectedType,
887   - new LwM2mPath(convertPathFromIdVerToObjectId(pathIdVer)));
  890 + if (resourceValue != null) {
  891 + ResourceModel.Type currentType = resourceValue.getType();
  892 + ResourceModel.Type expectedType = this.helper.getResourceModelTypeEqualsKvProtoValueType(currentType, pathIdVer);
  893 + return this.converter.convertValue(resourceValue.getValue(), currentType, expectedType,
  894 + new LwM2mPath(convertPathFromIdVerToObjectId(pathIdVer)));
  895 + }
  896 +
  897 + else {
  898 + return null;
  899 + }
888 900 }
889 901
890 902 /**
... ... @@ -1245,22 +1257,28 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
1245 1257 */
1246 1258 public void updateAttributeFromThingsboard(List<TransportProtos.TsKvProto> tsKvProtos, TransportProtos.SessionInfoProto sessionInfo) {
1247 1259 LwM2mClient lwM2MClient = clientContext.getClient(sessionInfo);
1248   - tsKvProtos.forEach(tsKvProto -> {
1249   - String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, tsKvProto.getKv().getKey());
1250   - if (pathIdVer != null) {
1251   - // #1.1
1252   - if (lwM2MClient.getDelayedRequests().containsKey(pathIdVer) && tsKvProto.getTs() > lwM2MClient.getDelayedRequests().get(pathIdVer).getTs()) {
1253   - lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
1254   - } else if (!lwM2MClient.getDelayedRequests().containsKey(pathIdVer)) {
1255   - lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
  1260 + if (lwM2MClient != null) {
  1261 + log.warn("1) UpdateAttributeFromThingsboard, tsKvProtos [{}]", tsKvProtos);
  1262 + tsKvProtos.forEach(tsKvProto -> {
  1263 + String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, tsKvProto.getKv().getKey());
  1264 + if (pathIdVer != null) {
  1265 + // #1.1
  1266 + if (lwM2MClient.getDelayedRequests().containsKey(pathIdVer) && tsKvProto.getTs() > lwM2MClient.getDelayedRequests().get(pathIdVer).getTs()) {
  1267 + lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
  1268 + } else if (!lwM2MClient.getDelayedRequests().containsKey(pathIdVer)) {
  1269 + lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
  1270 + }
1256 1271 }
1257   - }
1258   - });
1259   - // #2.1
1260   - lwM2MClient.getDelayedRequests().forEach((pathIdVer, tsKvProto) -> {
1261   - this.updateResourcesValueToClient(lwM2MClient, this.getResourceValueFormatKv(lwM2MClient, pathIdVer),
1262   - getValueFromKvProto(tsKvProto.getKv()), pathIdVer);
1263   - });
  1272 + });
  1273 + // #2.1
  1274 + lwM2MClient.getDelayedRequests().forEach((pathIdVer, tsKvProto) -> {
  1275 + this.updateResourcesValueToClient(lwM2MClient, this.getResourceValueFormatKv(lwM2MClient, pathIdVer),
  1276 + getValueFromKvProto(tsKvProto.getKv()), pathIdVer);
  1277 + });
  1278 + }
  1279 + else {
  1280 + log.error("UpdateAttributeFromThingsboard, lwM2MClient is null");
  1281 + }
1264 1282 }
1265 1283
1266 1284 /**
... ... @@ -1339,20 +1357,28 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
1339 1357 }
1340 1358 }
1341 1359
1342   - public void getInfoFirmwareUpdate(LwM2mClient lwM2MClient) {
  1360 + public void getInfoFirmwareUpdate(LwM2mClient lwM2MClient, Lwm2mClientRpcRequest rpcRequest) {
1343 1361 if (lwM2MClient.getRegistration().getSupportedVersion(FW_ID) != null) {
1344 1362 SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(lwM2MClient);
1345 1363 if (sessionInfo != null) {
1346   - transportService.process(sessionInfo, createOtaPackageRequestMsg(sessionInfo, OtaPackageType.FIRMWARE.name()),
  1364 + DefaultLwM2MTransportMsgHandler handler = this;
  1365 + this.transportService.process(sessionInfo, createOtaPackageRequestMsg(sessionInfo, OtaPackageType.FIRMWARE.name()),
1347 1366 new TransportServiceCallback<>() {
1348 1367 @Override
1349 1368 public void onSuccess(TransportProtos.GetOtaPackageResponseMsg response) {
1350 1369 if (TransportProtos.ResponseStatus.SUCCESS.equals(response.getResponseStatus())
1351 1370 && response.getType().equals(OtaPackageType.FIRMWARE.name())) {
  1371 + log.warn ("7) firmware start with ver: [{}]", response.getVersion());
  1372 + lwM2MClient.getFwUpdate().setRpcRequest(rpcRequest);
1352 1373 lwM2MClient.getFwUpdate().setCurrentVersion(response.getVersion());
1353 1374 lwM2MClient.getFwUpdate().setCurrentTitle(response.getTitle());
1354 1375 lwM2MClient.getFwUpdate().setCurrentId(new OtaPackageId(new UUID(response.getOtaPackageIdMSB(), response.getOtaPackageIdLSB())).getId());
1355   - lwM2MClient.getFwUpdate().sendReadObserveInfo(lwM2mTransportRequest);
  1376 + if (rpcRequest == null) {
  1377 + lwM2MClient.getFwUpdate().sendReadObserveInfo(lwM2mTransportRequest);
  1378 + }
  1379 + else {
  1380 + lwM2MClient.getFwUpdate().writeFwSwWare(handler, lwM2mTransportRequest);
  1381 + }
1356 1382 } else {
1357 1383 log.trace("OtaPackage [{}] [{}]", lwM2MClient.getDeviceName(), response.getResponseStatus().toString());
1358 1384 }
... ... @@ -1367,21 +1393,28 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler
1367 1393 }
1368 1394 }
1369 1395
1370   - public void getInfoSoftwareUpdate(LwM2mClient lwM2MClient) {
  1396 + public void getInfoSoftwareUpdate(LwM2mClient lwM2MClient, Lwm2mClientRpcRequest rpcRequest) {
1371 1397 if (lwM2MClient.getRegistration().getSupportedVersion(SW_ID) != null) {
1372 1398 SessionInfoProto sessionInfo = this.getSessionInfoOrCloseSession(lwM2MClient);
1373 1399 if (sessionInfo != null) {
1374   - DefaultLwM2MTransportMsgHandler serviceImpl = this;
  1400 + DefaultLwM2MTransportMsgHandler handler = this;
1375 1401 transportService.process(sessionInfo, createOtaPackageRequestMsg(sessionInfo, OtaPackageType.SOFTWARE.name()),
1376 1402 new TransportServiceCallback<>() {
1377 1403 @Override
1378 1404 public void onSuccess(TransportProtos.GetOtaPackageResponseMsg response) {
1379 1405 if (TransportProtos.ResponseStatus.SUCCESS.equals(response.getResponseStatus())
1380 1406 && response.getType().equals(OtaPackageType.SOFTWARE.name())) {
  1407 + lwM2MClient.getSwUpdate().setRpcRequest(rpcRequest);
1381 1408 lwM2MClient.getSwUpdate().setCurrentVersion(response.getVersion());
1382 1409 lwM2MClient.getSwUpdate().setCurrentTitle(response.getTitle());
1383 1410 lwM2MClient.getSwUpdate().setCurrentId(new OtaPackageId(new UUID(response.getOtaPackageIdMSB(), response.getOtaPackageIdLSB())).getId());
1384 1411 lwM2MClient.getSwUpdate().sendReadObserveInfo(lwM2mTransportRequest);
  1412 + if (rpcRequest == null) {
  1413 + lwM2MClient.getSwUpdate().sendReadObserveInfo(lwM2mTransportRequest);
  1414 + }
  1415 + else {
  1416 + lwM2MClient.getSwUpdate().writeFwSwWare(handler, lwM2mTransportRequest);
  1417 + }
1385 1418 } else {
1386 1419 log.trace("Software [{}] [{}]", lwM2MClient.getDeviceName(), response.getResponseStatus().toString());
1387 1420 }
... ...
... ... @@ -82,10 +82,8 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.L
82 82 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_VALUE;
83 83 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper;
84 84 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER;
85   -import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER_ALL;
86 85 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE;
87 86 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL;
88   -import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL_ALL;
89 87 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_READ_ALL;
90 88 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_ATTRIBUTES;
91 89 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_REPLACE;
... ... @@ -134,7 +132,7 @@ public class LwM2mTransportRequest {
134 132 ContentFormat contentFormat = contentFormatName != null ? ContentFormat.fromName(contentFormatName.toUpperCase()) : ContentFormat.DEFAULT;
135 133 LwM2mClient lwM2MClient = this.lwM2mClientContext.getOrRegister(registration);
136 134 LwM2mPath resultIds = target != null ? new LwM2mPath(target) : null;
137   - if (!OBSERVE_READ_ALL.name().equals(typeOper.name()) && resultIds != null && registration != null && resultIds.getObjectId() >= 0 && lwM2MClient != null) {
  135 + if (!OBSERVE_CANCEL.name().equals(typeOper.name()) && resultIds != null && registration != null && resultIds.getObjectId() >= 0 && lwM2MClient != null) {
138 136 if (lwM2MClient.isValidObjectVersion(targetIdVer)) {
139 137 timeoutInMs = timeoutInMs > 0 ? timeoutInMs : DEFAULT_TIMEOUT;
140 138 DownlinkRequest request = createRequest(registration, lwM2MClient, typeOper, contentFormat, target,
... ... @@ -153,47 +151,66 @@ public class LwM2mTransportRequest {
153 151 } else if (WRITE_UPDATE.name().equals(typeOper.name())) {
154 152 if (lwm2mClientRpcRequest != null) {
155 153 String errorMsg = String.format("Path %s params is not valid", targetIdVer);
156   - handler.sentRpcRequest(lwm2mClientRpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR);
  154 + handler.sentRpcResponse(lwm2mClientRpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR);
157 155 }
158 156 } else if (WRITE_REPLACE.name().equals(typeOper.name()) || EXECUTE.name().equals(typeOper.name())) {
159 157 if (lwm2mClientRpcRequest != null) {
160 158 String errorMsg = String.format("Path %s object model is absent", targetIdVer);
161   - handler.sentRpcRequest(lwm2mClientRpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR);
  159 + handler.sentRpcResponse(lwm2mClientRpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR);
162 160 }
163 161 } else if (!OBSERVE_CANCEL.name().equals(typeOper.name())) {
164 162 log.error("[{}], [{}] - [{}] error SendRequest", registration.getEndpoint(), typeOper.name(), targetIdVer);
165 163 if (lwm2mClientRpcRequest != null) {
166 164 ResourceModel resourceModel = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider());
167 165 String errorMsg = resourceModel == null ? String.format("Path %s not found in object version", targetIdVer) : "SendRequest - null";
168   - this.handler.sentRpcRequest(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR);
  166 + this.handler.sentRpcResponse(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR);
169 167 }
170 168 }
171 169 } else if (lwm2mClientRpcRequest != null) {
172 170 String errorMsg = String.format("Path %s not found in object version", targetIdVer);
173   - this.handler.sentRpcRequest(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR);
  171 + this.handler.sentRpcResponse(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR);
174 172 }
175   - } else if (OBSERVE_READ_ALL.name().equals(typeOper.name()) || DISCOVER_ALL.name().equals(typeOper.name())) {
176   - Set<String> paths;
177   - if (OBSERVE_READ_ALL.name().equals(typeOper.name())) {
178   - Set<Observation> observations = context.getServer().getObservationService().getObservations(registration);
179   - paths = observations.stream().map(observation -> observation.getPath().toString()).collect(Collectors.toUnmodifiableSet());
180   - } else {
181   - assert registration != null;
182   - Link[] objectLinks = registration.getSortedObjectLinks();
183   - paths = Arrays.stream(objectLinks).map(Link::toString).collect(Collectors.toUnmodifiableSet());
184   - }
185   - String msg = String.format("%s: type operation %s paths - %s", LOG_LW2M_INFO,
186   - typeOper.name(), paths);
187   - this.handler.sendLogsToThingsboard(msg, registration.getId());
188   - if (lwm2mClientRpcRequest != null) {
189   - String valueMsg = String.format("Paths - %s", paths);
190   - this.handler.sentRpcRequest(lwm2mClientRpcRequest, CONTENT.name(), valueMsg, LOG_LW2M_VALUE);
  173 + } else {
  174 + switch (typeOper) {
  175 + case OBSERVE_READ_ALL:
  176 + case DISCOVER_ALL:
  177 + Set<String> paths;
  178 + if (OBSERVE_READ_ALL.name().equals(typeOper.name())) {
  179 + Set<Observation> observations = context.getServer().getObservationService().getObservations(registration);
  180 + paths = observations.stream().map(observation -> observation.getPath().toString()).collect(Collectors.toUnmodifiableSet());
  181 + } else {
  182 + assert registration != null;
  183 + Link[] objectLinks = registration.getSortedObjectLinks();
  184 + paths = Arrays.stream(objectLinks).map(Link::toString).collect(Collectors.toUnmodifiableSet());
  185 + }
  186 + String msg = String.format("%s: type operation %s paths - %s", LOG_LW2M_INFO,
  187 + typeOper.name(), paths);
  188 + this.handler.sendLogsToThingsboard(msg, registration.getId());
  189 + if (lwm2mClientRpcRequest != null) {
  190 + String valueMsg = String.format("Paths - %s", paths);
  191 + this.handler.sentRpcResponse(lwm2mClientRpcRequest, CONTENT.name(), valueMsg, LOG_LW2M_VALUE);
  192 + }
  193 + break;
  194 + case OBSERVE_CANCEL:
  195 + case OBSERVE_CANCEL_ALL:
  196 + int observeCancelCnt = 0;
  197 + String observeCancelMsg = null;
  198 + if (OBSERVE_CANCEL.name().equals(typeOper)) {
  199 + observeCancelCnt = context.getServer().getObservationService().cancelObservations(registration, target);
  200 + observeCancelMsg = String.format("%s: type operation %s paths: %s count: %d", LOG_LW2M_INFO,
  201 + OBSERVE_CANCEL.name(), target, observeCancelCnt);
  202 + } else {
  203 + observeCancelCnt = context.getServer().getObservationService().cancelObservations(registration);
  204 + observeCancelMsg = String.format("%s: type operation %s paths: All count: %d", LOG_LW2M_INFO,
  205 + OBSERVE_CANCEL.name(), observeCancelCnt);
  206 + }
  207 + this.afterObserveCancel(registration, observeCancelCnt, observeCancelMsg, lwm2mClientRpcRequest);
  208 + break;
  209 + // lwm2mClientRpcRequest != null
  210 + case FW_UPDATE:
  211 + this.handler.getInfoFirmwareUpdate(lwM2MClient, lwm2mClientRpcRequest);
  212 + break;
191 213 }
192   - } else if (OBSERVE_CANCEL_ALL.name().equals(typeOper.name())) {
193   - int observeCancelCnt = context.getServer().getObservationService().cancelObservations(registration);
194   - String observeCancelMsgAll = String.format("%s: type operation %s paths: All count: %d", LOG_LW2M_INFO,
195   - OBSERVE_CANCEL.name(), observeCancelCnt);
196   - this.afterObserveCancel(registration, observeCancelCnt, observeCancelMsgAll, lwm2mClientRpcRequest);
197 214 }
198 215 } catch (Exception e) {
199 216 String msg = String.format("%s: type operation %s %s", LOG_LW2M_ERROR,
... ... @@ -201,7 +218,7 @@ public class LwM2mTransportRequest {
201 218 handler.sendLogsToThingsboard(msg, registration.getId());
202 219 if (lwm2mClientRpcRequest != null) {
203 220 String errorMsg = String.format("Path %s type operation %s %s", targetIdVer, typeOper.name(), e.getMessage());
204   - handler.sentRpcRequest(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR);
  221 + handler.sentRpcResponse(lwm2mClientRpcRequest, NOT_FOUND.getName(), errorMsg, LOG_LW2M_ERROR);
205 222 }
206 223 }
207 224 }
... ... @@ -234,17 +251,6 @@ public class LwM2mTransportRequest {
234 251 request = new ObserveRequest(contentFormat, resultIds.getObjectId());
235 252 }
236 253 break;
237   - case OBSERVE_CANCEL:
238   - /*
239   - lwM2MTransportRequest.sendAllRequest(lwServer, registration, path, POST_TYPE_OPER_OBSERVE_CANCEL, null, null, null, null, context.getTimeout());
240   - At server side this will not remove the observation from the observation store, to do it you need to use
241   - {@code ObservationService#cancelObservation()}
242   - */
243   - int observeCancelCnt = context.getServer().getObservationService().cancelObservations(registration, target);
244   - String observeCancelMsg = String.format("%s: type operation %s paths: %s count: %d", LOG_LW2M_INFO,
245   - OBSERVE_CANCEL.name(), target, observeCancelCnt);
246   - this.afterObserveCancel(registration, observeCancelCnt, observeCancelMsg, rpcRequest);
247   - break;
248 254 case EXECUTE:
249 255 ResourceModel resourceModelExecute = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider());
250 256 if (resourceModelExecute != null) {
... ... @@ -343,7 +349,7 @@ public class LwM2mTransportRequest {
343 349 }
344 350 /** Not Found */
345 351 if (rpcRequest != null) {
346   - handler.sentRpcRequest(rpcRequest, response.getCode().getName(), response.getErrorMessage(), LOG_LW2M_ERROR);
  352 + handler.sentRpcResponse(rpcRequest, response.getCode().getName(), response.getErrorMessage(), LOG_LW2M_ERROR);
347 353 }
348 354 /** Not Found
349 355 set setClient_fw_info... = empty
... ... @@ -385,7 +391,7 @@ public class LwM2mTransportRequest {
385 391 handler.sendLogsToThingsboard(msg, registration.getId());
386 392 log.error("[{}] [{}] - [{}] error SendRequest", request.getClass().getName().toString(), request.getPath().toString(), e.toString());
387 393 if (rpcRequest != null) {
388   - handler.sentRpcRequest(rpcRequest, CoAP.CodeClass.ERROR_RESPONSE.name(), e.getMessage(), LOG_LW2M_ERROR);
  394 + handler.sentRpcResponse(rpcRequest, CoAP.CodeClass.ERROR_RESPONSE.name(), e.getMessage(), LOG_LW2M_ERROR);
389 395 }
390 396 });
391 397 }
... ... @@ -431,7 +437,7 @@ public class LwM2mTransportRequest {
431 437 log.error("Path: [{}] type: [{}] value: [{}] errorMsg: [{}]]", patn, type, value, e.toString());
432 438 if (rpcRequest != null) {
433 439 String errorMsg = String.format("NumberFormatException: Resource path - %s type - %s value - %s", patn, type, value);
434   - handler.sentRpcRequest(rpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR);
  440 + handler.sentRpcResponse(rpcRequest, BAD_REQUEST.getName(), errorMsg, LOG_LW2M_ERROR);
435 441 }
436 442 return null;
437 443 }
... ... @@ -462,44 +468,48 @@ public class LwM2mTransportRequest {
462 468 if (response instanceof ReadResponse) {
463 469 handler.onUpdateValueAfterReadResponse(registration, pathIdVer, (ReadResponse) response, rpcRequest);
464 470 } else if (response instanceof DeleteResponse) {
465   - log.warn("[{}] Path [{}] DeleteResponse 5_Send", pathIdVer, response);
  471 + log.warn("11) [{}] Path [{}] DeleteResponse", pathIdVer, response);
  472 + if (rpcRequest != null) {
  473 + rpcRequest.setInfoMsg(null);
  474 + handler.sentRpcResponse(rpcRequest, response.getCode().getName(), null, null);
  475 + }
466 476 } else if (response instanceof DiscoverResponse) {
467   - String discoverValue = Link.serialize(((DiscoverResponse)response).getObjectLinks());
  477 + String discoverValue = Link.serialize(((DiscoverResponse) response).getObjectLinks());
468 478 msgLog = String.format("%s: type operation: %s path: %s value: %s",
469 479 LOG_LW2M_INFO, DISCOVER.name(), request.getPath().toString(), discoverValue);
470 480 handler.sendLogsToThingsboard(msgLog, registration.getId());
471 481 log.warn("DiscoverResponse: [{}]", (DiscoverResponse) response);
472 482 if (rpcRequest != null) {
473   - handler.sentRpcRequest(rpcRequest, response.getCode().getName(), discoverValue, LOG_LW2M_VALUE);
  483 + handler.sentRpcResponse(rpcRequest, response.getCode().getName(), discoverValue, LOG_LW2M_VALUE);
474 484 }
475 485 } else if (response instanceof ExecuteResponse) {
476   - log.warn("[{}] Path [{}] ExecuteResponse 7_Send", pathIdVer, response);
  486 + msgLog = String.format("%s: type operation: %s path: %s",
  487 + LOG_LW2M_INFO, EXECUTE.name(), request.getPath().toString());
  488 + log.warn("9) [{}] ", msgLog);
  489 + handler.sendLogsToThingsboard(msgLog, registration.getId());
  490 + if (rpcRequest != null) {
  491 + msgLog = String.format("Start %s path: %S. Preparation finished: %s", EXECUTE.name(), path, rpcRequest.getInfoMsg());
  492 + rpcRequest.setInfoMsg(msgLog);
  493 + handler.sentRpcResponse(rpcRequest, response.getCode().getName(), path, LOG_LW2M_INFO);
  494 + }
  495 +
477 496 } else if (response instanceof WriteAttributesResponse) {
478 497 msgLog = String.format("%s: type operation: %s path: %s value: %s",
479 498 LOG_LW2M_INFO, WRITE_ATTRIBUTES.name(), request.getPath().toString(), ((WriteAttributesRequest) request).getAttributes().toString());
480 499 handler.sendLogsToThingsboard(msgLog, registration.getId());
481   - log.warn("[{}] Path [{}] WriteAttributesResponse 8_Send", pathIdVer, response);
  500 + log.warn("12) [{}] Path [{}] WriteAttributesResponse", pathIdVer, response);
482 501 if (rpcRequest != null) {
483   - handler.sentRpcRequest(rpcRequest, response.getCode().getName(), response.toString(), LOG_LW2M_VALUE);
  502 + handler.sentRpcResponse(rpcRequest, response.getCode().getName(), response.toString(), LOG_LW2M_VALUE);
484 503 }
485 504 } else if (response instanceof WriteResponse) {
486   - log.warn("[{}] Path [{}] WriteResponse 9_Send", pathIdVer, response);
487   - this.infoWriteResponse(registration, response, request);
  505 + msgLog = String.format("Type operation: Write path: %s", pathIdVer);
  506 + log.warn("10) [{}] response: [{}]", msgLog, response);
  507 + this.infoWriteResponse(registration, response, request, rpcRequest);
488 508 handler.onWriteResponseOk(registration, pathIdVer, (WriteRequest) request);
489 509 }
490   - if (rpcRequest != null) {
491   - if (response instanceof ExecuteResponse
492   - || response instanceof WriteAttributesResponse
493   - || response instanceof DeleteResponse) {
494   - rpcRequest.setInfoMsg(null);
495   - handler.sentRpcRequest(rpcRequest, response.getCode().getName(), null, null);
496   - } else if (response instanceof WriteResponse) {
497   - handler.sentRpcRequest(rpcRequest, response.getCode().getName(), null, LOG_LW2M_INFO);
498   - }
499   - }
500 510 }
501 511
502   - private void infoWriteResponse(Registration registration, LwM2mResponse response, DownlinkRequest request) {
  512 + private void infoWriteResponse(Registration registration, LwM2mResponse response, DownlinkRequest request, Lwm2mClientRpcRequest rpcRequest) {
503 513 try {
504 514 LwM2mNode node = ((WriteRequest) request).getNode();
505 515 String msg = null;
... ... @@ -517,12 +527,12 @@ public class LwM2mTransportRequest {
517 527 if (singleResource.getType() == ResourceModel.Type.STRING) {
518 528 valueLength = ((String) singleResource.getValue()).length();
519 529 value = ((String) singleResource.getValue())
520   - .substring(Math.min(valueLength, config.getLogMaxLength()));
  530 + .substring(Math.min(valueLength, config.getLogMaxLength())).trim();
521 531
522 532 } else {
523 533 valueLength = ((byte[]) singleResource.getValue()).length;
524 534 value = new String(Arrays.copyOf(((byte[]) singleResource.getValue()),
525   - Math.min(valueLength, config.getLogMaxLength())));
  535 + Math.min(valueLength, config.getLogMaxLength()))).trim();
526 536 }
527 537 value = valueLength > config.getLogMaxLength() ? value + "..." : value;
528 538 msg = String.format("%s: Update finished successfully: Lwm2m code - %d Resource path: %s length: %s value: %s",
... ... @@ -538,6 +548,12 @@ public class LwM2mTransportRequest {
538 548 handler.sendLogsToThingsboard(msg, registration.getId());
539 549 if (request.getPath().toString().equals(FW_PACKAGE_ID) || request.getPath().toString().equals(SW_PACKAGE_ID)) {
540 550 this.afterWriteSuccessFwSwUpdate(registration, request);
  551 + if (rpcRequest != null) {
  552 + rpcRequest.setInfoMsg(msg);
  553 + }
  554 + }
  555 + else if (rpcRequest != null) {
  556 + handler.sentRpcResponse(rpcRequest, response.getCode().getName(), msg, LOG_LW2M_INFO);
541 557 }
542 558 }
543 559 } catch (Exception e) {
... ... @@ -558,7 +574,7 @@ public class LwM2mTransportRequest {
558 574 }
559 575 if (request.getPath().toString().equals(SW_PACKAGE_ID) && lwM2MClient.getSwUpdate() != null) {
560 576 lwM2MClient.getSwUpdate().setStateUpdate(DOWNLOADED.name());
561   - lwM2MClient.getSwUpdate().sendLogs(this.handler,WRITE_REPLACE.name(), LOG_LW2M_INFO, null);
  577 + lwM2MClient.getSwUpdate().sendLogs(this.handler, WRITE_REPLACE.name(), LOG_LW2M_INFO, null);
562 578 }
563 579 }
564 580
... ... @@ -592,7 +608,7 @@ public class LwM2mTransportRequest {
592 608 log.warn("[{}]", observeCancelMsg);
593 609 if (rpcRequest != null) {
594 610 rpcRequest.setInfoMsg(String.format("Count: %d", observeCancelCnt));
595   - handler.sentRpcRequest(rpcRequest, CONTENT.name(), null, LOG_LW2M_INFO);
  611 + handler.sentRpcResponse(rpcRequest, CONTENT.name(), null, LOG_LW2M_INFO);
596 612 }
597 613 }
598 614 }
... ...
... ... @@ -53,6 +53,8 @@ import java.io.ByteArrayInputStream;
53 53 import java.io.IOException;
54 54 import java.util.ArrayList;
55 55 import java.util.List;
  56 +import java.util.concurrent.TimeUnit;
  57 +import java.util.concurrent.atomic.AtomicInteger;
56 58
57 59 import static org.thingsboard.server.gen.transport.TransportProtos.KeyValueType.BOOLEAN_V;
58 60
... ... @@ -64,6 +66,13 @@ public class LwM2mTransportServerHelper {
64 66
65 67 private final LwM2mTransportContext context;
66 68 private final LwM2MJsonAdaptor adaptor;
  69 + private final AtomicInteger atomicTs = new AtomicInteger(0);
  70 +
  71 +
  72 + public long getTS() {
  73 + int addTs = atomicTs.getAndIncrement() >= 1000 ? atomicTs.getAndSet(0) : atomicTs.get();
  74 + return TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()) * 1000L + addTs;
  75 + }
67 76
68 77 /**
69 78 * send to Thingsboard Attribute || Telemetry
... ... @@ -96,7 +105,7 @@ public class LwM2mTransportServerHelper {
96 105 public void sendParametersOnThingsboardTelemetry(List<TransportProtos.KeyValueProto> result, SessionInfoProto sessionInfo) {
97 106 PostTelemetryMsg.Builder request = PostTelemetryMsg.newBuilder();
98 107 TransportProtos.TsKvListProto.Builder builder = TransportProtos.TsKvListProto.newBuilder();
99   - builder.setTs(System.currentTimeMillis());
  108 + builder.setTs(this.getTS());
100 109 builder.addAllKv(result);
101 110 request.addTsKvList(builder.build());
102 111 PostTelemetryMsg postTelemetryMsg = request.build();
... ...
... ... @@ -229,11 +229,12 @@ public class LwM2mTransportUtil {
229 229 */
230 230 WRITE_UPDATE(9, "WriteUpdate"),
231 231 WRITE_ATTRIBUTES(10, "WriteAttributes"),
232   - DELETE(11, "Delete");
  232 + DELETE(11, "Delete"),
233 233
234 234 // only for RPC
  235 + FW_UPDATE(12,"FirmwareUpdate");
235 236 // FW_READ_INFO(12, "FirmwareReadInfo"),
236   -// FW_UPDATE(13, "FirmwareUpdate"),
  237 +
237 238 // SW_READ_INFO(15, "SoftwareReadInfo"),
238 239 // SW_UPDATE(16, "SoftwareUpdate"),
239 240 // SW_UNINSTALL(18, "SoftwareUninstall");
... ...
... ... @@ -83,11 +83,17 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
83 83
84 84 @Override
85 85 public LwM2mClient getClient(TransportProtos.SessionInfoProto sessionInfo) {
86   - return lwM2mClientsByEndpoint.values().stream().filter(c ->
  86 + LwM2mClient lwM2mClient = lwM2mClientsByEndpoint.values().stream().filter(c ->
87 87 (new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB()))
88 88 .equals((new UUID(c.getSession().getSessionIdMSB(), c.getSession().getSessionIdLSB())))
89 89
90 90 ).findAny().get();
  91 + if (lwM2mClient == null) {
  92 + log.warn("Device TimeOut? lwM2mClient is null.");
  93 + log.warn("SessionInfo input [{}], lwM2mClientsByEndpoint size: [{}]", sessionInfo, lwM2mClientsByEndpoint.values().size());
  94 + log.error("", new RuntimeException());
  95 + }
  96 + return lwM2mClient;
91 97 }
92 98
93 99 @Override
... ...
... ... @@ -37,6 +37,7 @@ import static org.thingsboard.server.common.data.ota.OtaPackageType.FIRMWARE;
37 37 import static org.thingsboard.server.common.data.ota.OtaPackageType.SOFTWARE;
38 38 import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATING;
39 39 import static org.thingsboard.server.common.data.ota.OtaPackageUtil.getAttributeKey;
  40 +import static org.eclipse.californium.core.coap.CoAP.ResponseCode.CONTENT;
40 41 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_NAME_ID;
41 42 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_PACKAGE_ID;
42 43 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_RESULT_ID;
... ... @@ -103,6 +104,9 @@ public class LwM2mFwSwUpdate {
103 104 @Getter
104 105 @Setter
105 106 private final List<String> pendingInfoRequestsStart;
  107 + @Getter
  108 + @Setter
  109 + private volatile Lwm2mClientRpcRequest rpcRequest;
106 110
107 111 public LwM2mFwSwUpdate(LwM2mClient lwM2MClient, OtaPackageType type) {
108 112 this.lwM2MClient = lwM2MClient;
... ... @@ -153,16 +157,30 @@ public class LwM2mFwSwUpdate {
153 157 * Send FsSw to Lwm2mClient:
154 158 * before operation Write: fw_state = DOWNLOADING
155 159 */
156   - private void writeFwSwWare(DefaultLwM2MTransportMsgHandler handler, LwM2mTransportRequest request) {
157   - this.stateUpdate = OtaPackageUpdateStatus.DOWNLOADING.name();
158   -// this.observeStateUpdate();
159   - this.sendLogs(handler, WRITE_REPLACE.name(), LOG_LW2M_INFO, null);
160   - int chunkSize = 0;
161   - int chunk = 0;
162   - byte[] firmwareChunk = handler.otaPackageDataCache.get(this.currentId.toString(), chunkSize, chunk);
163   - String targetIdVer = convertPathFromObjectIdToIdVer(this.pathPackageId, this.lwM2MClient.getRegistration());
164   - request.sendAllRequest(lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, ContentFormat.OPAQUE.getName(),
165   - firmwareChunk, handler.config.getTimeout(), null);
  160 + public void writeFwSwWare(DefaultLwM2MTransportMsgHandler handler, LwM2mTransportRequest request) {
  161 + if (this.currentId != null) {
  162 + this.stateUpdate = OtaPackageUpdateStatus.DOWNLOADING.name();
  163 + this.sendLogs(handler, WRITE_REPLACE.name(), LOG_LW2M_INFO, null);
  164 + int chunkSize = 0;
  165 + int chunk = 0;
  166 + byte[] firmwareChunk = handler.otaPackageDataCache.get(this.currentId.toString(), chunkSize, chunk);
  167 + String targetIdVer = convertPathFromObjectIdToIdVer(this.pathPackageId, this.lwM2MClient.getRegistration());
  168 + String fwMsg = String.format("%s: Start type operation %s paths: %s", LOG_LW2M_INFO,
  169 + LwM2mTransportUtil.LwM2mTypeOper.FW_UPDATE.name(), FW_PACKAGE_ID);
  170 + handler.sendLogsToThingsboard(fwMsg, lwM2MClient.getRegistration().getId());
  171 + log.warn("8) Start firmware Update. Send save to: [{}] ver: [{}] path: [{}]", this.lwM2MClient.getDeviceName(), this.currentVersion, targetIdVer);
  172 + request.sendAllRequest(this.lwM2MClient.getRegistration(), targetIdVer, WRITE_REPLACE, ContentFormat.OPAQUE.getName(),
  173 + firmwareChunk, handler.config.getTimeout(), this.rpcRequest);
  174 + }
  175 + else {
  176 + String msgError = "FirmWareId is null.";
  177 + log.warn("6) [{}]", msgError);
  178 + if (this.rpcRequest != null) {
  179 + handler.sentRpcResponse(this.rpcRequest, CONTENT.name(), msgError, LOG_LW2M_ERROR);
  180 + }
  181 + log.error (msgError);
  182 + this.sendLogs(handler, WRITE_REPLACE.name(), LOG_LW2M_ERROR, msgError);
  183 + }
166 184 }
167 185
168 186 public void sendLogs(DefaultLwM2MTransportMsgHandler handler, String typeOper, String typeInfo, String msgError) {
... ... @@ -185,7 +203,7 @@ public class LwM2mFwSwUpdate {
185 203 this.setStateUpdate(UPDATING.name());
186 204 this.sendLogs(handler, EXECUTE.name(), LOG_LW2M_INFO, null);
187 205 request.sendAllRequest(this.lwM2MClient.getRegistration(), this.pathInstallId, EXECUTE, ContentFormat.TLV.getName(),
188   - null, 0, null);
  206 + null, 0, this.rpcRequest);
189 207 }
190 208
191 209 /**
... ... @@ -347,7 +365,7 @@ public class LwM2mFwSwUpdate {
347 365 this.pathResultId, this.lwM2MClient.getRegistration()));
348 366 this.pendingInfoRequestsStart.forEach(pathIdVer -> {
349 367 request.sendAllRequest(this.lwM2MClient.getRegistration(), pathIdVer, OBSERVE, ContentFormat.TLV.getName(),
350   - null, 0, null);
  368 + null, 0, this.rpcRequest);
351 369 });
352 370
353 371 }
... ...
... ... @@ -39,6 +39,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.K
39 39 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper;
40 40 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER_ALL;
41 41 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE;
  42 +import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.FW_UPDATE;
42 43 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL;
43 44 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_READ_ALL;
44 45 import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_ATTRIBUTES;
... ... @@ -140,7 +141,8 @@ public class Lwm2mClientRpcRequest {
140 141 if (this.getTargetIdVer() == null
141 142 && !(OBSERVE_READ_ALL == this.getTypeOper()
142 143 || DISCOVER_ALL == this.getTypeOper()
143   - || OBSERVE_CANCEL == this.getTypeOper())) {
  144 + || OBSERVE_CANCEL == this.getTypeOper()
  145 + || FW_UPDATE == this.getTypeOper())) {
144 146 this.setErrorMsg(TARGET_ID_VER_KEY + " and " +
145 147 KEY_NAME_KEY + " is null or bad format");
146 148 }
... ...
... ... @@ -43,6 +43,9 @@ public class LwM2mValueConverterImpl implements LwM2mValueConverter {
43 43 @Override
44 44 public Object convertValue(Object value, Type currentType, Type expectedType, LwM2mPath resourcePath)
45 45 throws CodecException {
  46 + if (value == null) {
  47 + return null;
  48 + }
46 49 if (expectedType == null) {
47 50 /** unknown resource, trusted value */
48 51 return value;
... ...