Merge branch 'develop/3.2' of github.com:thingsboard/thingsboard into develop/3.2

This commit is contained in:
Igor Kulikov 2020-09-07 14:45:56 +03:00
commit 192fa0796e
4 changed files with 10 additions and 3 deletions

View File

@ -514,7 +514,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement
ctx.close(); ctx.close();
} else { } else {
deviceSessionCtx.setDeviceInfo(msg.getDeviceInfo()); deviceSessionCtx.setDeviceInfo(msg.getDeviceInfo());
// deviceSessionCtx.setProfile(msg.getDeviceProfile()); deviceSessionCtx.setDeviceProfile(msg.getDeviceProfile());
sessionInfo = SessionInfoCreator.create(msg, context, sessionId); sessionInfo = SessionInfoCreator.create(msg, context, sessionId);
transportService.process(sessionInfo, DefaultTransportService.getSessionEventMsg(SessionEvent.OPEN), new TransportServiceCallback<Void>() { transportService.process(sessionInfo, DefaultTransportService.getSessionEventMsg(SessionEvent.OPEN), new TransportServiceCallback<Void>() {
@Override @Override

View File

@ -35,7 +35,7 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple
private final GatewaySessionHandler parent; private final GatewaySessionHandler parent;
private volatile SessionInfoProto sessionInfo; private volatile SessionInfoProto sessionInfo;
public GatewayDeviceSessionCtx(GatewaySessionHandler parent, TransportDeviceInfo deviceInfo, ConcurrentMap<MqttTopicMatcher, Integer> mqttQoSMap) { public GatewayDeviceSessionCtx(GatewaySessionHandler parent, TransportDeviceInfo deviceInfo, DeviceProfile deviceProfile, ConcurrentMap<MqttTopicMatcher, Integer> mqttQoSMap) {
super(UUID.randomUUID(), mqttQoSMap); super(UUID.randomUUID(), mqttQoSMap);
this.parent = parent; this.parent = parent;
this.sessionInfo = SessionInfoProto.newBuilder() this.sessionInfo = SessionInfoProto.newBuilder()
@ -54,6 +54,7 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple
.setDeviceProfileIdLSB(deviceInfo.getDeviceProfileId().getId().getLeastSignificantBits()) .setDeviceProfileIdLSB(deviceInfo.getDeviceProfileId().getId().getLeastSignificantBits())
.build(); .build();
setDeviceInfo(deviceInfo); setDeviceInfo(deviceInfo);
setDeviceProfile(deviceProfile);
} }
@Override @Override

View File

@ -147,7 +147,7 @@ public class GatewaySessionHandler {
new TransportServiceCallback<GetOrCreateDeviceFromGatewayResponse>() { new TransportServiceCallback<GetOrCreateDeviceFromGatewayResponse>() {
@Override @Override
public void onSuccess(GetOrCreateDeviceFromGatewayResponse msg) { public void onSuccess(GetOrCreateDeviceFromGatewayResponse msg) {
GatewayDeviceSessionCtx deviceSessionCtx = new GatewayDeviceSessionCtx(GatewaySessionHandler.this, msg.getDeviceInfo(), mqttQoSMap); GatewayDeviceSessionCtx deviceSessionCtx = new GatewayDeviceSessionCtx(GatewaySessionHandler.this, msg.getDeviceInfo(), msg.getDeviceProfile(), mqttQoSMap);
if (devices.putIfAbsent(deviceName, deviceSessionCtx) == null) { if (devices.putIfAbsent(deviceName, deviceSessionCtx) == null) {
log.trace("[{}] First got or created device [{}], type [{}] for the gateway session", sessionId, deviceName, deviceType); log.trace("[{}] First got or created device [{}], type [{}] for the gateway session", sessionId, deviceName, deviceType);
SessionInfoProto deviceSessionInfo = deviceSessionCtx.getSessionInfo(); SessionInfoProto deviceSessionInfo = deviceSessionCtx.getSessionInfo();

View File

@ -17,6 +17,8 @@ package org.thingsboard.server.common.transport.session;
import lombok.Data; import lombok.Data;
import lombok.Getter; import lombok.Getter;
import lombok.Setter;
import org.thingsboard.server.common.data.DeviceProfile;
import org.thingsboard.server.common.data.id.DeviceId; import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.msg.session.SessionContext; import org.thingsboard.server.common.msg.session.SessionContext;
import org.thingsboard.server.common.transport.auth.TransportDeviceInfo; import org.thingsboard.server.common.transport.auth.TransportDeviceInfo;
@ -36,6 +38,10 @@ public abstract class DeviceAwareSessionContext implements SessionContext {
private volatile DeviceId deviceId; private volatile DeviceId deviceId;
@Getter @Getter
protected volatile TransportDeviceInfo deviceInfo; protected volatile TransportDeviceInfo deviceInfo;
@Getter
@Setter
protected volatile DeviceProfile deviceProfile;
private volatile boolean connected; private volatile boolean connected;
public DeviceId getDeviceId() { public DeviceId getDeviceId() {