|
|
@ -15,6 +15,8 @@ |
|
|
*/ |
|
|
*/ |
|
|
package org.thingsboard.server.transport.mqtt.session; |
|
|
package org.thingsboard.server.transport.mqtt.session; |
|
|
|
|
|
|
|
|
|
|
|
import com.google.gson.JsonObject; |
|
|
|
|
|
import com.google.gson.JsonParser; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
import org.thingsboard.server.common.transport.SessionMsgListener; |
|
|
import org.thingsboard.server.common.transport.SessionMsgListener; |
|
|
@ -37,6 +39,14 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple |
|
|
DeviceProfile deviceProfile, ConcurrentMap<MqttTopicMatcher, Integer> mqttQoSMap) { |
|
|
DeviceProfile deviceProfile, ConcurrentMap<MqttTopicMatcher, Integer> mqttQoSMap) { |
|
|
super(UUID.randomUUID(), mqttQoSMap); |
|
|
super(UUID.randomUUID(), mqttQoSMap); |
|
|
this.parent = parent; |
|
|
this.parent = parent; |
|
|
|
|
|
JsonParser parser = new JsonParser(); |
|
|
|
|
|
boolean activityTimeFromGatewayDevice = Boolean.FALSE; |
|
|
|
|
|
if ("null".equals(this.parent.getDeviceInfo().getAdditionalInfo())) { |
|
|
|
|
|
JsonObject additionalInfo = parser.parse(this.parent.getDeviceInfo().getAdditionalInfo()).getAsJsonObject(); |
|
|
|
|
|
if (additionalInfo.get("activityTimeFromGatewayDevice") != null) { |
|
|
|
|
|
activityTimeFromGatewayDevice = additionalInfo.get("activityTimeFromGatewayDevice").getAsBoolean(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
setSessionInfo(SessionInfoProto.newBuilder() |
|
|
setSessionInfo(SessionInfoProto.newBuilder() |
|
|
.setNodeId(parent.getNodeId()) |
|
|
.setNodeId(parent.getNodeId()) |
|
|
.setSessionIdMSB(sessionId.getMostSignificantBits()) |
|
|
.setSessionIdMSB(sessionId.getMostSignificantBits()) |
|
|
@ -51,6 +61,7 @@ public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext imple |
|
|
.setGwSessionIdLSB(parent.getSessionId().getLeastSignificantBits()) |
|
|
.setGwSessionIdLSB(parent.getSessionId().getLeastSignificantBits()) |
|
|
.setDeviceProfileIdMSB(deviceInfo.getDeviceProfileId().getId().getMostSignificantBits()) |
|
|
.setDeviceProfileIdMSB(deviceInfo.getDeviceProfileId().getId().getMostSignificantBits()) |
|
|
.setDeviceProfileIdLSB(deviceInfo.getDeviceProfileId().getId().getLeastSignificantBits()) |
|
|
.setDeviceProfileIdLSB(deviceInfo.getDeviceProfileId().getId().getLeastSignificantBits()) |
|
|
|
|
|
.setActivityTimeFromGatewayDevice(activityTimeFromGatewayDevice) |
|
|
.build()); |
|
|
.build()); |
|
|
setDeviceInfo(deviceInfo); |
|
|
setDeviceInfo(deviceInfo); |
|
|
setDeviceProfile(deviceProfile); |
|
|
setDeviceProfile(deviceProfile); |
|
|
|