|
|
@@ -4,11 +4,45 @@ package mcu_ctrl_board
|
|
|
#include "mcu_ctrl_board.h"
|
|
|
*/
|
|
|
import "C"
|
|
|
+import (
|
|
|
+ "path/filepath"
|
|
|
+ "strings"
|
|
|
|
|
|
-// 处理JSON报文 支持老版协议
|
|
|
-func processText(jsonStr string) *C.char {
|
|
|
- s := jsonStr
|
|
|
- _ = s
|
|
|
+ "hnyfkj.com.cn/rtu/linux/baseapp"
|
|
|
+ "hnyfkj.com.cn/rtu/linux/rtu/cbd/utils"
|
|
|
+)
|
|
|
+
|
|
|
+func playTextAudio(text string) bool {
|
|
|
+ audioFile := ""
|
|
|
+
|
|
|
+ switch text {
|
|
|
+ case "button":
|
|
|
+ audioFile = "voices/button.wav"
|
|
|
+ case "reset":
|
|
|
+ audioFile = "voices/reset.wav"
|
|
|
+ case "save":
|
|
|
+ audioFile = "voices/save.wav"
|
|
|
+ case "takephoto.mp3":
|
|
|
+ audioFile = "voices/takephoto.wav"
|
|
|
+ case "workdone":
|
|
|
+ audioFile = "voices/workdone.wav"
|
|
|
+ case "workstart.mp3":
|
|
|
+ audioFile = "voices/workstart.wav"
|
|
|
+ default:
|
|
|
+ return false
|
|
|
+ }
|
|
|
+
|
|
|
+ utils.PlayAudioAsync(filepath.Join(baseapp.EXEC_DIR, audioFile))
|
|
|
+ return true
|
|
|
+}
|
|
|
+
|
|
|
+// 处理TEXT报文 支持老版协议
|
|
|
+func processText(textStr string) *C.char {
|
|
|
+ text := strings.TrimSpace(textStr)
|
|
|
+
|
|
|
+ if !playTextAudio(text) {
|
|
|
+ baseapp.Logger.Warnf("未知的TEXT命令: %s", text)
|
|
|
+ }
|
|
|
|
|
|
return nil
|
|
|
}
|