|
|
@@ -6,6 +6,7 @@ import (
|
|
|
"fmt"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
+ "strings"
|
|
|
|
|
|
mqtt "github.com/eclipse/paho.mqtt.golang"
|
|
|
"hnyfkj.com.cn/rtu/linux/baseapp"
|
|
|
@@ -15,6 +16,12 @@ import (
|
|
|
)
|
|
|
|
|
|
func yfkj_handleMessage(client *Client, msg mqtt.Message) {
|
|
|
+ if mcu_ctrl_board.GlobalWorkState.Has(mcu_ctrl_board.SystemUpgrading) {
|
|
|
+ data, _ := json.Marshal(map[string]string{"result": "系统升级中, 忽略当前消息指令, 请稍后重试"})
|
|
|
+ yfkj_sendResponse(client, string(data))
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
if msg.Retained() { /// 收到历史缓存消息, 先通知服务端清除掉(空载荷 + Retain=1)它, 然后再处理
|
|
|
if err := client.Publish(msg.Topic(), client.config.Qos, true, []byte{}); err != nil {
|
|
|
baseapp.Logger.Warnf("[%s] 清除MQTT服务器 %s 主题 %s 的Retained消息失败: %v!",
|
|
|
@@ -166,6 +173,9 @@ func yfkj_execLegacyCmd(client *Client, msg mqtt.Message) error {
|
|
|
data, _ := json.Marshal(map[string]string{"result": "rtu start upgrading..."})
|
|
|
yfkj_sendResponse(client, string(data))
|
|
|
|
|
|
+ mcu_ctrl_board.GlobalWorkState.Add(mcu_ctrl_board.SystemUpgrading)
|
|
|
+ defer mcu_ctrl_board.GlobalWorkState.Remove(mcu_ctrl_board.SystemUpgrading)
|
|
|
+
|
|
|
utils.PlayAudioAsync(filepath.Join(baseapp.EXEC_DIR, "voices",
|
|
|
"startupdate.wav")) ////// 播报开始升级语音
|
|
|
|
|
|
@@ -252,11 +262,11 @@ func yfkj_onHMIUpgradeComplete(arg any, err error) {
|
|
|
}
|
|
|
|
|
|
func yfkj_notifyUpgradeResult(client *Client, name string, err error) {
|
|
|
- result := name + " upgrade success"
|
|
|
+ event := strings.ToUpper(name) + "固件升级成功"
|
|
|
if err != nil {
|
|
|
- result = name + " upgrade failed: " + err.Error()
|
|
|
+ event = strings.ToUpper(name) + "固件升级失败:" + err.Error()
|
|
|
}
|
|
|
|
|
|
- data, _ := json.Marshal(map[string]string{"result": result})
|
|
|
+ data, _ := json.Marshal(map[string]string{"event": event})
|
|
|
yfkj_sendResponse(client, string(data))
|
|
|
}
|