lwm2m: front/back fix bug update profile

This commit is contained in:
nickAS21 2021-03-29 12:50:50 +03:00
parent 23373b055e
commit 2fcf5fd7c6
2 changed files with 10 additions and 10 deletions

View File

@ -109,14 +109,15 @@ public class LwM2mTransportRequest {
* Device management and service enablement, including Read, Write, Execute, Discover, Create, Delete and Write-Attributes * Device management and service enablement, including Read, Write, Execute, Discover, Create, Delete and Write-Attributes
* *
* @param registration - * @param registration -
* @param target - * @param targetIdVer -
* @param typeOper - * @param typeOper -
* @param contentFormatParam - * @param contentFormatParam -
* @param observation - * @param observation -
*/ */
public void sendAllRequest(Registration registration, String target, String typeOper, public void sendAllRequest(Registration registration, String targetIdVer, String typeOper,
String contentFormatParam, Observation observation, Object params, long timeoutInMs) { String contentFormatParam, Observation observation, Object params, long timeoutInMs) {
LwM2mPath resultIds = new LwM2mPath(convertToObjectIdFromIdVer(target)); String target = convertToObjectIdFromIdVer(targetIdVer);
LwM2mPath resultIds = new LwM2mPath(target);
if (registration != null && resultIds.getObjectId() >= 0) { if (registration != null && resultIds.getObjectId() >= 0) {
DownlinkRequest request = null; DownlinkRequest request = null;
ContentFormat contentFormat = contentFormatParam != null ? ContentFormat.fromName(contentFormatParam.toUpperCase()) : null; ContentFormat contentFormat = contentFormatParam != null ? ContentFormat.fromName(contentFormatParam.toUpperCase()) : null;
@ -221,7 +222,7 @@ public class LwM2mTransportRequest {
this.sendRequest(registration, lwM2MClient, request, timeoutInMs); this.sendRequest(registration, lwM2MClient, request, timeoutInMs);
} }
else { else {
log.error("[{}], [{}] - [{}] error SendRequest", registration.getEndpoint(), typeOper, target); log.error("[{}], [{}] - [{}] error SendRequest", registration.getEndpoint(), typeOper, targetIdVer);
} }
} }
} }

View File

@ -360,7 +360,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
*/ */
@Override @Override
public void onResourceUpdate (Optional<TransportProtos.ResourceUpdateMsg> resourceUpdateMsgOpt) { public void onResourceUpdate (Optional<TransportProtos.ResourceUpdateMsg> resourceUpdateMsgOpt) {
String idVer = resourceUpdateMsgOpt.get().getResourceKey(); // 19_1.0 String idVer = resourceUpdateMsgOpt.get().getResourceKey();
lwM2mClientContext.getLwM2mClients().values().stream().forEach(e -> e.updateResourceModel(idVer, this.lwM2mTransportContextServer.getLwM2MTransportConfigServer().getModelProvider())); lwM2mClientContext.getLwM2mClients().values().stream().forEach(e -> e.updateResourceModel(idVer, this.lwM2mTransportContextServer.getLwM2MTransportConfigServer().getModelProvider()));
} }
@ -370,7 +370,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
*/ */
@Override @Override
public void onResourceDelete(Optional<TransportProtos.ResourceDeleteMsg> resourceDeleteMsgOpt) { public void onResourceDelete(Optional<TransportProtos.ResourceDeleteMsg> resourceDeleteMsgOpt) {
String pathIdVer = resourceDeleteMsgOpt.get().getResourceKey(); // 19_1.0 String pathIdVer = resourceDeleteMsgOpt.get().getResourceKey();
lwM2mClientContext.getLwM2mClients().values().stream().forEach(e -> e.deleteResources(pathIdVer, this.lwM2mTransportContextServer.getLwM2MTransportConfigServer().getModelProvider())); lwM2mClientContext.getLwM2mClients().values().stream().forEach(e -> e.deleteResources(pathIdVer, this.lwM2mTransportContextServer.getLwM2MTransportConfigServer().getModelProvider()));
} }
@ -537,8 +537,7 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
Set<String> paths = new HashSet<>(); Set<String> paths = new HashSet<>();
paths.add(path); paths.add(path);
this.updateAttrTelemetry(registration, paths); this.updateAttrTelemetry(registration, paths);
} } else {
else {
log.error("Fail update Resource [{}]", lwM2mResource); log.error("Fail update Resource [{}]", lwM2mResource);
} }
} }
@ -574,7 +573,8 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
private boolean validatePathInAttrProfile(LwM2mClientProfile clientProfile, String path) { private boolean validatePathInAttrProfile(LwM2mClientProfile clientProfile, String path) {
try { try {
List<String> attributesSet = new Gson().fromJson(clientProfile.getPostAttributeProfile(), List<String> attributesSet = new Gson().fromJson(clientProfile.getPostAttributeProfile(),
new TypeToken<List<String>>() {}.getType()); new TypeToken<List<String>>() {
}.getType());
return attributesSet.stream().anyMatch(p -> p.equals(path)); return attributesSet.stream().anyMatch(p -> p.equals(path));
} catch (Exception e) { } catch (Exception e) {
log.error("Fail Validate Path [{}] ClientProfile.Attribute", path, e); log.error("Fail Validate Path [{}] ClientProfile.Attribute", path, e);
@ -830,7 +830,6 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService {
if (sendAttrToThingsboard.getPathPostParametersAdd().size() > 0) { if (sendAttrToThingsboard.getPathPostParametersAdd().size() > 0) {
// update value in Resources // update value in Resources
registrationIds.forEach(registrationId -> { registrationIds.forEach(registrationId -> {
// LeshanServer lwServer = leshanServer;
Registration registration = lwM2mClientContext.getRegistration(registrationId); Registration registration = lwM2mClientContext.getRegistration(registrationId);
this.readResourceValueObserve(registration, sendAttrToThingsboard.getPathPostParametersAdd(), GET_TYPE_OPER_READ); this.readResourceValueObserve(registration, sendAttrToThingsboard.getPathPostParametersAdd(), GET_TYPE_OPER_READ);
// send attr/telemetry to tingsboard for new path // send attr/telemetry to tingsboard for new path