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