mamnger api updatef=d for mqtt agteway

This commit is contained in:
rahulpscraftech360 2025-08-26 15:10:34 +05:30
parent 7ccdbe3c96
commit 24d1688a13
6 changed files with 34 additions and 5 deletions

11
add_mqtt_params.sql Normal file
View file

@ -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');

5
check_mqtt_params.sql Normal file
View file

@ -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;

View file

@ -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.

View file

@ -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;

View file

@ -183,7 +183,7 @@ public class DeviceServiceImpl extends BaseServiceImpl<DeviceDao, DeviceEntity>
// 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<DeviceDao, DeviceEntity>
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);

View file

@ -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