Commit 612532bbd9038f43e67bf031d5a56145019ca87e
Committed by
Andrew Shvayka
1 parent
9552ab05
Lwm2m: back: fix bug final and pom
Showing
6 changed files
with
27 additions
and
25 deletions
@@ -166,13 +166,13 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { | @@ -166,13 +166,13 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { | ||
166 | if (this.getValidatedSecurityMode(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap, lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer)) { | 166 | if (this.getValidatedSecurityMode(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap, lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer)) { |
167 | lwM2MBootstrapConfig.bootstrapServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap); | 167 | lwM2MBootstrapConfig.bootstrapServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap); |
168 | lwM2MBootstrapConfig.lwm2mServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer); | 168 | lwM2MBootstrapConfig.lwm2mServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer); |
169 | - String logMsg = String.format(LOG_LW2M_INFO + ": getParametersBootstrap: %s Access connect client with bootstrap server.", store.getEndPoint()); | 169 | + String logMsg = String.format("%s: getParametersBootstrap: %s Access connect client with bootstrap server.", LOG_LW2M_INFO, store.getEndPoint()); |
170 | context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo); | 170 | context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo); |
171 | return lwM2MBootstrapConfig; | 171 | return lwM2MBootstrapConfig; |
172 | } else { | 172 | } else { |
173 | log.error(" [{}] Different values SecurityMode between of client and profile.", store.getEndPoint()); | 173 | log.error(" [{}] Different values SecurityMode between of client and profile.", store.getEndPoint()); |
174 | - log.error(LOG_LW2M_ERROR + " getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", store.getEndPoint()); | ||
175 | - String logMsg = String.format(LOG_LW2M_ERROR + ": getParametersBootstrap: %s Different values SecurityMode between of client and profile.", store.getEndPoint()); | 174 | + log.error("{} getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", LOG_LW2M_ERROR, store.getEndPoint()); |
175 | + String logMsg = String.format("%s: getParametersBootstrap: %s Different values SecurityMode between of client and profile.", LOG_LW2M_ERROR, store.getEndPoint()); | ||
176 | context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo); | 176 | context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo); |
177 | return null; | 177 | return null; |
178 | } | 178 | } |
@@ -188,6 +188,7 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { | @@ -188,6 +188,7 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { | ||
188 | /** | 188 | /** |
189 | * Bootstrap security have to sync between (bootstrapServer in credential and bootstrapServer in profile) | 189 | * Bootstrap security have to sync between (bootstrapServer in credential and bootstrapServer in profile) |
190 | * and (lwm2mServer in credential and lwm2mServer in profile | 190 | * and (lwm2mServer in credential and lwm2mServer in profile |
191 | + * | ||
191 | * @param bootstrapFromCredential - Bootstrap -> Security of bootstrapServer in credential | 192 | * @param bootstrapFromCredential - Bootstrap -> Security of bootstrapServer in credential |
192 | * @param profileServerBootstrap - Bootstrap -> Security of bootstrapServer in profile | 193 | * @param profileServerBootstrap - Bootstrap -> Security of bootstrapServer in profile |
193 | * @param lwm2mFromCredential - Bootstrap -> Security of lwm2mServer in credential | 194 | * @param lwm2mFromCredential - Bootstrap -> Security of lwm2mServer in credential |
@@ -39,7 +39,6 @@ import org.eclipse.leshan.core.response.DeleteResponse; | @@ -39,7 +39,6 @@ import org.eclipse.leshan.core.response.DeleteResponse; | ||
39 | import org.eclipse.leshan.core.response.DiscoverResponse; | 39 | import org.eclipse.leshan.core.response.DiscoverResponse; |
40 | import org.eclipse.leshan.core.response.ExecuteResponse; | 40 | import org.eclipse.leshan.core.response.ExecuteResponse; |
41 | import org.eclipse.leshan.core.response.LwM2mResponse; | 41 | import org.eclipse.leshan.core.response.LwM2mResponse; |
42 | -import org.eclipse.leshan.core.response.ObserveResponse; | ||
43 | import org.eclipse.leshan.core.response.ReadResponse; | 42 | import org.eclipse.leshan.core.response.ReadResponse; |
44 | import org.eclipse.leshan.core.response.ResponseCallback; | 43 | import org.eclipse.leshan.core.response.ResponseCallback; |
45 | import org.eclipse.leshan.core.response.WriteAttributesResponse; | 44 | import org.eclipse.leshan.core.response.WriteAttributesResponse; |
@@ -242,15 +241,15 @@ public class LwM2MTransportRequest { | @@ -242,15 +241,15 @@ public class LwM2MTransportRequest { | ||
242 | if (isSuccess(((Response) response.getCoapResponse()).getCode())) { | 241 | if (isSuccess(((Response) response.getCoapResponse()).getCode())) { |
243 | this.handleResponse(registration, request.getPath().toString(), response, request); | 242 | this.handleResponse(registration, request.getPath().toString(), response, request); |
244 | if (request instanceof WriteRequest && ((WriteRequest) request).isReplaceRequest()) { | 243 | if (request instanceof WriteRequest && ((WriteRequest) request).isReplaceRequest()) { |
245 | - String msg = String.format(LOG_LW2M_INFO + ": sendRequest Replace: CoapCde - %s Lwm2m code - %d name - %s Resource path - %s value - %s SendRequest to Client", | ||
246 | - ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString(), | 244 | + String msg = String.format("%s: sendRequest Replace: CoapCde - %s Lwm2m code - %d name - %s Resource path - %s value - %s SendRequest to Client", |
245 | + LOG_LW2M_INFO, ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString(), | ||
247 | ((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue().toString()); | 246 | ((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue().toString()); |
248 | service.sentLogsToThingsboard(msg, registration); | 247 | service.sentLogsToThingsboard(msg, registration); |
249 | log.info("[{}] [{}] - [{}] [{}] Update SendRequest[{}]", registration.getEndpoint(), ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString(), | 248 | log.info("[{}] [{}] - [{}] [{}] Update SendRequest[{}]", registration.getEndpoint(), ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString(), |
250 | ((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue()); | 249 | ((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue()); |
251 | } | 250 | } |
252 | } else { | 251 | } else { |
253 | - String msg = String.format(LOG_LW2M_ERROR + ": sendRequest: CoapCode - %s Lwm2m code - %d name - %s Resource path - %s SendRequest to Client", | 252 | + String msg = String.format("%s: sendRequest: CoapCode - %s Lwm2m code - %d name - %s Resource path - %s SendRequest to Client", LOG_LW2M_ERROR, |
254 | ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString()); | 253 | ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString()); |
255 | service.sentLogsToThingsboard(msg, registration); | 254 | service.sentLogsToThingsboard(msg, registration); |
256 | log.error("[{}] - [{}] [{}] error SendRequest", ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString()); | 255 | log.error("[{}] - [{}] [{}] error SendRequest", ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString()); |
@@ -259,8 +258,8 @@ public class LwM2MTransportRequest { | @@ -259,8 +258,8 @@ public class LwM2MTransportRequest { | ||
259 | if (!lwM2MClient.isInit()) { | 258 | if (!lwM2MClient.isInit()) { |
260 | lwM2MClient.initValue(this.service, request.getPath().toString()); | 259 | lwM2MClient.initValue(this.service, request.getPath().toString()); |
261 | } | 260 | } |
262 | - String msg = String.format(LOG_LW2M_ERROR + ": sendRequest: Resource path - %s msg error - %s SendRequest to Client", | ||
263 | - request.getPath().toString(), e.toString()); | 261 | + String msg = String.format("%s: sendRequest: Resource path - %s msg error - %s SendRequest to Client", |
262 | + LOG_LW2M_ERROR, request.getPath().toString(), e.toString()); | ||
264 | service.sentLogsToThingsboard(msg, registration); | 263 | service.sentLogsToThingsboard(msg, registration); |
265 | log.error("[{}] - [{}] error SendRequest", request.getPath().toString(), e.toString()); | 264 | log.error("[{}] - [{}] error SendRequest", request.getPath().toString(), e.toString()); |
266 | }); | 265 | }); |
@@ -314,7 +313,7 @@ public class LwM2MTransportRequest { | @@ -314,7 +313,7 @@ public class LwM2MTransportRequest { | ||
314 | * @param response - | 313 | * @param response - |
315 | */ | 314 | */ |
316 | private void sendResponse(Registration registration, String path, LwM2mResponse response, DownlinkRequest request) { | 315 | private void sendResponse(Registration registration, String path, LwM2mResponse response, DownlinkRequest request) { |
317 | - if (response instanceof ObserveResponse || response instanceof ReadResponse) { | 316 | + if (response instanceof ReadResponse) { |
318 | service.onObservationResponse(registration, path, (ReadResponse) response); | 317 | service.onObservationResponse(registration, path, (ReadResponse) response); |
319 | } else if (response instanceof CancelObservationResponse) { | 318 | } else if (response instanceof CancelObservationResponse) { |
320 | log.info("[{}] Path [{}] CancelObservationResponse 3_Send", path, response); | 319 | log.info("[{}] Path [{}] CancelObservationResponse 3_Send", path, response); |
@@ -300,12 +300,14 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { | @@ -300,12 +300,14 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { | ||
300 | ContentFormat.TLV.getName(), null, value, this.context.getCtxServer().getTimeout()); | 300 | ContentFormat.TLV.getName(), null, value, this.context.getCtxServer().getTimeout()); |
301 | } else { | 301 | } else { |
302 | log.error("Resource path - [{}] value - [{}] is not Writable and cannot be updated", path, value); | 302 | log.error("Resource path - [{}] value - [{}] is not Writable and cannot be updated", path, value); |
303 | - String logMsg = String.format(LOG_LW2M_ERROR + ": attributeUpdate: Resource path - %s value - %s is not Writable and cannot be updated", path, value); | 303 | + String logMsg = String.format("%s: attributeUpdate: Resource path - %s value - %s is not Writable and cannot be updated", |
304 | + LOG_LW2M_ERROR, path, value); | ||
304 | this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration()); | 305 | this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration()); |
305 | } | 306 | } |
306 | } else { | 307 | } else { |
307 | log.error("Attribute name - [{}] value - [{}] is not present as attribute in profile and cannot be updated", de.getKey(), value); | 308 | log.error("Attribute name - [{}] value - [{}] is not present as attribute in profile and cannot be updated", de.getKey(), value); |
308 | - String logMsg = String.format(LOG_LW2M_ERROR + ": attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated", de.getKey(), value); | 309 | + String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated", |
310 | + LOG_LW2M_ERROR, de.getKey(), value); | ||
309 | this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration()); | 311 | this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration()); |
310 | } | 312 | } |
311 | }); | 313 | }); |
@@ -581,7 +583,8 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { | @@ -581,7 +583,8 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { | ||
581 | * Start observe/read: Attr/Telemetry | 583 | * Start observe/read: Attr/Telemetry |
582 | * #1 - Analyze: | 584 | * #1 - Analyze: |
583 | * #1.1 path in resource profile == client resource | 585 | * #1.1 path in resource profile == client resource |
584 | - * @param lwServer - | 586 | + * |
587 | + * @param lwServer - | ||
585 | * @param registration - | 588 | * @param registration - |
586 | */ | 589 | */ |
587 | private void initReadAttrTelemetryObserveToClient(LeshanServer lwServer, Registration registration, LwM2MClient lwM2MClient, String typeOper) { | 590 | private void initReadAttrTelemetryObserveToClient(LeshanServer lwServer, Registration registration, LwM2MClient lwM2MClient, String typeOper) { |
@@ -592,8 +595,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { | @@ -592,8 +595,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { | ||
592 | if (GET_TYPE_OPER_READ.equals(typeOper)) { | 595 | if (GET_TYPE_OPER_READ.equals(typeOper)) { |
593 | result = new ObjectMapper().readValue(lwM2MClientProfile.getPostAttributeProfile().getAsJsonArray().toString().getBytes(), Set.class); | 596 | result = new ObjectMapper().readValue(lwM2MClientProfile.getPostAttributeProfile().getAsJsonArray().toString().getBytes(), Set.class); |
594 | result.addAll(new ObjectMapper().readValue(lwM2MClientProfile.getPostTelemetryProfile().getAsJsonArray().toString().getBytes(), Set.class)); | 597 | result.addAll(new ObjectMapper().readValue(lwM2MClientProfile.getPostTelemetryProfile().getAsJsonArray().toString().getBytes(), Set.class)); |
595 | - } | ||
596 | - else { | 598 | + } else { |
597 | result = new ObjectMapper().readValue(lwM2MClientProfile.getPostObserveProfile().getAsJsonArray().toString().getBytes(), Set.class); | 599 | result = new ObjectMapper().readValue(lwM2MClientProfile.getPostObserveProfile().getAsJsonArray().toString().getBytes(), Set.class); |
598 | } | 600 | } |
599 | Set<String> pathSent = ConcurrentHashMap.newKeySet(); | 601 | Set<String> pathSent = ConcurrentHashMap.newKeySet(); |
@@ -49,10 +49,10 @@ public class LwM2MClient implements Cloneable { | @@ -49,10 +49,10 @@ public class LwM2MClient implements Cloneable { | ||
49 | private LwM2MTransportServiceImpl lwM2MTransportServiceImpl; | 49 | private LwM2MTransportServiceImpl lwM2MTransportServiceImpl; |
50 | private Registration registration; | 50 | private Registration registration; |
51 | private ValidateDeviceCredentialsResponseMsg credentialsResponse; | 51 | private ValidateDeviceCredentialsResponseMsg credentialsResponse; |
52 | - private Map<String, String> attributes; | ||
53 | - private Map<String, ResourceValue> resources; | ||
54 | - private Map<String, TransportProtos.TsKvProto> delayedRequests; | ||
55 | - private List<String> pendingRequests; | 52 | + private final Map<String, String> attributes; |
53 | + private final Map<String, ResourceValue> resources; | ||
54 | + private final Map<String, TransportProtos.TsKvProto> delayedRequests; | ||
55 | + private final List<String> pendingRequests; | ||
56 | private boolean init; | 56 | private boolean init; |
57 | private final LwM2mValueConverterImpl converter; | 57 | private final LwM2mValueConverterImpl converter; |
58 | 58 |
@@ -168,7 +168,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore { | @@ -168,7 +168,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore { | ||
168 | LwM2MClient lwM2MClient = this.sessions.get(registration.getEndpoint()); | 168 | LwM2MClient lwM2MClient = this.sessions.get(registration.getEndpoint()); |
169 | lwM2MClient.setLwServer(lwServer); | 169 | lwM2MClient.setLwServer(lwServer); |
170 | lwM2MClient.setRegistration(registration); | 170 | lwM2MClient.setRegistration(registration); |
171 | - lwM2MClient.setAttributes(registration.getAdditionalRegistrationAttributes()); | 171 | + lwM2MClient.getAttributes().putAll(registration.getAdditionalRegistrationAttributes()); |
172 | this.sessions.remove(registration.getEndpoint()); | 172 | this.sessions.remove(registration.getEndpoint()); |
173 | this.sessions.put(registration.getId(), lwM2MClient); | 173 | this.sessions.put(registration.getId(), lwM2MClient); |
174 | return lwM2MClient; | 174 | return lwM2MClient; |
@@ -625,11 +625,11 @@ | @@ -625,11 +625,11 @@ | ||
625 | <artifactId>maven-install-plugin</artifactId> | 625 | <artifactId>maven-install-plugin</artifactId> |
626 | <version>3.0.0-M1</version> | 626 | <version>3.0.0-M1</version> |
627 | </plugin> | 627 | </plugin> |
628 | - <plugin> | ||
629 | - <groupId>org.apache.maven.plugins</groupId> | ||
630 | - <artifactId>maven-deploy-plugin</artifactId> | ||
631 | - <version>3.0.0-M1</version> | ||
632 | - </plugin> | 628 | +<!-- <plugin>--> |
629 | +<!-- <groupId>org.apache.maven.plugins</groupId>--> | ||
630 | +<!-- <artifactId>maven-deploy-plugin</artifactId>--> | ||
631 | +<!-- <version>3.0.0-M1</version>--> | ||
632 | +<!-- </plugin>--> | ||
633 | <plugin> | 633 | <plugin> |
634 | <groupId>org.apache.maven.plugins</groupId> | 634 | <groupId>org.apache.maven.plugins</groupId> |
635 | <artifactId>maven-dependency-plugin</artifactId> | 635 | <artifactId>maven-dependency-plugin</artifactId> |