|
@@ -209,14 +209,14 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendRealtimePoseMessage(String deviceId, int pose, Object targetPoint) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("message_type", DeviceConstants.MessageType.MSG_REALTIME_TARGET.getCode());
|
|
|
payload.put("timestamp", System.currentTimeMillis());
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("pose", pose);
|
|
|
+ payload.put("pose", pose);
|
|
|
payload.put("target_point", targetPoint);
|
|
|
-
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_REALTIME_POS, payload);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending realtime pose message: {}", deviceId, e);
|
|
@@ -226,13 +226,13 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendAlarmMessage(String deviceId, String alarmType, Map<String, Object> data) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>(data);
|
|
|
+ Map<String, Object> payload = new HashMap<>(data);
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("message_type", DeviceConstants.MessageType.MSG_ALARM_EVENT.getCode());
|
|
|
payload.put("dev_id", deviceId);
|
|
|
payload.put("timestamp", System.currentTimeMillis());
|
|
|
- payload.put("alarmType", alarmType);
|
|
|
-
|
|
|
+ payload.put("alarmType", alarmType);
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_ALARM_EVENT, payload);
|
|
|
log.info("Alarm message sent: {}, type: {}", deviceId, alarmType);
|
|
|
} catch (Exception e) {
|
|
@@ -243,12 +243,12 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendBehaviorAnalysisResult(String deviceId, Object behaviorPattern) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("behaviorPattern", behaviorPattern);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("behaviorPattern", behaviorPattern);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_BEHAVIOR_ANALYSIS, payload);
|
|
|
log.debug("Behavior analysis result sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
@@ -259,11 +259,11 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public boolean sendCommandToDevice(String deviceId, String command, Object payload) {
|
|
|
try {
|
|
|
- Map<String, Object> message = new HashMap<>();
|
|
|
- message.put("command", command);
|
|
|
- message.put("payload", payload);
|
|
|
- message.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ Map<String, Object> message = new HashMap<>();
|
|
|
+ message.put("command", command);
|
|
|
+ message.put("payload", payload);
|
|
|
+ message.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = String.format(MqttTopics.DEV_COMMAND, deviceId);
|
|
|
sendMessage(topic, message);
|
|
|
log.info("Command sent to device: {}, command: {}", deviceId, command);
|
|
@@ -277,15 +277,15 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendFallAlarmMessage(String deviceId, int pose, List<Float> targetPoint) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("message_type", DeviceConstants.MessageType.MSG_EVENT_FALL.getCode());
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("pose", pose);
|
|
|
+ payload.put("pose", pose);
|
|
|
payload.put("target_point", targetPoint);
|
|
|
payload.put("alarmType", "fall");
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
// 跌倒告警使用QoS 2确保可靠传输
|
|
|
sendMessage(MqttTopics.DAS_ALARM_EVENT, payload, 2);
|
|
|
log.info("Fall alarm message sent: {}", deviceId);
|
|
@@ -297,9 +297,9 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceRebootCommand(String deviceId) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/reboot";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Device reboot command sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device reboot command: {}", deviceId, e);
|
|
@@ -309,9 +309,9 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceResetCommand(String deviceId) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/reset";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Device reset command sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device reset command: {}", deviceId, e);
|
|
@@ -321,13 +321,13 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceCommand(String deviceId, String command, Map<String, Object> params) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
- payload.put("command", command);
|
|
|
- payload.put("params", params);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
+ payload.put("command", command);
|
|
|
+ payload.put("params", params);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/" + command;
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Device command sent: {}, command: {}", deviceId, command);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device command: {}, command: {}", deviceId, command, e);
|
|
@@ -337,11 +337,11 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceKeepAliveResponse(String deviceId, int status) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("code", status);
|
|
|
-
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DAS_PREFIX + deviceId + "/keepalive";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.debug("Device keepalive response sent: {}, code: {}", deviceId, status);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device keepalive response: {}", deviceId, e);
|
|
@@ -351,12 +351,12 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceNotFoundResponse(String deviceId) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("code", 404);
|
|
|
- payload.put("message", "Device not found");
|
|
|
-
|
|
|
+ payload.put("message", "Device not found");
|
|
|
+
|
|
|
String topic = MqttTopics.APP_DEVICE_INFO_RESPONSE;
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.debug("Device not found response sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device not found response: {}", deviceId, e);
|
|
@@ -366,11 +366,11 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendAlarmAckMessage(String deviceId, Long eventId) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("dev_id", deviceId);
|
|
|
payload.put("event_id", eventId);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
sendMessage(MqttTopics.APP_FALL_EVENT_ACK, payload);
|
|
|
log.debug("Alarm acknowledgment sent: {}, eventId: {}", deviceId, eventId);
|
|
|
} catch (Exception e) {
|
|
@@ -381,14 +381,14 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceParamSetCommand(String deviceId, String paramType, String paramName, float value) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("param_type", paramType);
|
|
|
payload.put("param_name", paramName);
|
|
|
- payload.put("value", value);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("value", value);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/set_param";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Device parameter set command sent: {}, {}={}", deviceId, paramName, value);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device parameter set command: {}", deviceId, e);
|
|
@@ -403,13 +403,13 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendUpdateNetworkCommand(String deviceId, String ssid, String password) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
- payload.put("ssid", ssid);
|
|
|
- payload.put("password", password);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
+ payload.put("ssid", ssid);
|
|
|
+ payload.put("password", password);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/network";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Network update command sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending network update command: {}", deviceId, e);
|
|
@@ -419,12 +419,12 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceLoginResponse(String deviceId, int code) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
- payload.put("code", code);
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
+ payload.put("code", code);
|
|
|
payload.put("expires", 90); // 过期时间,单位秒
|
|
|
-
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DAS_PREFIX + deviceId + "/login";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.debug("Device login response sent: {}, code: {}", deviceId, code);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending device login response: {}", deviceId, e);
|
|
@@ -434,12 +434,12 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendEventMessage(String deviceId, List<List<Float>> rawPoints, int pose, List<List<Float>> targets, String event) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("message_type", DeviceConstants.MessageType.MSG_EVENT_FALL.getCode());
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("event", event);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
+ payload.put("event", event);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
payload.put("pose", pose);
|
|
|
payload.put("RawPoints", rawPoints != null ? rawPoints : new ArrayList<>()); // 对应Python版本的RawPoints参数
|
|
|
payload.put("targets", targets != null ? targets : new ArrayList<>()); // 对应Python版本的targets参数
|
|
@@ -457,15 +457,15 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendAlarmEventMessage(String deviceId, String description, String table, int tableId) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("message_type", DeviceConstants.MessageType.MSG_ALARM_EVENT.getCode());
|
|
|
payload.put("dev_id", deviceId);
|
|
|
payload.put("timestamp", System.currentTimeMillis());
|
|
|
payload.put("desc", description);
|
|
|
- payload.put("table", table);
|
|
|
+ payload.put("table", table);
|
|
|
payload.put("table_id", tableId);
|
|
|
-
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_ALARM_EVENT, payload);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending alarm event message: {}, desc: {}", deviceId, description, e);
|
|
@@ -475,13 +475,13 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendExistenceMessage(String deviceId, String event) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("message", "notify");
|
|
|
payload.put("message_type", DeviceConstants.MessageType.MSG_EVENT_EXIST.getCode());
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("event", event);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("event", event);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_EXIST_EVENT, payload);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending existence message: {}, event: {}", deviceId, event, e);
|
|
@@ -491,17 +491,17 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendNetworkConfigUpdate(String deviceId, Device.NetworkInfo networkInfo) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("dev_id", deviceId);
|
|
|
if (networkInfo != null) {
|
|
|
payload.put("ssid", networkInfo.getSsid());
|
|
|
payload.put("password", networkInfo.getPassword());
|
|
|
payload.put("ip", networkInfo.getIp());
|
|
|
}
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/network_config";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Network config update sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending network config update: {}", deviceId, e);
|
|
@@ -511,7 +511,7 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendInstallParamUpdate(String deviceId, Device.InstallParam installParam) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("dev_id", deviceId);
|
|
|
if (installParam != null) {
|
|
|
payload.put("mount_plain", installParam.getMountPlain());
|
|
@@ -523,10 +523,10 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
payload.put("tracking_region", trackingRegion);
|
|
|
}
|
|
|
}
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/install_param";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Install parameter update sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending install parameter update: {}", deviceId, e);
|
|
@@ -536,16 +536,16 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendTrackingRegionUpdate(String deviceId, Device.TrackingRegion trackingRegion) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("dev_id", deviceId);
|
|
|
if (trackingRegion != null) {
|
|
|
Map<String, Object> regionMap = getStringObjectMap(trackingRegion);
|
|
|
payload.put("tracking_region", regionMap);
|
|
|
}
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/tracking_region";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Tracking region update sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending tracking region update: {}", deviceId, e);
|
|
@@ -555,13 +555,13 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendAlarmScheduleUpdate(String deviceId, Map<String, Object> alarmSchedule) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("dev_id", deviceId);
|
|
|
payload.put("alarm_schedule", alarmSchedule);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
String topic = DeviceConstants.MqttConstant.TOPIC_DEVICE_PREFIX + deviceId + "/alarm_schedule";
|
|
|
- sendMessage(topic, payload);
|
|
|
+ sendMessage(topic, payload);
|
|
|
log.info("Alarm schedule update sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending alarm schedule update: {}", deviceId, e);
|
|
@@ -571,11 +571,11 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendDeviceInfoResponse(String deviceId, Device device) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("device", device);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("device", device);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
sendMessage(MqttTopics.APP_DEVICE_INFO_RESPONSE, payload);
|
|
|
log.debug("Device info response sent: {}", deviceId);
|
|
|
} catch (Exception e) {
|
|
@@ -586,11 +586,11 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendStatusMessage(String deviceId, String status, Map<String, Object> data) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>(data);
|
|
|
+ Map<String, Object> payload = new HashMap<>(data);
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("status", status);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("status", status);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_STATUS, payload);
|
|
|
log.debug("Device status message sent: {}, status: {}", deviceId, status);
|
|
|
} catch (Exception e) {
|
|
@@ -601,11 +601,11 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendBehaviorMessage(String deviceId, String behaviorType, Map<String, Object> data) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>(data);
|
|
|
+ Map<String, Object> payload = new HashMap<>(data);
|
|
|
payload.put("dev_id", deviceId);
|
|
|
- payload.put("behaviorType", behaviorType);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
+ payload.put("behaviorType", behaviorType);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
sendMessage(MqttTopics.DAS_BEHAVIOR_ANALYSIS, payload);
|
|
|
log.debug("Behavior message sent: {}, type: {}", deviceId, behaviorType);
|
|
|
} catch (Exception e) {
|
|
@@ -646,12 +646,12 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendResponse(String topic, int code, Map<String, Object> data) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>(data);
|
|
|
- payload.put("code", code);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
- sendMessage(topic, payload);
|
|
|
- log.debug("Response sent to topic: {}, code: {}", topic, code);
|
|
|
+ Map<String, Object> payload = new HashMap<>(data);
|
|
|
+ payload.put("code", code);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
+ sendMessage(topic, payload);
|
|
|
+ log.debug("Response sent to topic: {}, code: {}", topic, code);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending response to topic: {}", topic, e);
|
|
|
}
|
|
@@ -660,13 +660,13 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendCommand(String topic, String command, Map<String, Object> params) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>();
|
|
|
- payload.put("command", command);
|
|
|
+ Map<String, Object> payload = new HashMap<>();
|
|
|
+ payload.put("command", command);
|
|
|
payload.put("params", params);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
- sendMessage(topic, payload);
|
|
|
- log.debug("Command sent to topic: {}, command: {}", topic, command);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
+ sendMessage(topic, payload);
|
|
|
+ log.debug("Command sent to topic: {}, command: {}", topic, command);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending command to topic: {}", topic, e);
|
|
|
}
|
|
@@ -675,12 +675,12 @@ public class MqttGatewayImpl implements MqttGateway {
|
|
|
@Override
|
|
|
public void sendGenericMessage(String topic, String messageType, Map<String, Object> messageData) {
|
|
|
try {
|
|
|
- Map<String, Object> payload = new HashMap<>(messageData);
|
|
|
+ Map<String, Object> payload = new HashMap<>(messageData);
|
|
|
payload.put("message_type", messageType);
|
|
|
- payload.put("timestamp", System.currentTimeMillis());
|
|
|
-
|
|
|
- sendMessage(topic, payload);
|
|
|
- log.debug("Generic message sent to topic: {}, type: {}", topic, messageType);
|
|
|
+ payload.put("timestamp", System.currentTimeMillis());
|
|
|
+
|
|
|
+ sendMessage(topic, payload);
|
|
|
+ log.debug("Generic message sent to topic: {}, type: {}", topic, messageType);
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error sending generic message to topic: {}", topic, e);
|
|
|
}
|