bo log
This commit is contained in:
parent
a038d3d801
commit
daa3e0660d
41
GPIO/GPIO.go
41
GPIO/GPIO.go
|
@ -151,7 +151,8 @@ func LoadConfig(path string) {
|
||||||
func main() {
|
func main() {
|
||||||
// Bat debug
|
// Bat debug
|
||||||
//mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime)
|
//mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime)
|
||||||
time.Sleep(7 * time.Second)
|
fmt.Println("======== START MAIN ==========")
|
||||||
|
time.Sleep(1 * time.Second)
|
||||||
if state_read_ecf == false {
|
if state_read_ecf == false {
|
||||||
LoadConfig(Path_config)
|
LoadConfig(Path_config)
|
||||||
fmt.Println("Read config done")
|
fmt.Println("Read config done")
|
||||||
|
@ -185,17 +186,12 @@ func main() {
|
||||||
relay.PullDown()
|
relay.PullDown()
|
||||||
// Toggle pin 20 times
|
// Toggle pin 20 times
|
||||||
//go Check_door()
|
//go Check_door()
|
||||||
|
mqtt_begin()
|
||||||
for {
|
for {
|
||||||
if stt_mqtt == false {
|
|
||||||
mqtt_begin()
|
|
||||||
}
|
|
||||||
Check_door()
|
Check_door()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
func connLostHandler(c mqtt.Client, err error) {
|
|
||||||
fmt.Printf("Connection lost, reason: %v\n", err)
|
|
||||||
mqtt_begin()
|
|
||||||
}
|
|
||||||
func Check_door() {
|
func Check_door() {
|
||||||
if door_state == true {
|
if door_state == true {
|
||||||
time.Sleep(time.Second * time_hold)
|
time.Sleep(time.Second * time_hold)
|
||||||
|
@ -222,22 +218,17 @@ func mqtt_begin() {
|
||||||
opts_cms_bi.SetConnectionLostHandler(MQTTLostConnectHandler)
|
opts_cms_bi.SetConnectionLostHandler(MQTTLostConnectHandler)
|
||||||
opts_cms_bi.SetOnConnectHandler(MQTTOnConnectHandler)
|
opts_cms_bi.SetOnConnectHandler(MQTTOnConnectHandler)
|
||||||
|
|
||||||
var reconect = false
|
if token_1 := mqtt_cms_bi.Connect(); token_1.Wait() && token_1.Error() == nil {
|
||||||
for reconect == false {
|
//file.Write_log("MQTT CMS Beetsoft Connected\n", path_log)
|
||||||
if token_1 := mqtt_cms_bi.Connect(); token_1.Wait() && token_1.Error() == nil {
|
if Debug == 1 {
|
||||||
//file.Write_log("MQTT CMS Beetsoft Connected\n", path_log)
|
fmt.Printf("MQTT Server Connected\n")
|
||||||
if Debug == 1 {
|
}
|
||||||
fmt.Printf("MQTT CMS Beetsoft Connected\n")
|
} else {
|
||||||
}
|
//file.Write_log("MQTT CMS Beetsoft cant not Connected\n", path_log)
|
||||||
reconect = true
|
if Debug == 1 {
|
||||||
} else {
|
fmt.Printf("MQTT Server cant not Connected\n")
|
||||||
//file.Write_log("MQTT CMS Beetsoft cant not Connected\n", path_log)
|
fmt.Printf("Loi Server : %v \n", token_1.Error())
|
||||||
if Debug == 1 {
|
fmt.Printf("-------------------\n")
|
||||||
fmt.Printf("MQTT CMS Beetsoft cant not Connected\n")
|
|
||||||
fmt.Printf("Loi CMS Beetsoft : %v \n", token_1.Error())
|
|
||||||
fmt.Printf("-------------------\n")
|
|
||||||
}
|
|
||||||
reconect = false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +241,7 @@ func mqtt_begin() {
|
||||||
|
|
||||||
func MQTTLostConnectHandler(c mqtt.Client, err error) {
|
func MQTTLostConnectHandler(c mqtt.Client, err error) {
|
||||||
// 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)
|
||||||
fmt.Println("MQTT CMS Beetsoft Lost Connect\n")
|
fmt.Println("MQTT SERVER Lost Connect\n")
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
func MQTTOnConnectHandler(client mqtt.Client) {
|
func MQTTOnConnectHandler(client mqtt.Client) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user