|
@@ -79,7 +79,7 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private UserService userService;
|
|
private UserService userService;
|
|
|
|
|
|
|
|
- @Autowired
|
|
|
|
|
|
|
+ @Autowired(required = false)
|
|
|
private MqttTemplate mqttTemplate;
|
|
private MqttTemplate mqttTemplate;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -488,7 +488,11 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
|
JSONObject msg = new JSONObject();
|
|
JSONObject msg = new JSONObject();
|
|
|
msg.put("dev_id", clientId);
|
|
msg.put("dev_id", clientId);
|
|
|
|
|
|
|
|
- mqttTemplate.send(topic, msg.toJSONString());
|
|
|
|
|
|
|
+ if (mqttTemplate != null) {
|
|
|
|
|
+ mqttTemplate.send(topic, msg.toJSONString());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("MQTT template is not available, message not sent to topic: {}", topic);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -496,7 +500,11 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
|
|
|
|
|
|
String topic = String.format(TopicConstants.TOPIC_DEV_REBOOT, clientId);
|
|
String topic = String.format(TopicConstants.TOPIC_DEV_REBOOT, clientId);
|
|
|
|
|
|
|
|
- mqttTemplate.send(topic, "1");
|
|
|
|
|
|
|
+ if (mqttTemplate != null) {
|
|
|
|
|
+ mqttTemplate.send(topic, "1");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("MQTT template is not available, message not sent to topic: {}", topic);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -504,7 +512,11 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
|
|
|
|
|
|
String topic = String.format(TopicConstants.TOPIC_DEV_UPDATEOTA, clientId);
|
|
String topic = String.format(TopicConstants.TOPIC_DEV_UPDATEOTA, clientId);
|
|
|
|
|
|
|
|
- mqttTemplate.send(topic, "1");
|
|
|
|
|
|
|
+ if (mqttTemplate != null) {
|
|
|
|
|
+ mqttTemplate.send(topic, "1");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("MQTT template is not available, message not sent to topic: {}", topic);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -544,7 +556,11 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
|
JSONObject msg = new JSONObject();
|
|
JSONObject msg = new JSONObject();
|
|
|
msg.put("dev_id", clientId);
|
|
msg.put("dev_id", clientId);
|
|
|
|
|
|
|
|
- mqttTemplate.send(TopicConstants.TOPIC_DEV_GET_INFO, msg.toJSONString());
|
|
|
|
|
|
|
+ if (mqttTemplate != null) {
|
|
|
|
|
+ mqttTemplate.send(TopicConstants.TOPIC_DEV_GET_INFO, msg.toJSONString());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("MQTT template is not available, message not sent to topic: {}", TopicConstants.TOPIC_DEV_GET_INFO);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -553,7 +569,11 @@ public class DeviceGatewayImpl implements DeviceGateway {
|
|
|
JSONObject msg = new JSONObject();
|
|
JSONObject msg = new JSONObject();
|
|
|
msg.put("dev_id", clientId);
|
|
msg.put("dev_id", clientId);
|
|
|
|
|
|
|
|
- mqttTemplate.send(TopicConstants.TOPIC_DEV_GET_PARAM, msg.toJSONString());
|
|
|
|
|
|
|
+ if (mqttTemplate != null) {
|
|
|
|
|
+ mqttTemplate.send(TopicConstants.TOPIC_DEV_GET_PARAM, msg.toJSONString());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("MQTT template is not available, message not sent to topic: {}", TopicConstants.TOPIC_DEV_GET_PARAM);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|