Browse Source

LwM2M client profile

pull/4800/head
Andrii Shvaika 5 years ago
parent
commit
40659a2087
  1. 27
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/uplink/DefaultLwM2MUplinkMsgHandler.java

27
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 @Override
public void onDeviceProfileUpdate(SessionInfoProto sessionInfo, DeviceProfile deviceProfile) { public void onDeviceProfileUpdate(SessionInfoProto sessionInfo, DeviceProfile deviceProfile) {
List<LwM2mClient> clients = clientContext.getLwM2mClients() try {
.stream().filter(e -> e.getProfileId() != null) List<LwM2mClient> clients = clientContext.getLwM2mClients()
.filter(e -> e.getProfileId().equals(deviceProfile.getUuidId())).collect(Collectors.toList()); .stream().filter(e -> e.getProfileId() != null)
clients.forEach(client -> client.onDeviceProfileUpdate(deviceProfile)); .filter(e -> e.getProfileId().equals(deviceProfile.getUuidId())).collect(Collectors.toList());
if (clients.size() > 0) { clients.forEach(client -> client.onDeviceProfileUpdate(deviceProfile));
this.onDeviceProfileUpdate(clients, deviceProfile); if (clients.size() > 0) {
this.onDeviceProfileUpdate(clients, deviceProfile);
}
} catch (Exception e) {
log.warn("[{}] failed to update profile: {}", deviceProfile.getId(), deviceProfile);
} }
} }
@Override @Override
public void onDeviceUpdate(SessionInfoProto sessionInfo, Device device, Optional<DeviceProfile> deviceProfileOpt) { public void onDeviceUpdate(SessionInfoProto sessionInfo, Device device, Optional<DeviceProfile> deviceProfileOpt) {
//TODO: check, maybe device has multiple sessions/registrations? Is this possible according to the standard. try {
LwM2mClient client = clientContext.getClientByDeviceId(device.getUuidId()); LwM2mClient client = clientContext.getClientByDeviceId(device.getUuidId());
if (client != null) { if (client != null) {
this.onDeviceUpdate(client, device, deviceProfileOpt); this.onDeviceUpdate(client, device, deviceProfileOpt);
}
} catch (Exception e) {
log.warn("[{}] failed to update device: {}", device.getId(), device);
} }
} }

Loading…
Cancel
Save