check anvui

This commit is contained in:
2021-03-13 11:51:23 +07:00
parent 63727cd2f2
commit 1c552ac0ce
11 changed files with 178 additions and 42 deletions

Binary file not shown.

View File

@@ -101,24 +101,23 @@ func main() {
time.Sleep(7 * time.Second) // Waitting 7 second for next request
} else {
if SttNetwork == true {
// KHoi tao connect MQTT cms.beetai.com
if MqttStt == false {
if CheckConnectionMQTT() == true { // Server mqtt running ?
CreateTopic()
MqttBegin()
//MqttCmsBi.Subscribe(CmsTopicOut, 1, MqttMessageHandler)
MqttStt = true
}
// if CheckConnectionMQTT() == true { // Server mqtt running ?
CreateTopic()
MqttBegin()
//MqttCmsBi.Subscribe(CmsTopicOut, 1, MqttMessageHandler)
MqttStt = true
// }
}
if MqttStt == true && SttUpdate == false && SttPub == true {
PublishData()
//go Ping_broker_sub()
if STT_test == false {
// time.Sleep(10)
Ping_broker_sub()
STT_test = true
}
// if STT_test == false {
// // time.Sleep(10)
// Ping_broker_sub()
// STT_test = true
// }
}
} else {
@@ -136,22 +135,22 @@ func main() {
// KHoi tao connect MQTT cms.beetai.com
if MqttStt == false { // Chưa connect đến MQTT or mất connect mqtt
if CheckConnectionMQTT() == true { // Server mqtt running ?
CreateTopic()
MqttBegin()
//MqttCmsBi.Subscribe(CmsTopicOut, 1, MqttMessageHandler)
MqttStt = true
}
//if CheckConnectionMQTT() == true { // Server mqtt running ?
CreateTopic()
MqttBegin()
//MqttCmsBi.Subscribe(CmsTopicOut, 1, MqttMessageHandler)
MqttStt = true
//}
}
if MqttStt == true && SttUpdate == false && SttPub == true { // Check khởi tạo done mqtt and no update and cho phép publish message
box.RunCheck()
PublishData()
//go Ping_broker_sub()
if STT_test == false {
// time.Sleep(10)
Ping_broker_sub()
STT_test = true
}
// if STT_test == false {
// // time.Sleep(10)
// Ping_broker_sub()
// STT_test = true
// }
}
} else {
@@ -456,17 +455,18 @@ func MqttMessageHandler(MqttBI mqtt.Client, message mqtt.Message) {
file.Println("Update engine done\n")
} else if list["method"] == "sub_begin" { // Test subcriber
file.Write_log("================>> Subcriber is OKIE <========== \n", box.Path_log_luncher)
fmt.Println("================>> Subcriber is OKIE <========== \n")
file.Write_log("======>> Subcriber is OKIE <========== \n", box.Path_log_luncher)
} else if list["method"] == "update_model" { // {"method":"update_model","status": 1}
file.Println("Update_model \n")
fmt.Printf("%v--%T", list["id_box_engine"], list["id_box_engine"])
msg := `{"method":"update_model","status": ` + strconv.Itoa(1) + `}`
file.Write_log("Message:"+msg+" \n", box.Path_log_luncher)
if SttUpdate == false {
UpdateModule((int)((list["id_box_engine"]).(float64)))
topic := strings.Replace(message.Topic(), "request", "response", 1)
msg := `{"method":"update_model","status": ` + strconv.Itoa(1) + `}`
file.Write_log("Message:"+msg+" \n", box.Path_log_luncher)
// file.Write_log("Message:"+msg+" \n", box.Path_log_luncher)
CmsResponse(MqttBI, topic, msg)
file.Println("UpdateModule done\n")
}
@@ -561,8 +561,8 @@ func MqttMessageHandler(MqttBI mqtt.Client, message mqtt.Message) {
func UpdateModule(id_engine int) {
file.Write_log("-------- START UPDATE MODULE ----------", box.Path_log_luncher)
SttUpdate = true
box.Stop_check_engine()
box.Stop_Server_Engine()
// box.Stop_check_engine()
// box.Stop_Server_Engine()
box.RequestUpdate_Module(box.Url_module, id_engine)
SttUpdate = false
file.Write_log("---------------------------------------", box.Path_log_luncher)

5
S905X_BI/build_arm.bat Normal file
View File

@@ -0,0 +1,5 @@
set GOOS=linux
set GOARCH=arm
set GOARM=5
go build
pause