|
@@ -82,10 +82,8 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.L |
|
@@ -82,10 +82,8 @@ import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.L |
82
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_VALUE;
|
82
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LOG_LW2M_VALUE;
|
83
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper;
|
83
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper;
|
84
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.DISCOVER;
|
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
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE;
|
85
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.EXECUTE;
|
87
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_CANCEL;
|
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
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_READ_ALL;
|
87
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.OBSERVE_READ_ALL;
|
90
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_ATTRIBUTES;
|
88
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_ATTRIBUTES;
|
91
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_REPLACE;
|
89
|
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.LwM2mTypeOper.WRITE_REPLACE;
|
|
@@ -134,7 +132,7 @@ public class LwM2mTransportRequest { |
|
@@ -134,7 +132,7 @@ public class LwM2mTransportRequest { |
134
|
ContentFormat contentFormat = contentFormatName != null ? ContentFormat.fromName(contentFormatName.toUpperCase()) : ContentFormat.DEFAULT;
|
132
|
ContentFormat contentFormat = contentFormatName != null ? ContentFormat.fromName(contentFormatName.toUpperCase()) : ContentFormat.DEFAULT;
|
135
|
LwM2mClient lwM2MClient = this.lwM2mClientContext.getOrRegister(registration);
|
133
|
LwM2mClient lwM2MClient = this.lwM2mClientContext.getOrRegister(registration);
|
136
|
LwM2mPath resultIds = target != null ? new LwM2mPath(target) : null;
|
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
|
if (lwM2MClient.isValidObjectVersion(targetIdVer)) {
|
136
|
if (lwM2MClient.isValidObjectVersion(targetIdVer)) {
|
139
|
timeoutInMs = timeoutInMs > 0 ? timeoutInMs : DEFAULT_TIMEOUT;
|
137
|
timeoutInMs = timeoutInMs > 0 ? timeoutInMs : DEFAULT_TIMEOUT;
|
140
|
DownlinkRequest request = createRequest(registration, lwM2MClient, typeOper, contentFormat, target,
|
138
|
DownlinkRequest request = createRequest(registration, lwM2MClient, typeOper, contentFormat, target,
|
|
@@ -153,47 +151,66 @@ public class LwM2mTransportRequest { |
|
@@ -153,47 +151,66 @@ public class LwM2mTransportRequest { |
153
|
} else if (WRITE_UPDATE.name().equals(typeOper.name())) {
|
151
|
} else if (WRITE_UPDATE.name().equals(typeOper.name())) {
|
154
|
if (lwm2mClientRpcRequest != null) {
|
152
|
if (lwm2mClientRpcRequest != null) {
|
155
|
String errorMsg = String.format("Path %s params is not valid", targetIdVer);
|
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
|
} else if (WRITE_REPLACE.name().equals(typeOper.name()) || EXECUTE.name().equals(typeOper.name())) {
|
156
|
} else if (WRITE_REPLACE.name().equals(typeOper.name()) || EXECUTE.name().equals(typeOper.name())) {
|
159
|
if (lwm2mClientRpcRequest != null) {
|
157
|
if (lwm2mClientRpcRequest != null) {
|
160
|
String errorMsg = String.format("Path %s object model is absent", targetIdVer);
|
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
|
} else if (!OBSERVE_CANCEL.name().equals(typeOper.name())) {
|
161
|
} else if (!OBSERVE_CANCEL.name().equals(typeOper.name())) {
|
164
|
log.error("[{}], [{}] - [{}] error SendRequest", registration.getEndpoint(), typeOper.name(), targetIdVer);
|
162
|
log.error("[{}], [{}] - [{}] error SendRequest", registration.getEndpoint(), typeOper.name(), targetIdVer);
|
165
|
if (lwm2mClientRpcRequest != null) {
|
163
|
if (lwm2mClientRpcRequest != null) {
|
166
|
ResourceModel resourceModel = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider());
|
164
|
ResourceModel resourceModel = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider());
|
167
|
String errorMsg = resourceModel == null ? String.format("Path %s not found in object version", targetIdVer) : "SendRequest - null";
|
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
|
} else if (lwm2mClientRpcRequest != null) {
|
169
|
} else if (lwm2mClientRpcRequest != null) {
|
172
|
String errorMsg = String.format("Path %s not found in object version", targetIdVer);
|
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
|
} catch (Exception e) {
|
215
|
} catch (Exception e) {
|
199
|
String msg = String.format("%s: type operation %s %s", LOG_LW2M_ERROR,
|
216
|
String msg = String.format("%s: type operation %s %s", LOG_LW2M_ERROR,
|
|
@@ -201,7 +218,7 @@ public class LwM2mTransportRequest { |
|
@@ -201,7 +218,7 @@ public class LwM2mTransportRequest { |
201
|
handler.sendLogsToThingsboard(msg, registration.getId());
|
218
|
handler.sendLogsToThingsboard(msg, registration.getId());
|
202
|
if (lwm2mClientRpcRequest != null) {
|
219
|
if (lwm2mClientRpcRequest != null) {
|
203
|
String errorMsg = String.format("Path %s type operation %s %s", targetIdVer, typeOper.name(), e.getMessage());
|
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,17 +251,6 @@ public class LwM2mTransportRequest { |
234
|
request = new ObserveRequest(contentFormat, resultIds.getObjectId());
|
251
|
request = new ObserveRequest(contentFormat, resultIds.getObjectId());
|
235
|
}
|
252
|
}
|
236
|
break;
|
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
|
case EXECUTE:
|
254
|
case EXECUTE:
|
249
|
ResourceModel resourceModelExecute = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider());
|
255
|
ResourceModel resourceModelExecute = lwM2MClient.getResourceModel(targetIdVer, this.config.getModelProvider());
|
250
|
if (resourceModelExecute != null) {
|
256
|
if (resourceModelExecute != null) {
|
|
@@ -343,7 +349,7 @@ public class LwM2mTransportRequest { |
|
@@ -343,7 +349,7 @@ public class LwM2mTransportRequest { |
343
|
}
|
349
|
}
|
344
|
/** Not Found */
|
350
|
/** Not Found */
|
345
|
if (rpcRequest != null) {
|
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
|
/** Not Found
|
354
|
/** Not Found
|
349
|
set setClient_fw_info... = empty
|
355
|
set setClient_fw_info... = empty
|
|
@@ -385,7 +391,7 @@ public class LwM2mTransportRequest { |
|
@@ -385,7 +391,7 @@ public class LwM2mTransportRequest { |
385
|
handler.sendLogsToThingsboard(msg, registration.getId());
|
391
|
handler.sendLogsToThingsboard(msg, registration.getId());
|
386
|
log.error("[{}] [{}] - [{}] error SendRequest", request.getClass().getName().toString(), request.getPath().toString(), e.toString());
|
392
|
log.error("[{}] [{}] - [{}] error SendRequest", request.getClass().getName().toString(), request.getPath().toString(), e.toString());
|
387
|
if (rpcRequest != null) {
|
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,7 +437,7 @@ public class LwM2mTransportRequest { |
431
|
log.error("Path: [{}] type: [{}] value: [{}] errorMsg: [{}]]", patn, type, value, e.toString());
|
437
|
log.error("Path: [{}] type: [{}] value: [{}] errorMsg: [{}]]", patn, type, value, e.toString());
|
432
|
if (rpcRequest != null) {
|
438
|
if (rpcRequest != null) {
|
433
|
String errorMsg = String.format("NumberFormatException: Resource path - %s type - %s value - %s", patn, type, value);
|
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
|
return null;
|
442
|
return null;
|
437
|
}
|
443
|
}
|
|
@@ -462,44 +468,48 @@ public class LwM2mTransportRequest { |
|
@@ -462,44 +468,48 @@ public class LwM2mTransportRequest { |
462
|
if (response instanceof ReadResponse) {
|
468
|
if (response instanceof ReadResponse) {
|
463
|
handler.onUpdateValueAfterReadResponse(registration, pathIdVer, (ReadResponse) response, rpcRequest);
|
469
|
handler.onUpdateValueAfterReadResponse(registration, pathIdVer, (ReadResponse) response, rpcRequest);
|
464
|
} else if (response instanceof DeleteResponse) {
|
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
|
} else if (response instanceof DiscoverResponse) {
|
476
|
} else if (response instanceof DiscoverResponse) {
|
467
|
- String discoverValue = Link.serialize(((DiscoverResponse)response).getObjectLinks());
|
477
|
+ String discoverValue = Link.serialize(((DiscoverResponse) response).getObjectLinks());
|
468
|
msgLog = String.format("%s: type operation: %s path: %s value: %s",
|
478
|
msgLog = String.format("%s: type operation: %s path: %s value: %s",
|
469
|
LOG_LW2M_INFO, DISCOVER.name(), request.getPath().toString(), discoverValue);
|
479
|
LOG_LW2M_INFO, DISCOVER.name(), request.getPath().toString(), discoverValue);
|
470
|
handler.sendLogsToThingsboard(msgLog, registration.getId());
|
480
|
handler.sendLogsToThingsboard(msgLog, registration.getId());
|
471
|
log.warn("DiscoverResponse: [{}]", (DiscoverResponse) response);
|
481
|
log.warn("DiscoverResponse: [{}]", (DiscoverResponse) response);
|
472
|
if (rpcRequest != null) {
|
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
|
} else if (response instanceof ExecuteResponse) {
|
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
|
} else if (response instanceof WriteAttributesResponse) {
|
496
|
} else if (response instanceof WriteAttributesResponse) {
|
478
|
msgLog = String.format("%s: type operation: %s path: %s value: %s",
|
497
|
msgLog = String.format("%s: type operation: %s path: %s value: %s",
|
479
|
LOG_LW2M_INFO, WRITE_ATTRIBUTES.name(), request.getPath().toString(), ((WriteAttributesRequest) request).getAttributes().toString());
|
498
|
LOG_LW2M_INFO, WRITE_ATTRIBUTES.name(), request.getPath().toString(), ((WriteAttributesRequest) request).getAttributes().toString());
|
480
|
handler.sendLogsToThingsboard(msgLog, registration.getId());
|
499
|
handler.sendLogsToThingsboard(msgLog, registration.getId());
|
481
|
- log.warn("[{}] Path [{}] WriteAttributesResponse 8_Send", pathIdVer, response);
|
500
|
+ log.warn("12) [{}] Path [{}] WriteAttributesResponse", pathIdVer, response);
|
482
|
if (rpcRequest != null) {
|
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
|
} else if (response instanceof WriteResponse) {
|
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
|
handler.onWriteResponseOk(registration, pathIdVer, (WriteRequest) request);
|
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
|
try {
|
513
|
try {
|
504
|
LwM2mNode node = ((WriteRequest) request).getNode();
|
514
|
LwM2mNode node = ((WriteRequest) request).getNode();
|
505
|
String msg = null;
|
515
|
String msg = null;
|
|
@@ -517,12 +527,12 @@ public class LwM2mTransportRequest { |
|
@@ -517,12 +527,12 @@ public class LwM2mTransportRequest { |
517
|
if (singleResource.getType() == ResourceModel.Type.STRING) {
|
527
|
if (singleResource.getType() == ResourceModel.Type.STRING) {
|
518
|
valueLength = ((String) singleResource.getValue()).length();
|
528
|
valueLength = ((String) singleResource.getValue()).length();
|
519
|
value = ((String) singleResource.getValue())
|
529
|
value = ((String) singleResource.getValue())
|
520
|
- .substring(Math.min(valueLength, config.getLogMaxLength()));
|
530
|
+ .substring(Math.min(valueLength, config.getLogMaxLength())).trim();
|
521
|
|
531
|
|
522
|
} else {
|
532
|
} else {
|
523
|
valueLength = ((byte[]) singleResource.getValue()).length;
|
533
|
valueLength = ((byte[]) singleResource.getValue()).length;
|
524
|
value = new String(Arrays.copyOf(((byte[]) singleResource.getValue()),
|
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
|
value = valueLength > config.getLogMaxLength() ? value + "..." : value;
|
537
|
value = valueLength > config.getLogMaxLength() ? value + "..." : value;
|
528
|
msg = String.format("%s: Update finished successfully: Lwm2m code - %d Resource path: %s length: %s value: %s",
|
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,6 +548,12 @@ public class LwM2mTransportRequest { |
538
|
handler.sendLogsToThingsboard(msg, registration.getId());
|
548
|
handler.sendLogsToThingsboard(msg, registration.getId());
|
539
|
if (request.getPath().toString().equals(FW_PACKAGE_ID) || request.getPath().toString().equals(SW_PACKAGE_ID)) {
|
549
|
if (request.getPath().toString().equals(FW_PACKAGE_ID) || request.getPath().toString().equals(SW_PACKAGE_ID)) {
|
540
|
this.afterWriteSuccessFwSwUpdate(registration, request);
|
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
|
} catch (Exception e) {
|
559
|
} catch (Exception e) {
|
|
@@ -558,7 +574,7 @@ public class LwM2mTransportRequest { |
|
@@ -558,7 +574,7 @@ public class LwM2mTransportRequest { |
558
|
}
|
574
|
}
|
559
|
if (request.getPath().toString().equals(SW_PACKAGE_ID) && lwM2MClient.getSwUpdate() != null) {
|
575
|
if (request.getPath().toString().equals(SW_PACKAGE_ID) && lwM2MClient.getSwUpdate() != null) {
|
560
|
lwM2MClient.getSwUpdate().setStateUpdate(DOWNLOADED.name());
|
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,7 +608,7 @@ public class LwM2mTransportRequest { |
592
|
log.warn("[{}]", observeCancelMsg);
|
608
|
log.warn("[{}]", observeCancelMsg);
|
593
|
if (rpcRequest != null) {
|
609
|
if (rpcRequest != null) {
|
594
|
rpcRequest.setInfoMsg(String.format("Count: %d", observeCancelCnt));
|
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
|
} |