diff --git a/GPIO/GPIO b/GPIO/GPIO index 2827c98..bc4a9d2 100644 Binary files a/GPIO/GPIO and b/GPIO/GPIO differ diff --git a/GPIO/GPIO.go b/GPIO/GPIO.go index b1023db..b9198e8 100644 --- a/GPIO/GPIO.go +++ b/GPIO/GPIO.go @@ -6,7 +6,6 @@ import ( "encoding/json" "fmt" "io/ioutil" - "log" "os" "time" @@ -151,7 +150,7 @@ func LoadConfig(path string) { } func main() { // Bat debug - mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime) + // mqtt.DEBUG = log.New(os.Stderr, "DEBUG ", log.Ltime) fmt.Println("======== START MAIN ==========") time.Sleep(1 * time.Second) if state_read_ecf == false { @@ -275,6 +274,26 @@ func mqtt_messageHandler(mqtt_bi mqtt.Client, message mqtt.Message) { fmt.Printf("TOPIC: %s\n", message.Topic()) fmt.Printf("MSG:\n %s\n", message.Payload()) } + if string(message.Payload()) == `{"method":"gpio","params":"1"}` { + fmt.Println("MO KHOA") + if door_state == true { + + } else { + //relay.High() + relay.Low() + //Name = (list["name"]).(string) + fmt.Println("Xin Chao Mung " + Name) + } + + //msg := `{"method":"gpio","params":"1"}` + //CmsResponse(mqtt_bi, topic, msg) + if Debug == 1 { + fmt.Println("Open Door") + fmt.Println("--------------------------------") + } + + door_state = true + } //file.Write_log(string(message.Topic()), path_log) //file.Write_log(string(message.Payload()), path_log) dec := json.NewDecoder(bytes.NewReader(message.Payload()))