Files
SmartPetFeeder_STM32/wex_small/utils/mqtt.config.js

52 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// MQTT配置文件
const MQTT_CONFIG = {
// MQTT服务器地址请替换为你的实际MQTT服务器地址
host: 'beihong.wang',
// MQTT服务器端口一般为1883或8883
port: 8084,
// 是否使用SSL/TLS加密连接
useSSL: true,
// 用户名(用于认证)
username: 'STM32_MQTT',
// 密码(用于认证)
password: 'STM32_MQTT123456',
// 客户端ID唯一标识
clientId: `SmartPetFeeder_${Math.random().toString(16).substr(2, 8)}`,
// 连接超时时间(毫秒)
connectTimeout: 5000,
// 心跳间隔(秒)
keepalive: 60,
// 遗嘱消息配置(可选)
will: {
topic: 'device/status',
payload: JSON.stringify({ status: 'offline' }),
qos: 1,
retain: true
},
// 重连配置
reconnectPeriod: 5000, // 5秒后尝试重连
// 主题订阅列表
topics: [
'petfeeder/control', // 设备控制主题
'petfeeder/status', // 设备状态主题
'petfeeder/sensor' // 传感器数据
],
// QoS等级
qos: 1
};
module.exports = {
MQTT_CONFIG
};