Thêm hàm Check Subcriber, disable bien khoi tao mqtt
This commit is contained in:
parent
a313f4eeac
commit
4d54d52cad
Binary file not shown.
|
@ -1,14 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
_ "beetai_BeetAipro/action_engine"
|
_ "Beetai_Pro/action_engine"
|
||||||
"beetai_BeetAipro/box"
|
"Beetai_Pro/box"
|
||||||
"beetai_BeetAipro/file"
|
"Beetai_Pro/file"
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -79,7 +77,7 @@ var STT_test bool
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
file.Println("----------------------START MAIN -------------------------")
|
file.Println("----------------------START MAIN -------------------------")
|
||||||
mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime) // | log.Lshortfile)
|
// mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime) // | log.Lshortfile)
|
||||||
//box.GetDir() // Check thu muc goc
|
//box.GetDir() // Check thu muc goc
|
||||||
fmt.Println("FUC......U")
|
fmt.Println("FUC......U")
|
||||||
file.Check_path(box.Path_log_luncher)
|
file.Check_path(box.Path_log_luncher)
|
||||||
|
@ -300,7 +298,7 @@ func MqttBegin_test() {
|
||||||
// Check lost connect mqtt server - can't publish msg
|
// Check lost connect mqtt server - can't publish msg
|
||||||
func MQTTLostConnectHandler(c mqtt.Client, err error) {
|
func MQTTLostConnectHandler(c mqtt.Client, err error) {
|
||||||
//c.Disconnect(10)
|
//c.Disconnect(10)
|
||||||
MqttStt = false
|
//MqttStt = false
|
||||||
number_repub = number_repub + 1
|
number_repub = number_repub + 1
|
||||||
file.Write_log("MQTT CMS Beetsoft Lost Connect\n", box.Path_log_luncher)
|
file.Write_log("MQTT CMS Beetsoft Lost Connect\n", box.Path_log_luncher)
|
||||||
file.Write_log("Number reconnect publish msg: "+strconv.Itoa(number_repub)+"\n", box.Path_log_luncher)
|
file.Write_log("Number reconnect publish msg: "+strconv.Itoa(number_repub)+"\n", box.Path_log_luncher)
|
||||||
|
@ -316,9 +314,17 @@ func MQTTOnConnectHandler(client mqtt.Client) {
|
||||||
file.Write_log("Number reconnect subcriber msg: "+strconv.Itoa(number_resub)+"\n", box.Path_log_luncher)
|
file.Write_log("Number reconnect subcriber msg: "+strconv.Itoa(number_resub)+"\n", box.Path_log_luncher)
|
||||||
client.Unsubscribe(CmsTopicOut)
|
client.Unsubscribe(CmsTopicOut)
|
||||||
time.Sleep(10)
|
time.Sleep(10)
|
||||||
client.Subscribe(CmsTopicOut, 0, MqttMessageHandler)
|
//client.Subscribe(CmsTopicOut, 0, MqttMessageHandler)
|
||||||
|
if token := client.Subscribe(CmsTopicOut, 0, MqttMessageHandler); token.Wait() && token.Error() != nil {
|
||||||
|
fmt.Println(token.Error())
|
||||||
|
file.Write_log("Subscriber Error MQTT\n", box.Path_log_luncher)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fmt.Println("Subcriber is MQTTOnConnectHandler () OKIE ")
|
||||||
|
file.Write_log("Subcriber is MQTTOnConnectHandler () OKIE\n ", box.Path_log_luncher)
|
||||||
|
}
|
||||||
STT_test = false
|
STT_test = false
|
||||||
file.Write_log("Recall function Subscribe MQTT\n", box.Path_log_luncher)
|
// file.Write_log("Recall function Subscribe MQTT\n", box.Path_log_luncher)
|
||||||
}
|
}
|
||||||
|
|
||||||
func MqttServer() {
|
func MqttServer() {
|
||||||
|
|
BIN
S905X_BI/aibox@gitlab.beetsoft.com.vn
Normal file
BIN
S905X_BI/aibox@gitlab.beetsoft.com.vn
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user