|
@@ -352,7 +352,8 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -352,7 +352,8 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
352
|
@Override
|
352
|
@Override
|
353
|
public void onAttributeUpdate(AttributeUpdateNotificationMsg msg, TransportProtos.SessionInfoProto sessionInfo) {
|
353
|
public void onAttributeUpdate(AttributeUpdateNotificationMsg msg, TransportProtos.SessionInfoProto sessionInfo) {
|
354
|
LwM2mClient lwM2MClient = clientContext.getClient(sessionInfo);
|
354
|
LwM2mClient lwM2MClient = clientContext.getClient(sessionInfo);
|
355
|
- if (msg.getSharedUpdatedCount() > 0) {
|
355
|
+ if (msg.getSharedUpdatedCount() > 0 && lwM2MClient != null) {
|
|
|
356
|
+ log.warn ("2) OnAttributeUpdate, SharedUpdatedList() [{}]", msg.getSharedUpdatedList());
|
356
|
msg.getSharedUpdatedList().forEach(tsKvProto -> {
|
357
|
msg.getSharedUpdatedList().forEach(tsKvProto -> {
|
357
|
String pathName = tsKvProto.getKv().getKey();
|
358
|
String pathName = tsKvProto.getKv().getKey();
|
358
|
String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName);
|
359
|
String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, pathName);
|
|
@@ -387,7 +388,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -387,7 +388,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
387
|
}
|
388
|
}
|
388
|
|
389
|
|
389
|
});
|
390
|
});
|
390
|
- } else if (msg.getSharedDeletedCount() > 0) {
|
391
|
+ } else if (msg.getSharedDeletedCount() > 0 && lwM2MClient != null) {
|
391
|
msg.getSharedUpdatedList().forEach(tsKvProto -> {
|
392
|
msg.getSharedUpdatedList().forEach(tsKvProto -> {
|
392
|
String pathName = tsKvProto.getKv().getKey();
|
393
|
String pathName = tsKvProto.getKv().getKey();
|
393
|
Object valueNew = getValueFromKvProto(tsKvProto.getKv());
|
394
|
Object valueNew = getValueFromKvProto(tsKvProto.getKv());
|
|
@@ -397,6 +398,9 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -397,6 +398,9 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
397
|
});
|
398
|
});
|
398
|
log.info("[{}] delete [{}] onAttributeUpdate", msg.getSharedDeletedList(), sessionInfo);
|
399
|
log.info("[{}] delete [{}] onAttributeUpdate", msg.getSharedDeletedList(), sessionInfo);
|
399
|
}
|
400
|
}
|
|
|
401
|
+ else if (lwM2MClient == null) {
|
|
|
402
|
+ log.error ("OnAttributeUpdate, lwM2MClient is null");
|
|
|
403
|
+ }
|
400
|
}
|
404
|
}
|
401
|
|
405
|
|
402
|
/**
|
406
|
/**
|
|
@@ -443,6 +447,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -443,6 +447,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
443
|
public void onToDeviceRpcRequest(TransportProtos.ToDeviceRpcRequestMsg toDeviceRpcRequestMsg, SessionInfoProto sessionInfo) {
|
447
|
public void onToDeviceRpcRequest(TransportProtos.ToDeviceRpcRequestMsg toDeviceRpcRequestMsg, SessionInfoProto sessionInfo) {
|
444
|
// #1
|
448
|
// #1
|
445
|
this.checkRpcRequestTimeout();
|
449
|
this.checkRpcRequestTimeout();
|
|
|
450
|
+ log.warn ("4) toDeviceRpcRequestMsg: [{}], sessionUUID: [{}]", toDeviceRpcRequestMsg, new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB()));
|
446
|
String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null";
|
451
|
String bodyParams = StringUtils.trimToNull(toDeviceRpcRequestMsg.getParams()) != null ? toDeviceRpcRequestMsg.getParams() : "null";
|
447
|
LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName());
|
452
|
LwM2mTypeOper lwM2mTypeOper = setValidTypeOper(toDeviceRpcRequestMsg.getMethodName());
|
448
|
UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB());
|
453
|
UUID requestUUID = new UUID(toDeviceRpcRequestMsg.getRequestIdMSB(), toDeviceRpcRequestMsg.getRequestIdLSB());
|
|
@@ -502,6 +507,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -502,6 +507,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
502
|
|
507
|
|
503
|
@Override
|
508
|
@Override
|
504
|
public void onToDeviceRpcResponse(TransportProtos.ToDeviceRpcResponseMsg toDeviceResponse, SessionInfoProto sessionInfo) {
|
509
|
public void onToDeviceRpcResponse(TransportProtos.ToDeviceRpcResponseMsg toDeviceResponse, SessionInfoProto sessionInfo) {
|
|
|
510
|
+ log.warn ("5) nToDeviceRpcResponse: [{}], sessionUUID: [{}]", toDeviceResponse, new UUID(sessionInfo.getSessionIdMSB(), sessionInfo.getSessionIdLSB()));
|
505
|
transportService.process(sessionInfo, toDeviceResponse, null);
|
511
|
transportService.process(sessionInfo, toDeviceResponse, null);
|
506
|
}
|
512
|
}
|
507
|
|
513
|
|
|
@@ -882,10 +888,16 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -882,10 +888,16 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
882
|
*/
|
888
|
*/
|
883
|
private Object getResourceValueFormatKv(LwM2mClient lwM2MClient, String pathIdVer) {
|
889
|
private Object getResourceValueFormatKv(LwM2mClient lwM2MClient, String pathIdVer) {
|
884
|
LwM2mResource resourceValue = this.getResourceValueFromLwM2MClient(lwM2MClient, pathIdVer);
|
890
|
LwM2mResource resourceValue = this.getResourceValueFromLwM2MClient(lwM2MClient, pathIdVer);
|
885
|
- ResourceModel.Type currentType = resourceValue.getType();
|
|
|
886
|
- ResourceModel.Type expectedType = this.helper.getResourceModelTypeEqualsKvProtoValueType(currentType, pathIdVer);
|
|
|
887
|
- return this.converter.convertValue(resourceValue.getValue(), currentType, expectedType,
|
|
|
888
|
- new LwM2mPath(convertPathFromIdVerToObjectId(pathIdVer)));
|
891
|
+ if (resourceValue != null) {
|
|
|
892
|
+ ResourceModel.Type currentType = resourceValue.getType();
|
|
|
893
|
+ ResourceModel.Type expectedType = this.helper.getResourceModelTypeEqualsKvProtoValueType(currentType, pathIdVer);
|
|
|
894
|
+ return this.converter.convertValue(resourceValue.getValue(), currentType, expectedType,
|
|
|
895
|
+ new LwM2mPath(convertPathFromIdVerToObjectId(pathIdVer)));
|
|
|
896
|
+ }
|
|
|
897
|
+
|
|
|
898
|
+ else {
|
|
|
899
|
+ return null;
|
|
|
900
|
+ }
|
889
|
}
|
901
|
}
|
890
|
|
902
|
|
891
|
/**
|
903
|
/**
|
|
@@ -1246,22 +1258,28 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -1246,22 +1258,28 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1246
|
*/
|
1258
|
*/
|
1247
|
public void updateAttributeFromThingsboard(List<TransportProtos.TsKvProto> tsKvProtos, TransportProtos.SessionInfoProto sessionInfo) {
|
1259
|
public void updateAttributeFromThingsboard(List<TransportProtos.TsKvProto> tsKvProtos, TransportProtos.SessionInfoProto sessionInfo) {
|
1248
|
LwM2mClient lwM2MClient = clientContext.getClient(sessionInfo);
|
1260
|
LwM2mClient lwM2MClient = clientContext.getClient(sessionInfo);
|
1249
|
- tsKvProtos.forEach(tsKvProto -> {
|
|
|
1250
|
- String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, tsKvProto.getKv().getKey());
|
|
|
1251
|
- if (pathIdVer != null) {
|
|
|
1252
|
- // #1.1
|
|
|
1253
|
- if (lwM2MClient.getDelayedRequests().containsKey(pathIdVer) && tsKvProto.getTs() > lwM2MClient.getDelayedRequests().get(pathIdVer).getTs()) {
|
|
|
1254
|
- lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
|
|
|
1255
|
- } else if (!lwM2MClient.getDelayedRequests().containsKey(pathIdVer)) {
|
|
|
1256
|
- lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
|
1261
|
+ if (lwM2MClient != null) {
|
|
|
1262
|
+ log.warn("1) UpdateAttributeFromThingsboard, tsKvProtos [{}]", tsKvProtos);
|
|
|
1263
|
+ tsKvProtos.forEach(tsKvProto -> {
|
|
|
1264
|
+ String pathIdVer = this.getPresentPathIntoProfile(sessionInfo, tsKvProto.getKv().getKey());
|
|
|
1265
|
+ if (pathIdVer != null) {
|
|
|
1266
|
+ // #1.1
|
|
|
1267
|
+ if (lwM2MClient.getDelayedRequests().containsKey(pathIdVer) && tsKvProto.getTs() > lwM2MClient.getDelayedRequests().get(pathIdVer).getTs()) {
|
|
|
1268
|
+ lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
|
|
|
1269
|
+ } else if (!lwM2MClient.getDelayedRequests().containsKey(pathIdVer)) {
|
|
|
1270
|
+ lwM2MClient.getDelayedRequests().put(pathIdVer, tsKvProto);
|
|
|
1271
|
+ }
|
1257
|
}
|
1272
|
}
|
1258
|
- }
|
|
|
1259
|
- });
|
|
|
1260
|
- // #2.1
|
|
|
1261
|
- lwM2MClient.getDelayedRequests().forEach((pathIdVer, tsKvProto) -> {
|
|
|
1262
|
- this.updateResourcesValueToClient(lwM2MClient, this.getResourceValueFormatKv(lwM2MClient, pathIdVer),
|
|
|
1263
|
- getValueFromKvProto(tsKvProto.getKv()), pathIdVer);
|
|
|
1264
|
- });
|
1273
|
+ });
|
|
|
1274
|
+ // #2.1
|
|
|
1275
|
+ lwM2MClient.getDelayedRequests().forEach((pathIdVer, tsKvProto) -> {
|
|
|
1276
|
+ this.updateResourcesValueToClient(lwM2MClient, this.getResourceValueFormatKv(lwM2MClient, pathIdVer),
|
|
|
1277
|
+ getValueFromKvProto(tsKvProto.getKv()), pathIdVer);
|
|
|
1278
|
+ });
|
|
|
1279
|
+ }
|
|
|
1280
|
+ else {
|
|
|
1281
|
+ log.error("UpdateAttributeFromThingsboard, lwM2MClient is null");
|
|
|
1282
|
+ }
|
1265
|
}
|
1283
|
}
|
1266
|
|
1284
|
|
1267
|
/**
|
1285
|
/**
|
|
@@ -1350,6 +1368,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
|
@@ -1350,6 +1368,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1350
|
public void onSuccess(TransportProtos.GetFirmwareResponseMsg response) {
|
1368
|
public void onSuccess(TransportProtos.GetFirmwareResponseMsg response) {
|
1351
|
if (TransportProtos.ResponseStatus.SUCCESS.equals(response.getResponseStatus())
|
1369
|
if (TransportProtos.ResponseStatus.SUCCESS.equals(response.getResponseStatus())
|
1352
|
&& response.getType().equals(FirmwareType.FIRMWARE.name())) {
|
1370
|
&& response.getType().equals(FirmwareType.FIRMWARE.name())) {
|
|
|
1371
|
+ log.warn ("7) firmware start with ver: [{}]",response.getVersion());
|
1353
|
lwM2MClient.getFwUpdate().setCurrentVersion(response.getVersion());
|
1372
|
lwM2MClient.getFwUpdate().setCurrentVersion(response.getVersion());
|
1354
|
lwM2MClient.getFwUpdate().setCurrentTitle(response.getTitle());
|
1373
|
lwM2MClient.getFwUpdate().setCurrentTitle(response.getTitle());
|
1355
|
lwM2MClient.getFwUpdate().setCurrentId(new FirmwareId(new UUID(response.getFirmwareIdMSB(), response.getFirmwareIdLSB())).getId());
|
1374
|
lwM2MClient.getFwUpdate().setCurrentId(new FirmwareId(new UUID(response.getFirmwareIdMSB(), response.getFirmwareIdLSB())).getId());
|