...
|
...
|
@@ -31,7 +31,6 @@ import org.eclipse.leshan.core.node.LwM2mObjectInstance; |
31
|
31
|
import org.eclipse.leshan.core.node.LwM2mPath;
|
32
|
32
|
import org.eclipse.leshan.core.node.LwM2mResource;
|
33
|
33
|
import org.eclipse.leshan.core.observation.Observation;
|
34
|
|
-import org.eclipse.leshan.core.request.ContentFormat;
|
35
|
34
|
import org.eclipse.leshan.core.request.WriteRequest;
|
36
|
35
|
import org.eclipse.leshan.core.response.ReadResponse;
|
37
|
36
|
import org.eclipse.leshan.server.registration.Registration;
|
...
|
...
|
@@ -100,6 +99,7 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.L |
100
|
99
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_INFO;
|
101
|
100
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_TELEMETRY;
|
102
|
101
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_VALUE;
|
|
102
|
+import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_WARN;
|
103
|
103
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LWM2M_STRATEGY_2;
|
104
|
104
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER;
|
105
|
105
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE;
|
...
|
...
|
@@ -183,39 +183,38 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
183
|
183
|
*/
|
184
|
184
|
public void onRegistered(Registration registration, Collection<Observation> previousObservations) {
|
185
|
185
|
registrationExecutor.submit(() -> {
|
|
186
|
+ LwM2mClient lwM2MClient = this.clientContext.getClientByEndpoint(registration.getEndpoint());
|
186
|
187
|
try {
|
187
|
188
|
log.warn("[{}] [{{}] Client: create after Registration", registration.getEndpoint(), registration.getId());
|
188
|
|
- LwM2mClient lwM2MClient = this.clientContext.getClientByEndpoint(registration.getEndpoint());
|
189
|
189
|
if (lwM2MClient != null) {
|
190
|
190
|
this.clientContext.register(lwM2MClient, registration);
|
|
191
|
+ this.sendLogsToThingsboard(lwM2MClient, LOG_LW2M_INFO + ": Client registered with registration id: " + registration.getId());
|
191
|
192
|
SessionInfoProto sessionInfo = lwM2MClient.getSession();
|
192
|
|
- if (sessionInfo != null) {
|
193
|
|
- transportService.registerAsyncSession(sessionInfo, new LwM2mSessionMsgListener(this, sessionInfo));
|
194
|
|
- TransportProtos.TransportToDeviceActorMsg msg = TransportProtos.TransportToDeviceActorMsg.newBuilder()
|
195
|
|
- .setSessionInfo(sessionInfo)
|
196
|
|
- .setSessionEvent(DefaultTransportService.getSessionEventMsg(SessionEvent.OPEN))
|
197
|
|
- .setSubscribeToAttributes(TransportProtos.SubscribeToAttributeUpdatesMsg.newBuilder().build())
|
198
|
|
- .setSubscribeToRPC(TransportProtos.SubscribeToRPCMsg.newBuilder().build())
|
199
|
|
- .build();
|
200
|
|
- transportService.process(msg, null);
|
201
|
|
- this.getInfoFirmwareUpdate(lwM2MClient, null);
|
202
|
|
- this.getInfoSoftwareUpdate(lwM2MClient, null);
|
203
|
|
- this.initLwM2mFromClientValue(registration, lwM2MClient);
|
204
|
|
- this.sendLogsToThingsboard(lwM2MClient, LOG_LW2M_INFO + ": Client create after Registration");
|
205
|
|
- } else {
|
206
|
|
- log.error("Client: [{}] onRegistered [{}] name [{}] sessionInfo ", registration.getId(), registration.getEndpoint(), null);
|
207
|
|
- }
|
|
193
|
+ transportService.registerAsyncSession(sessionInfo, new LwM2mSessionMsgListener(this, sessionInfo));
|
|
194
|
+ TransportProtos.TransportToDeviceActorMsg msg = TransportProtos.TransportToDeviceActorMsg.newBuilder()
|
|
195
|
+ .setSessionInfo(sessionInfo)
|
|
196
|
+ .setSessionEvent(DefaultTransportService.getSessionEventMsg(SessionEvent.OPEN))
|
|
197
|
+ .setSubscribeToAttributes(TransportProtos.SubscribeToAttributeUpdatesMsg.newBuilder().build())
|
|
198
|
+ .setSubscribeToRPC(TransportProtos.SubscribeToRPCMsg.newBuilder().build())
|
|
199
|
+ .build();
|
|
200
|
+ transportService.process(msg, null);
|
|
201
|
+ this.getInfoFirmwareUpdate(lwM2MClient, null);
|
|
202
|
+ this.getInfoSoftwareUpdate(lwM2MClient, null);
|
|
203
|
+ this.initClientTelemetry(lwM2MClient);
|
208
|
204
|
} else {
|
209
|
|
- log.error("Client: [{}] onRegistered [{}] name [{}] lwM2MClient ", registration.getId(), registration.getEndpoint(), null);
|
|
205
|
+ log.error("Client: [{}] onRegistered [{}] name [{}] lwM2MClient ", registration.getId(), registration.getEndpoint(), null);
|
210
|
206
|
}
|
211
|
207
|
} catch (LwM2MClientStateException stateException) {
|
212
|
208
|
if (LwM2MClientState.UNREGISTERED.equals(stateException.getState())) {
|
213
|
209
|
log.info("[{}] retry registration due to race condition: [{}].", registration.getEndpoint(), stateException.getState());
|
214
|
210
|
// Race condition detected and the client was in progress of unregistration while new registration arrived. Let's try again.
|
215
|
211
|
onRegistered(registration, previousObservations);
|
|
212
|
+ } else {
|
|
213
|
+ this.sendLogsToThingsboard(lwM2MClient, LOG_LW2M_WARN + ": Client registration failed due to invalid state: " + stateException.getState());
|
216
|
214
|
}
|
217
|
215
|
} catch (Throwable t) {
|
218
|
216
|
log.error("[{}] endpoint [{}] error Unable registration.", registration.getEndpoint(), t);
|
|
217
|
+ this.sendLogsToThingsboard(lwM2MClient, LOG_LW2M_WARN + ": Client registration failed due to: " + t.getMessage());
|
219
|
218
|
}
|
220
|
219
|
});
|
221
|
220
|
}
|
...
|
...
|
@@ -232,7 +231,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
232
|
231
|
clientContext.updateRegistration(lwM2MClient, registration);
|
233
|
232
|
TransportProtos.SessionInfoProto sessionInfo = lwM2MClient.getSession();
|
234
|
233
|
this.reportActivityAndRegister(sessionInfo);
|
235
|
|
- if (registration.getQueueMode()) {
|
|
234
|
+ if (registration.usesQueueMode()) {
|
236
|
235
|
LwM2mQueuedRequest request;
|
237
|
236
|
while ((request = lwM2MClient.getQueuedRequests().poll()) != null) {
|
238
|
237
|
request.send();
|
...
|
...
|
@@ -292,8 +291,11 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
292
|
291
|
@Override
|
293
|
292
|
public void setCancelObservationsAll(Registration registration) {
|
294
|
293
|
if (registration != null) {
|
295
|
|
- this.lwM2mTransportRequest.sendAllRequest(registration, null, OBSERVE_CANCEL_ALL,
|
296
|
|
- null, null, this.config.getTimeout(), null);
|
|
294
|
+ LwM2mClient client = clientContext.getClientByEndpoint(registration.getEndpoint());
|
|
295
|
+ if (client != null && client.getRegistration() != null && client.getRegistration().getId().equals(registration.getId())) {
|
|
296
|
+ this.lwM2mTransportRequest.sendAllRequest(client, null, OBSERVE_CANCEL_ALL,
|
|
297
|
+ null, null, this.config.getTimeout(), null);
|
|
298
|
+ }
|
297
|
299
|
}
|
298
|
300
|
}
|
299
|
301
|
|
...
|
...
|
@@ -459,13 +461,14 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
459
|
461
|
this.rpcSubscriptions.put(requestUUID, toDeviceRpcRequestMsg.getExpirationTime());
|
460
|
462
|
Lwm2mClientRpcRequest lwm2mClientRpcRequest = null;
|
461
|
463
|
try {
|
462
|
|
- Registration registration = clientContext.getClientBySessionInfo(sessionInfo).getRegistration();
|
|
464
|
+ LwM2mClient client = clientContext.getClientBySessionInfo(sessionInfo);
|
|
465
|
+ Registration registration = client.getRegistration();
|
463
|
466
|
lwm2mClientRpcRequest = new Lwm2mClientRpcRequest(lwM2mTypeOper, bodyParams, toDeviceRpcRequestMsg.getRequestId(), sessionInfo, registration, this);
|
464
|
467
|
if (lwm2mClientRpcRequest.getErrorMsg() != null) {
|
465
|
468
|
lwm2mClientRpcRequest.setResponseCode(BAD_REQUEST.name());
|
466
|
469
|
this.onToDeviceRpcResponse(lwm2mClientRpcRequest.getDeviceRpcResponseResultMsg(), sessionInfo);
|
467
|
470
|
} else {
|
468
|
|
- lwM2mTransportRequest.sendAllRequest(registration, lwm2mClientRpcRequest.getTargetIdVer(), lwm2mClientRpcRequest.getTypeOper(),
|
|
471
|
+ lwM2mTransportRequest.sendAllRequest(client, lwm2mClientRpcRequest.getTargetIdVer(), lwm2mClientRpcRequest.getTypeOper(),
|
469
|
472
|
null,
|
470
|
473
|
lwm2mClientRpcRequest.getValue() == null ? lwm2mClientRpcRequest.getParams() : lwm2mClientRpcRequest.getValue(),
|
471
|
474
|
this.config.getTimeout(), lwm2mClientRpcRequest);
|
...
|
...
|
@@ -520,17 +523,6 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
520
|
523
|
}
|
521
|
524
|
|
522
|
525
|
/**
|
523
|
|
- * Trigger Server path = "/1/0/8"
|
524
|
|
- * <p>
|
525
|
|
- * Trigger bootStrap path = "/1/0/9" - have to implemented on client
|
526
|
|
- */
|
527
|
|
- @Override
|
528
|
|
- public void doTrigger(Registration registration, String path) {
|
529
|
|
- lwM2mTransportRequest.sendAllRequest(registration, path, EXECUTE,
|
530
|
|
- ContentFormat.TLV.getName(), null, this.config.getTimeout(), null);
|
531
|
|
- }
|
532
|
|
-
|
533
|
|
- /**
|
534
|
526
|
* Deregister session in transport
|
535
|
527
|
*
|
536
|
528
|
* @param sessionInfo - lwm2m client
|
...
|
...
|
@@ -572,7 +564,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
572
|
564
|
* @param registrationId - Id of Registration LwM2M Client
|
573
|
565
|
*/
|
574
|
566
|
@Override
|
575
|
|
- public void sendLogsToThingsboard2(String registrationId, String logMsg) {
|
|
567
|
+ public void sendLogsToThingsboard(String registrationId, String logMsg) {
|
576
|
568
|
sendLogsToThingsboard(clientContext.getClientByRegistrationId(registrationId), logMsg);
|
577
|
569
|
}
|
578
|
570
|
|
...
|
...
|
@@ -595,24 +587,23 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
595
|
587
|
* - Read Request to the client after registration to read all resource values for all objects
|
596
|
588
|
* - then Observe Request to the client marked as observe from the profile configuration.
|
597
|
589
|
*
|
598
|
|
- * @param registration - Registration LwM2M Client
|
599
|
|
- * @param lwM2MClient - object with All parameters off client
|
|
590
|
+ * @param lwM2MClient - object with All parameters off client
|
600
|
591
|
*/
|
601
|
|
- private void initLwM2mFromClientValue(Registration registration, LwM2mClient lwM2MClient) {
|
602
|
|
- LwM2mClientProfile lwM2MClientProfile = clientContext.getProfile(registration);
|
603
|
|
- Set<String> clientObjects = clientContext.getSupportedIdVerInClient(registration);
|
|
592
|
+ private void initClientTelemetry(LwM2mClient lwM2MClient) {
|
|
593
|
+ LwM2mClientProfile lwM2MClientProfile = clientContext.getProfile(lwM2MClient.getProfileId());
|
|
594
|
+ Set<String> clientObjects = clientContext.getSupportedIdVerInClient(lwM2MClient);
|
604
|
595
|
if (clientObjects != null && clientObjects.size() > 0) {
|
605
|
596
|
if (LWM2M_STRATEGY_2 == LwM2mTransportUtil.getClientOnlyObserveAfterConnect(lwM2MClientProfile)) {
|
606
|
597
|
// #2
|
607
|
598
|
lwM2MClient.getPendingReadRequests().addAll(clientObjects);
|
608
|
|
- clientObjects.forEach(path -> lwM2mTransportRequest.sendAllRequest(registration, path, READ, ContentFormat.TLV.getName(),
|
|
599
|
+ clientObjects.forEach(path -> lwM2mTransportRequest.sendAllRequest(lwM2MClient, path, READ,
|
609
|
600
|
null, this.config.getTimeout(), null));
|
610
|
601
|
}
|
611
|
602
|
// #1
|
612
|
|
- this.initReadAttrTelemetryObserveToClient(registration, lwM2MClient, READ, clientObjects);
|
613
|
|
- this.initReadAttrTelemetryObserveToClient(registration, lwM2MClient, OBSERVE, clientObjects);
|
614
|
|
- this.initReadAttrTelemetryObserveToClient(registration, lwM2MClient, WRITE_ATTRIBUTES, clientObjects);
|
615
|
|
- this.initReadAttrTelemetryObserveToClient(registration, lwM2MClient, DISCOVER, clientObjects);
|
|
603
|
+ this.initReadAttrTelemetryObserveToClient(lwM2MClient, READ, clientObjects);
|
|
604
|
+ this.initReadAttrTelemetryObserveToClient(lwM2MClient, OBSERVE, clientObjects);
|
|
605
|
+ this.initReadAttrTelemetryObserveToClient(lwM2MClient, WRITE_ATTRIBUTES, clientObjects);
|
|
606
|
+ this.initReadAttrTelemetryObserveToClient(lwM2MClient, DISCOVER, clientObjects);
|
616
|
607
|
}
|
617
|
608
|
}
|
618
|
609
|
|
...
|
...
|
@@ -749,15 +740,9 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
749
|
740
|
}
|
750
|
741
|
}
|
751
|
742
|
|
752
|
|
- /**
|
753
|
|
- * Start observe/read: Attr/Telemetry
|
754
|
|
- * #1 - Analyze: path in resource profile == client resource
|
755
|
|
- *
|
756
|
|
- * @param registration -
|
757
|
|
- */
|
758
|
|
- private void initReadAttrTelemetryObserveToClient(Registration registration, LwM2mClient lwM2MClient,
|
|
743
|
+ private void initReadAttrTelemetryObserveToClient(LwM2mClient lwM2MClient,
|
759
|
744
|
LwM2mTypeOper typeOper, Set<String> clientObjects) {
|
760
|
|
- LwM2mClientProfile lwM2MClientProfile = clientContext.getProfile(registration);
|
|
745
|
+ LwM2mClientProfile lwM2MClientProfile = clientContext.getProfile(lwM2MClient.getProfileId());
|
761
|
746
|
Set<String> result = null;
|
762
|
747
|
ConcurrentHashMap<String, Object> params = null;
|
763
|
748
|
if (READ.equals(typeOper)) {
|
...
|
...
|
@@ -789,7 +774,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
789
|
774
|
lwM2MClient.getPendingReadRequests().addAll(pathSend);
|
790
|
775
|
ConcurrentHashMap<String, Object> finalParams = params;
|
791
|
776
|
pathSend.forEach(target -> {
|
792
|
|
- lwM2mTransportRequest.sendAllRequest(registration, target, typeOper, ContentFormat.TEXT.getName(),
|
|
777
|
+ lwM2mTransportRequest.sendAllRequest(lwM2MClient, target, typeOper,
|
793
|
778
|
finalParams != null ? finalParams.get(target) : null, this.config.getTimeout(), null);
|
794
|
779
|
});
|
795
|
780
|
if (OBSERVE.equals(typeOper)) {
|
...
|
...
|
@@ -1023,7 +1008,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1023
|
1008
|
if (sendAttrToThingsboard.getPathPostParametersAdd().size() > 0) {
|
1024
|
1009
|
// update value in Resources
|
1025
|
1010
|
clients.forEach(client -> {
|
1026
|
|
- this.readObserveFromProfile(client.getRegistration(), sendAttrToThingsboard.getPathPostParametersAdd(), READ);
|
|
1011
|
+ this.readObserveFromProfile(client, sendAttrToThingsboard.getPathPostParametersAdd(), READ);
|
1027
|
1012
|
});
|
1028
|
1013
|
}
|
1029
|
1014
|
// #4.2 del
|
...
|
...
|
@@ -1050,12 +1035,12 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1050
|
1035
|
clients.forEach(client -> {
|
1051
|
1036
|
Registration registration = client.getRegistration();
|
1052
|
1037
|
if (postObserveAnalyzer.getPathPostParametersAdd().size() > 0) {
|
1053
|
|
- this.readObserveFromProfile(registration, postObserveAnalyzer.getPathPostParametersAdd(), OBSERVE);
|
|
1038
|
+ this.readObserveFromProfile(client, postObserveAnalyzer.getPathPostParametersAdd(), OBSERVE);
|
1054
|
1039
|
}
|
1055
|
1040
|
// 5.3 del
|
1056
|
1041
|
// send Request cancel observe to Client
|
1057
|
1042
|
if (postObserveAnalyzer.getPathPostParametersDel().size() > 0) {
|
1058
|
|
- this.cancelObserveFromProfile(registration, postObserveAnalyzer.getPathPostParametersDel());
|
|
1043
|
+ this.cancelObserveFromProfile(client, postObserveAnalyzer.getPathPostParametersDel());
|
1059
|
1044
|
}
|
1060
|
1045
|
});
|
1061
|
1046
|
}
|
...
|
...
|
@@ -1092,19 +1077,18 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1092
|
1077
|
* Update Resource value after change RezAttrTelemetry in config Profile
|
1093
|
1078
|
* send response Read to Client and add path to pathResAttrTelemetry in LwM2MClient.getAttrTelemetryObserveValue()
|
1094
|
1079
|
*
|
1095
|
|
- * @param registration - Registration LwM2M Client
|
1096
|
|
- * @param targets - path Resources == [ "/2/0/0", "/2/0/1"]
|
|
1080
|
+ * @param targets - path Resources == [ "/2/0/0", "/2/0/1"]
|
1097
|
1081
|
*/
|
1098
|
|
- private void readObserveFromProfile(Registration registration, Set<String> targets, LwM2mTypeOper typeOper) {
|
|
1082
|
+ private void readObserveFromProfile(LwM2mClient client, Set<String> targets, LwM2mTypeOper typeOper) {
|
1099
|
1083
|
targets.forEach(target -> {
|
1100
|
1084
|
LwM2mPath pathIds = new LwM2mPath(convertPathFromIdVerToObjectId(target));
|
1101
|
1085
|
if (pathIds.isResource()) {
|
1102
|
1086
|
if (READ.equals(typeOper)) {
|
1103
|
|
- lwM2mTransportRequest.sendAllRequest(registration, target, typeOper,
|
1104
|
|
- ContentFormat.TLV.getName(), null, this.config.getTimeout(), null);
|
|
1087
|
+ lwM2mTransportRequest.sendAllRequest(client, target, typeOper,
|
|
1088
|
+ null, this.config.getTimeout(), null);
|
1105
|
1089
|
} else if (OBSERVE.equals(typeOper)) {
|
1106
|
|
- lwM2mTransportRequest.sendAllRequest(registration, target, typeOper,
|
1107
|
|
- null, null, this.config.getTimeout(), null);
|
|
1090
|
+ lwM2mTransportRequest.sendAllRequest(client, target, typeOper,
|
|
1091
|
+ null, this.config.getTimeout(), null);
|
1108
|
1092
|
}
|
1109
|
1093
|
}
|
1110
|
1094
|
});
|
...
|
...
|
@@ -1153,13 +1137,12 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1153
|
1137
|
// #6.2
|
1154
|
1138
|
if (analyzerParameters.getPathPostParametersAdd().size() > 0) {
|
1155
|
1139
|
clients.forEach(client -> {
|
1156
|
|
- Registration registration = client.getRegistration();
|
1157
|
|
- Set<String> clientObjects = clientContext.getSupportedIdVerInClient(registration);
|
|
1140
|
+ Set<String> clientObjects = clientContext.getSupportedIdVerInClient(client);
|
1158
|
1141
|
Set<String> pathSend = analyzerParameters.getPathPostParametersAdd().stream().filter(target -> clientObjects.contains("/" + target.split(LWM2M_SEPARATOR_PATH)[1]))
|
1159
|
1142
|
.collect(Collectors.toUnmodifiableSet());
|
1160
|
1143
|
if (!pathSend.isEmpty()) {
|
1161
|
1144
|
ConcurrentHashMap<String, Object> finalParams = lwm2mAttributesNew;
|
1162
|
|
- pathSend.forEach(target -> lwM2mTransportRequest.sendAllRequest(registration, target, WRITE_ATTRIBUTES, ContentFormat.TEXT.getName(),
|
|
1145
|
+ pathSend.forEach(target -> lwM2mTransportRequest.sendAllRequest(client, target, WRITE_ATTRIBUTES,
|
1163
|
1146
|
finalParams.get(target), this.config.getTimeout(), null));
|
1164
|
1147
|
}
|
1165
|
1148
|
});
|
...
|
...
|
@@ -1168,7 +1151,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1168
|
1151
|
if (analyzerParameters.getPathPostParametersDel().size() > 0) {
|
1169
|
1152
|
clients.forEach(client -> {
|
1170
|
1153
|
Registration registration = client.getRegistration();
|
1171
|
|
- Set<String> clientObjects = clientContext.getSupportedIdVerInClient(registration);
|
|
1154
|
+ Set<String> clientObjects = clientContext.getSupportedIdVerInClient(client);
|
1172
|
1155
|
Set<String> pathSend = analyzerParameters.getPathPostParametersDel().stream().filter(target -> clientObjects.contains("/" + target.split(LWM2M_SEPARATOR_PATH)[1]))
|
1173
|
1156
|
.collect(Collectors.toUnmodifiableSet());
|
1174
|
1157
|
if (!pathSend.isEmpty()) {
|
...
|
...
|
@@ -1176,8 +1159,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1176
|
1159
|
Map<String, Object> params = (Map<String, Object>) lwm2mAttributesOld.get(target);
|
1177
|
1160
|
params.clear();
|
1178
|
1161
|
params.put(OBJECT_VERSION, "");
|
1179
|
|
- lwM2mTransportRequest.sendAllRequest(registration, target, WRITE_ATTRIBUTES, ContentFormat.TEXT.getName(),
|
1180
|
|
- params, this.config.getTimeout(), null);
|
|
1162
|
+ lwM2mTransportRequest.sendAllRequest(client, target, WRITE_ATTRIBUTES, params, this.config.getTimeout(), null);
|
1181
|
1163
|
});
|
1182
|
1164
|
}
|
1183
|
1165
|
});
|
...
|
...
|
@@ -1185,12 +1167,10 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1185
|
1167
|
|
1186
|
1168
|
}
|
1187
|
1169
|
|
1188
|
|
- private void cancelObserveFromProfile(Registration registration, Set<String> paramAnallyzer) {
|
1189
|
|
- LwM2mClient lwM2MClient = clientContext.getClientByEndpoint(registration.getEndpoint());
|
|
1170
|
+ private void cancelObserveFromProfile(LwM2mClient lwM2mClient, Set<String> paramAnallyzer) {
|
1190
|
1171
|
paramAnallyzer.forEach(pathIdVer -> {
|
1191
|
|
- if (this.getResourceValueFromLwM2MClient(lwM2MClient, pathIdVer) != null) {
|
1192
|
|
- lwM2mTransportRequest.sendAllRequest(registration, pathIdVer, OBSERVE_CANCEL, null,
|
1193
|
|
- null, this.config.getTimeout(), null);
|
|
1172
|
+ if (this.getResourceValueFromLwM2MClient(lwM2mClient, pathIdVer) != null) {
|
|
1173
|
+ lwM2mTransportRequest.sendAllRequest(lwM2mClient, pathIdVer, OBSERVE_CANCEL, null, this.config.getTimeout(), null);
|
1194
|
1174
|
}
|
1195
|
1175
|
}
|
1196
|
1176
|
);
|
...
|
...
|
@@ -1198,9 +1178,7 @@ public class DefaultLwM2MTransportMsgHandler implements LwM2mTransportMsgHandler |
1198
|
1178
|
|
1199
|
1179
|
private void updateResourcesValueToClient(LwM2mClient lwM2MClient, Object valueOld, Object valueNew, String path) {
|
1200
|
1180
|
if (valueNew != null && (valueOld == null || !valueNew.toString().equals(valueOld.toString()))) {
|
1201
|
|
- lwM2mTransportRequest.sendAllRequest(lwM2MClient.getRegistration(), path, WRITE_REPLACE,
|
1202
|
|
- ContentFormat.TLV.getName(), valueNew,
|
1203
|
|
- this.config.getTimeout(), null);
|
|
1181
|
+ lwM2mTransportRequest.sendAllRequest(lwM2MClient, path, WRITE_REPLACE, valueNew, this.config.getTimeout(), null);
|
1204
|
1182
|
} else {
|
1205
|
1183
|
log.error("Failed update resource [{}] [{}]", path, valueNew);
|
1206
|
1184
|
String logMsg = String.format("%s: Failed update resource path - %s value - %s. Value is not changed or bad",
|
...
|
...
|
|