Commit 8090e5201e8840bfd645dc5858785234ed322d11

Authored by Andrii Shvaika
1 parent ce4ecedc

Gateway Profile update

... ... @@ -16,6 +16,7 @@
16 16 package org.thingsboard.server.transport.mqtt.session;
17 17
18 18 import lombok.extern.slf4j.Slf4j;
  19 +import org.thingsboard.server.common.data.DeviceProfile;
19 20 import org.thingsboard.server.common.transport.SessionMsgListener;
20 21 import org.thingsboard.server.common.transport.auth.TransportDeviceInfo;
21 22 import org.thingsboard.server.gen.transport.TransportProtos;
... ... @@ -32,7 +33,7 @@ import java.util.concurrent.ConcurrentMap;
32 33 public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext implements SessionMsgListener {
33 34
34 35 private final GatewaySessionHandler parent;
35   - private final SessionInfoProto sessionInfo;
  36 + private volatile SessionInfoProto sessionInfo;
36 37
37 38 public GatewayDeviceSessionCtx(GatewaySessionHandler parent, TransportDeviceInfo deviceInfo, ConcurrentMap<MqttTopicMatcher, Integer> mqttQoSMap) {
38 39 super(UUID.randomUUID(), mqttQoSMap);
... ... @@ -105,4 +106,10 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple
105 106 public void onToServerRpcResponse(TransportProtos.ToServerRpcResponseMsg toServerResponse) {
106 107 // This feature is not supported in the TB IoT Gateway yet.
107 108 }
  109 +
  110 + @Override
  111 + public void onProfileUpdate(DeviceProfile deviceProfile) {
  112 + deviceInfo.setDeviceType(deviceProfile.getName());
  113 + sessionInfo = SessionInfoProto.newBuilder().mergeFrom(sessionInfo).setDeviceType(deviceProfile.getName()).build();
  114 + }
108 115 }
... ...
... ... @@ -35,7 +35,7 @@ public abstract class DeviceAwareSessionContext implements SessionContext {
35 35 @Getter
36 36 private volatile DeviceId deviceId;
37 37 @Getter
38   - private volatile TransportDeviceInfo deviceInfo;
  38 + protected volatile TransportDeviceInfo deviceInfo;
39 39 private volatile boolean connected;
40 40
41 41 public DeviceId getDeviceId() {
... ...