From 24d1688a13850462cffbe77cb8ef2fc42b73c6ec Mon Sep 17 00:00:00 2001 From: rahulpscraftech360 Date: Tue, 26 Aug 2025 15:10:34 +0530 Subject: [PATCH] mamnger api updatef=d for mqtt agteway --- add_mqtt_params.sql | 11 +++++++++++ check_mqtt_params.sql | 5 +++++ main/manager-api/README.md | 5 +++++ .../modules/device/dto/DeviceReportRespDTO.java | 8 +++++++- .../device/service/impl/DeviceServiceImpl.java | 4 +++- main/xiaozhi-server/client.py | 6 +++--- 6 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 add_mqtt_params.sql create mode 100644 check_mqtt_params.sql diff --git a/add_mqtt_params.sql b/add_mqtt_params.sql new file mode 100644 index 000000000..28c8f57fe --- /dev/null +++ b/add_mqtt_params.sql @@ -0,0 +1,11 @@ +-- Add MQTT configuration parameters to sys_params table +-- Replace the values with your actual MQTT broker configuration + +INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) +VALUES (120, 'mqtt.broker', '139.59.7.72', 'string', 1, 'MQTT broker IP address'); + +INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) +VALUES (121, 'mqtt.port', '1883', 'string', 1, 'MQTT broker port'); + +INSERT INTO `sys_params` (id, param_code, param_value, value_type, param_type, remark) +VALUES (122, 'mqtt.signature_key', 'your-secure-signature-key-here', 'string', 1, 'MQTT signature key for authentication'); \ No newline at end of file diff --git a/check_mqtt_params.sql b/check_mqtt_params.sql new file mode 100644 index 000000000..b9344fbaf --- /dev/null +++ b/check_mqtt_params.sql @@ -0,0 +1,5 @@ +-- Check current MQTT-related parameters in sys_params table +SELECT * FROM sys_params WHERE param_code LIKE 'mqtt.%'; + +-- Check all system parameters to see what's configured +SELECT id, param_code, param_value, remark FROM sys_params ORDER BY id; \ No newline at end of file diff --git a/main/manager-api/README.md b/main/manager-api/README.md index 901f6611d..ccfe8c131 100644 --- a/main/manager-api/README.md +++ b/main/manager-api/README.md @@ -2,6 +2,11 @@ This is a development document. If you need to deploy the Xiaozhi server, [click # Project Introduction + +run app + + +npm run serve manager-api: This project is developed based on the SpringBoot framework. When developing, use a code editor and select the `manager-api` folder as the project directory when importing the project. diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java index d8f193cd5..538895fb0 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/device/dto/DeviceReportRespDTO.java @@ -24,7 +24,7 @@ public class DeviceReportRespDTO { private Websocket websocket; @Schema(description = "MQTT配置") - private Mqtt mqtt; + private Mqtt mqtt_gateway; @Getter @Setter @@ -77,6 +77,12 @@ public class DeviceReportRespDTO { @Getter @Setter public static class Mqtt { + @Schema(description = "MQTT服务器地址") + private String broker; + + @Schema(description = "MQTT服务器端口") + private Integer port; + @Schema(description = "MQTT服务器端点") private String endpoint; diff --git a/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java b/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java index 67406a19f..fcda2fa37 100644 --- a/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java +++ b/main/manager-api/src/main/java/xiaozhi/modules/device/service/impl/DeviceServiceImpl.java @@ -183,7 +183,7 @@ public class DeviceServiceImpl extends BaseServiceImpl // Always include MQTT credentials for all devices (both registered and unregistered) DeviceReportRespDTO.Mqtt mqttCredentials = buildMqttCredentials(macAddress); if (mqttCredentials != null) { - response.setMqtt(mqttCredentials); + response.setMqtt_gateway(mqttCredentials); log.info("Added MQTT credentials to response for device: {}", macAddress); } @@ -427,6 +427,8 @@ public class DeviceServiceImpl extends BaseServiceImpl String password = Base64.getEncoder().encodeToString(signature); // Set MQTT credentials + mqtt.setBroker(mqttBroker); + mqtt.setPort(Integer.parseInt(mqttPort)); mqtt.setEndpoint(mqttBroker + ":" + mqttPort); mqtt.setClient_id(clientId); mqtt.setUsername(username); diff --git a/main/xiaozhi-server/client.py b/main/xiaozhi-server/client.py index fe401f031..9cee3edfe 100644 --- a/main/xiaozhi-server/client.py +++ b/main/xiaozhi-server/client.py @@ -19,9 +19,9 @@ import opuslib # --- Configuration --- -SERVER_IP = "192.168.1.107" # !!! UPDATE with your server's local IP address !!! -OTA_PORT = 8003 -MQTT_BROKER_HOST = "192.168.1.107" # MQTT gateway IP +SERVER_IP = "139.59.7.72" # !!! UPDATE with your server's local IP address !!! +OTA_PORT = 8002 +MQTT_BROKER_HOST = "139.59.7.72" # MQTT gateway IP MQTT_BROKER_PORT = 1883