From 40659a2087f97e023146c12d1440cc31756b7983 Mon Sep 17 00:00:00 2001 From: Andrii Shvaika Date: Fri, 25 Jun 2021 19:12:43 +0300 Subject: [PATCH] LwM2M client profile --- .../uplink/DefaultLwM2MUplinkMsgHandler.java | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java index ff22cca3f7..56dad43db7 100644 --- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java +++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java @@ -353,21 +353,28 @@ public class DefaultLwM2MUplinkMsgHandler extends LwM2MExecutorAwareService impl */ @Override public void onDeviceProfileUpdate(SessionInfoProto sessionInfo, DeviceProfile deviceProfile) { - List clients = clientContext.getLwM2mClients() - .stream().filter(e -> e.getProfileId() != null) - .filter(e -> e.getProfileId().equals(deviceProfile.getUuidId())).collect(Collectors.toList()); - clients.forEach(client -> client.onDeviceProfileUpdate(deviceProfile)); - if (clients.size() > 0) { - this.onDeviceProfileUpdate(clients, deviceProfile); + try { + List clients = clientContext.getLwM2mClients() + .stream().filter(e -> e.getProfileId() != null) + .filter(e -> e.getProfileId().equals(deviceProfile.getUuidId())).collect(Collectors.toList()); + clients.forEach(client -> client.onDeviceProfileUpdate(deviceProfile)); + if (clients.size() > 0) { + this.onDeviceProfileUpdate(clients, deviceProfile); + } + } catch (Exception e) { + log.warn("[{}] failed to update profile: {}", deviceProfile.getId(), deviceProfile); } } @Override public void onDeviceUpdate(SessionInfoProto sessionInfo, Device device, Optional deviceProfileOpt) { - //TODO: check, maybe device has multiple sessions/registrations? Is this possible according to the standard. - LwM2mClient client = clientContext.getClientByDeviceId(device.getUuidId()); - if (client != null) { - this.onDeviceUpdate(client, device, deviceProfileOpt); + try { + LwM2mClient client = clientContext.getClientByDeviceId(device.getUuidId()); + if (client != null) { + this.onDeviceUpdate(client, device, deviceProfileOpt); + } + } catch (Exception e) { + log.warn("[{}] failed to update device: {}", device.getId(), device); } }