Lwm2m: back: fix bug final and pom
This commit is contained in:
parent
9552ab0589
commit
612532bbd9
@ -166,13 +166,13 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore {
|
|||||||
if (this.getValidatedSecurityMode(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap, lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer)) {
|
if (this.getValidatedSecurityMode(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap, lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer)) {
|
||||||
lwM2MBootstrapConfig.bootstrapServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap);
|
lwM2MBootstrapConfig.bootstrapServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap);
|
||||||
lwM2MBootstrapConfig.lwm2mServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer);
|
lwM2MBootstrapConfig.lwm2mServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer);
|
||||||
String logMsg = String.format(LOG_LW2M_INFO + ": getParametersBootstrap: %s Access connect client with bootstrap server.", store.getEndPoint());
|
String logMsg = String.format("%s: getParametersBootstrap: %s Access connect client with bootstrap server.", LOG_LW2M_INFO, store.getEndPoint());
|
||||||
context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo);
|
context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo);
|
||||||
return lwM2MBootstrapConfig;
|
return lwM2MBootstrapConfig;
|
||||||
} else {
|
} else {
|
||||||
log.error(" [{}] Different values SecurityMode between of client and profile.", store.getEndPoint());
|
log.error(" [{}] Different values SecurityMode between of client and profile.", store.getEndPoint());
|
||||||
log.error(LOG_LW2M_ERROR + " getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", store.getEndPoint());
|
log.error("{} getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", LOG_LW2M_ERROR, store.getEndPoint());
|
||||||
String logMsg = String.format(LOG_LW2M_ERROR + ": getParametersBootstrap: %s Different values SecurityMode between of client and profile.", store.getEndPoint());
|
String logMsg = String.format("%s: getParametersBootstrap: %s Different values SecurityMode between of client and profile.", LOG_LW2M_ERROR, store.getEndPoint());
|
||||||
context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo);
|
context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -188,6 +188,7 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore {
|
|||||||
/**
|
/**
|
||||||
* Bootstrap security have to sync between (bootstrapServer in credential and bootstrapServer in profile)
|
* Bootstrap security have to sync between (bootstrapServer in credential and bootstrapServer in profile)
|
||||||
* and (lwm2mServer in credential and lwm2mServer in profile
|
* and (lwm2mServer in credential and lwm2mServer in profile
|
||||||
|
*
|
||||||
* @param bootstrapFromCredential - Bootstrap -> Security of bootstrapServer in credential
|
* @param bootstrapFromCredential - Bootstrap -> Security of bootstrapServer in credential
|
||||||
* @param profileServerBootstrap - Bootstrap -> Security of bootstrapServer in profile
|
* @param profileServerBootstrap - Bootstrap -> Security of bootstrapServer in profile
|
||||||
* @param lwm2mFromCredential - Bootstrap -> Security of lwm2mServer in credential
|
* @param lwm2mFromCredential - Bootstrap -> Security of lwm2mServer in credential
|
||||||
|
|||||||
@ -39,7 +39,6 @@ import org.eclipse.leshan.core.response.DeleteResponse;
|
|||||||
import org.eclipse.leshan.core.response.DiscoverResponse;
|
import org.eclipse.leshan.core.response.DiscoverResponse;
|
||||||
import org.eclipse.leshan.core.response.ExecuteResponse;
|
import org.eclipse.leshan.core.response.ExecuteResponse;
|
||||||
import org.eclipse.leshan.core.response.LwM2mResponse;
|
import org.eclipse.leshan.core.response.LwM2mResponse;
|
||||||
import org.eclipse.leshan.core.response.ObserveResponse;
|
|
||||||
import org.eclipse.leshan.core.response.ReadResponse;
|
import org.eclipse.leshan.core.response.ReadResponse;
|
||||||
import org.eclipse.leshan.core.response.ResponseCallback;
|
import org.eclipse.leshan.core.response.ResponseCallback;
|
||||||
import org.eclipse.leshan.core.response.WriteAttributesResponse;
|
import org.eclipse.leshan.core.response.WriteAttributesResponse;
|
||||||
@ -242,15 +241,15 @@ public class LwM2MTransportRequest {
|
|||||||
if (isSuccess(((Response) response.getCoapResponse()).getCode())) {
|
if (isSuccess(((Response) response.getCoapResponse()).getCode())) {
|
||||||
this.handleResponse(registration, request.getPath().toString(), response, request);
|
this.handleResponse(registration, request.getPath().toString(), response, request);
|
||||||
if (request instanceof WriteRequest && ((WriteRequest) request).isReplaceRequest()) {
|
if (request instanceof WriteRequest && ((WriteRequest) request).isReplaceRequest()) {
|
||||||
String msg = String.format(LOG_LW2M_INFO + ": sendRequest Replace: CoapCde - %s Lwm2m code - %d name - %s Resource path - %s value - %s SendRequest to Client",
|
String msg = String.format("%s: sendRequest Replace: CoapCde - %s Lwm2m code - %d name - %s Resource path - %s value - %s SendRequest to Client",
|
||||||
((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString(),
|
LOG_LW2M_INFO, ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString(),
|
||||||
((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue().toString());
|
((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue().toString());
|
||||||
service.sentLogsToThingsboard(msg, registration);
|
service.sentLogsToThingsboard(msg, registration);
|
||||||
log.info("[{}] [{}] - [{}] [{}] Update SendRequest[{}]", registration.getEndpoint(), ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString(),
|
log.info("[{}] [{}] - [{}] [{}] Update SendRequest[{}]", registration.getEndpoint(), ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString(),
|
||||||
((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue());
|
((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
String msg = String.format(LOG_LW2M_ERROR + ": sendRequest: CoapCode - %s Lwm2m code - %d name - %s Resource path - %s SendRequest to Client",
|
String msg = String.format("%s: sendRequest: CoapCode - %s Lwm2m code - %d name - %s Resource path - %s SendRequest to Client", LOG_LW2M_ERROR,
|
||||||
((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString());
|
((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString());
|
||||||
service.sentLogsToThingsboard(msg, registration);
|
service.sentLogsToThingsboard(msg, registration);
|
||||||
log.error("[{}] - [{}] [{}] error SendRequest", ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString());
|
log.error("[{}] - [{}] [{}] error SendRequest", ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString());
|
||||||
@ -259,8 +258,8 @@ public class LwM2MTransportRequest {
|
|||||||
if (!lwM2MClient.isInit()) {
|
if (!lwM2MClient.isInit()) {
|
||||||
lwM2MClient.initValue(this.service, request.getPath().toString());
|
lwM2MClient.initValue(this.service, request.getPath().toString());
|
||||||
}
|
}
|
||||||
String msg = String.format(LOG_LW2M_ERROR + ": sendRequest: Resource path - %s msg error - %s SendRequest to Client",
|
String msg = String.format("%s: sendRequest: Resource path - %s msg error - %s SendRequest to Client",
|
||||||
request.getPath().toString(), e.toString());
|
LOG_LW2M_ERROR, request.getPath().toString(), e.toString());
|
||||||
service.sentLogsToThingsboard(msg, registration);
|
service.sentLogsToThingsboard(msg, registration);
|
||||||
log.error("[{}] - [{}] error SendRequest", request.getPath().toString(), e.toString());
|
log.error("[{}] - [{}] error SendRequest", request.getPath().toString(), e.toString());
|
||||||
});
|
});
|
||||||
@ -314,7 +313,7 @@ public class LwM2MTransportRequest {
|
|||||||
* @param response -
|
* @param response -
|
||||||
*/
|
*/
|
||||||
private void sendResponse(Registration registration, String path, LwM2mResponse response, DownlinkRequest request) {
|
private void sendResponse(Registration registration, String path, LwM2mResponse response, DownlinkRequest request) {
|
||||||
if (response instanceof ObserveResponse || response instanceof ReadResponse) {
|
if (response instanceof ReadResponse) {
|
||||||
service.onObservationResponse(registration, path, (ReadResponse) response);
|
service.onObservationResponse(registration, path, (ReadResponse) response);
|
||||||
} else if (response instanceof CancelObservationResponse) {
|
} else if (response instanceof CancelObservationResponse) {
|
||||||
log.info("[{}] Path [{}] CancelObservationResponse 3_Send", path, response);
|
log.info("[{}] Path [{}] CancelObservationResponse 3_Send", path, response);
|
||||||
|
|||||||
@ -300,12 +300,14 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService {
|
|||||||
ContentFormat.TLV.getName(), null, value, this.context.getCtxServer().getTimeout());
|
ContentFormat.TLV.getName(), null, value, this.context.getCtxServer().getTimeout());
|
||||||
} else {
|
} else {
|
||||||
log.error("Resource path - [{}] value - [{}] is not Writable and cannot be updated", path, value);
|
log.error("Resource path - [{}] value - [{}] is not Writable and cannot be updated", path, value);
|
||||||
String logMsg = String.format(LOG_LW2M_ERROR + ": attributeUpdate: Resource path - %s value - %s is not Writable and cannot be updated", path, value);
|
String logMsg = String.format("%s: attributeUpdate: Resource path - %s value - %s is not Writable and cannot be updated",
|
||||||
|
LOG_LW2M_ERROR, path, value);
|
||||||
this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration());
|
this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.error("Attribute name - [{}] value - [{}] is not present as attribute in profile and cannot be updated", de.getKey(), value);
|
log.error("Attribute name - [{}] value - [{}] is not present as attribute in profile and cannot be updated", de.getKey(), value);
|
||||||
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);
|
String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated",
|
||||||
|
LOG_LW2M_ERROR, de.getKey(), value);
|
||||||
this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration());
|
this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -581,6 +583,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService {
|
|||||||
* Start observe/read: Attr/Telemetry
|
* Start observe/read: Attr/Telemetry
|
||||||
* #1 - Analyze:
|
* #1 - Analyze:
|
||||||
* #1.1 path in resource profile == client resource
|
* #1.1 path in resource profile == client resource
|
||||||
|
*
|
||||||
* @param lwServer -
|
* @param lwServer -
|
||||||
* @param registration -
|
* @param registration -
|
||||||
*/
|
*/
|
||||||
@ -592,8 +595,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService {
|
|||||||
if (GET_TYPE_OPER_READ.equals(typeOper)) {
|
if (GET_TYPE_OPER_READ.equals(typeOper)) {
|
||||||
result = new ObjectMapper().readValue(lwM2MClientProfile.getPostAttributeProfile().getAsJsonArray().toString().getBytes(), Set.class);
|
result = new ObjectMapper().readValue(lwM2MClientProfile.getPostAttributeProfile().getAsJsonArray().toString().getBytes(), Set.class);
|
||||||
result.addAll(new ObjectMapper().readValue(lwM2MClientProfile.getPostTelemetryProfile().getAsJsonArray().toString().getBytes(), Set.class));
|
result.addAll(new ObjectMapper().readValue(lwM2MClientProfile.getPostTelemetryProfile().getAsJsonArray().toString().getBytes(), Set.class));
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
result = new ObjectMapper().readValue(lwM2MClientProfile.getPostObserveProfile().getAsJsonArray().toString().getBytes(), Set.class);
|
result = new ObjectMapper().readValue(lwM2MClientProfile.getPostObserveProfile().getAsJsonArray().toString().getBytes(), Set.class);
|
||||||
}
|
}
|
||||||
Set<String> pathSent = ConcurrentHashMap.newKeySet();
|
Set<String> pathSent = ConcurrentHashMap.newKeySet();
|
||||||
|
|||||||
@ -49,10 +49,10 @@ public class LwM2MClient implements Cloneable {
|
|||||||
private LwM2MTransportServiceImpl lwM2MTransportServiceImpl;
|
private LwM2MTransportServiceImpl lwM2MTransportServiceImpl;
|
||||||
private Registration registration;
|
private Registration registration;
|
||||||
private ValidateDeviceCredentialsResponseMsg credentialsResponse;
|
private ValidateDeviceCredentialsResponseMsg credentialsResponse;
|
||||||
private Map<String, String> attributes;
|
private final Map<String, String> attributes;
|
||||||
private Map<String, ResourceValue> resources;
|
private final Map<String, ResourceValue> resources;
|
||||||
private Map<String, TransportProtos.TsKvProto> delayedRequests;
|
private final Map<String, TransportProtos.TsKvProto> delayedRequests;
|
||||||
private List<String> pendingRequests;
|
private final List<String> pendingRequests;
|
||||||
private boolean init;
|
private boolean init;
|
||||||
private final LwM2mValueConverterImpl converter;
|
private final LwM2mValueConverterImpl converter;
|
||||||
|
|
||||||
|
|||||||
@ -168,7 +168,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
|
|||||||
LwM2MClient lwM2MClient = this.sessions.get(registration.getEndpoint());
|
LwM2MClient lwM2MClient = this.sessions.get(registration.getEndpoint());
|
||||||
lwM2MClient.setLwServer(lwServer);
|
lwM2MClient.setLwServer(lwServer);
|
||||||
lwM2MClient.setRegistration(registration);
|
lwM2MClient.setRegistration(registration);
|
||||||
lwM2MClient.setAttributes(registration.getAdditionalRegistrationAttributes());
|
lwM2MClient.getAttributes().putAll(registration.getAdditionalRegistrationAttributes());
|
||||||
this.sessions.remove(registration.getEndpoint());
|
this.sessions.remove(registration.getEndpoint());
|
||||||
this.sessions.put(registration.getId(), lwM2MClient);
|
this.sessions.put(registration.getId(), lwM2MClient);
|
||||||
return lwM2MClient;
|
return lwM2MClient;
|
||||||
|
|||||||
10
pom.xml
10
pom.xml
@ -625,11 +625,11 @@
|
|||||||
<artifactId>maven-install-plugin</artifactId>
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
<version>3.0.0-M1</version>
|
<version>3.0.0-M1</version>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<!-- <plugin>-->
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<!-- <groupId>org.apache.maven.plugins</groupId>-->
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
<!-- <artifactId>maven-deploy-plugin</artifactId>-->
|
||||||
<version>3.0.0-M1</version>
|
<!-- <version>3.0.0-M1</version>-->
|
||||||
</plugin>
|
<!-- </plugin>-->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
<artifactId>maven-dependency-plugin</artifactId>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user