|
|
|
@ -42,6 +42,7 @@ import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.thingsboard.server.common.data.DataConstants; |
|
|
|
import org.thingsboard.server.common.data.DeviceProfile; |
|
|
|
import org.thingsboard.server.common.data.DeviceTransportType; |
|
|
|
import org.thingsboard.server.common.data.TransportPayloadType; |
|
|
|
import org.thingsboard.server.common.data.device.profile.MqttTopics; |
|
|
|
import org.thingsboard.server.common.msg.EncryptionUtil; |
|
|
|
import org.thingsboard.server.common.transport.SessionMsgListener; |
|
|
|
@ -159,6 +160,7 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
|
|
|
if (e.getCause().toString().contains("JsonSyntaxException")) { |
|
|
|
TransportProtos.ProvisionDeviceRequestMsg provisionRequestMsg = deviceSessionCtx.getContext().getProtoMqttAdaptor().convertToProvisionRequestMsg(deviceSessionCtx, mqttMsg); |
|
|
|
transportService.process(provisionRequestMsg, new DeviceProvisionCallback(ctx, msgId, provisionRequestMsg)); |
|
|
|
deviceSessionCtx.setProvisionPayloadType(TransportPayloadType.PROTOBUF); |
|
|
|
log.trace("[{}][{}] Processing provision publish msg [{}][{}]!", sessionId, deviceSessionCtx.getDeviceId(), topicName, msgId); |
|
|
|
} else { |
|
|
|
throw e; |
|
|
|
@ -326,7 +328,11 @@ public class MqttTransportHandler extends ChannelInboundHandlerAdapter implement |
|
|
|
ctx.writeAndFlush(createMqttPubAckMsg(msgId)); |
|
|
|
} |
|
|
|
try { |
|
|
|
deviceSessionCtx.getPayloadAdaptor().convertToPublish(deviceSessionCtx, provisionResponseMsg).ifPresent(deviceSessionCtx.getChannel()::writeAndFlush); |
|
|
|
if (deviceSessionCtx.getProvisionPayloadType().equals(TransportPayloadType.JSON)) { |
|
|
|
deviceSessionCtx.getContext().getJsonMqttAdaptor().convertToPublish(deviceSessionCtx, provisionResponseMsg).ifPresent(deviceSessionCtx.getChannel()::writeAndFlush); |
|
|
|
} else { |
|
|
|
deviceSessionCtx.getContext().getProtoMqttAdaptor().convertToPublish(deviceSessionCtx, provisionResponseMsg).ifPresent(deviceSessionCtx.getChannel()::writeAndFlush); |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
log.trace("[{}] Failed to convert device attributes response to MQTT msg", sessionId, e); |
|
|
|
} |
|
|
|
|