Files
wangbeihong 1fc85589c6 ## 主要修改
### 1. MQTT setMode命令处理修复
- 添加Set_System_Mode函数extern声明,解决编译错误
- 将setMode处理逻辑移到control主题,符合小程序规范
- 完善Set_System_Mode函数,添加音频播放功能

### 2. 按键4手动补水功能
- 实现key4_single_click_handler函数,添加手动补水逻辑
- 与按键2喂食逻辑保持一致:相同的模式检查和错误处理
- 提供完整的本地手动控制功能

### 3. 系统优化
- 统一本地和远程控制逻辑
- 完善错误处理和用户反馈
- 优化代码结构和日志记录

## 影响
- 系统现在支持完整的双重控制方式(本地按键+远程MQTT)
- 所有按键功能完善:模式切换、手动喂食、页面切换、手动补水
- 编译无错误,代码结构清晰,便于维护
2026-02-25 22:48:12 +08:00

52 lines
1.1 KiB
JavaScript
Raw Permalink 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: '123456',
// 客户端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
};