diff --git a/include/main.h b/include/main.h index b12c73c..4086994 100644 --- a/include/main.h +++ b/include/main.h @@ -19,7 +19,7 @@ struct channel_t { double button_last_change; }; -void led_green_blink(); +void led_status_blink(); bool channel_init(const char *fn); uint8_t channel_gpio_by_idx(int idx); diff --git a/src/channel.c b/src/channel.c index a9e6042..61c84c4 100644 --- a/src/channel.c +++ b/src/channel.c @@ -138,7 +138,7 @@ void channel_report(int idx, char *msg, int msg_len) { if (idx<0 || idx>=channel_get_total()) return; - snprintf(msg, msg_len-1, "{\"idx\": %d, \"button_gpio\": %d, \"led_gpio\": %d, \"relay_gpio\": %d, \"relay_state\": %d}", + snprintf(msg, msg_len-1, "{idx: %d, button_gpio: %d, led_gpio: %d, relay_gpio: %d, relay_state: %d}", idx, s_channels[idx].button_gpio, s_channels[idx].led_gpio, s_channels[idx].relay_gpio, s_channels[idx].relay_state); } diff --git a/src/led.c b/src/led.c index 7fae74e..98ce2b4 100644 --- a/src/led.c +++ b/src/led.c @@ -1,20 +1,20 @@ #include "main.h" -static mgos_timer_id led_green_timer_id = 0; +static mgos_timer_id led_status_timer_id = 0; -static void led_green_off_cb(void *arg) { +static void led_status_off_cb(void *arg) { mgos_gpio_write(GREEN_LED_GPIO, 0); - led_green_timer_id=0; + led_status_timer_id=0; (void) arg; } -void led_green_blink() { +void led_status_blink() { mgos_gpio_write(GREEN_LED_GPIO, 1); - if (led_green_timer_id) { - mgos_clear_timer(led_green_timer_id); - led_green_timer_id=0; + if (led_status_timer_id) { + mgos_clear_timer(led_status_timer_id); + led_status_timer_id=0; } - led_green_timer_id = mgos_set_timer(100, false, led_green_off_cb, NULL); + led_status_timer_id = mgos_set_timer(100, false, led_status_off_cb, NULL); } diff --git a/src/mqtt.c b/src/mqtt.c index e0062aa..d278453 100644 --- a/src/mqtt.c +++ b/src/mqtt.c @@ -7,7 +7,7 @@ static void mqtt_publish_broadcast_stat(const char *stat, const char *msg) { char topic[80]; - led_green_blink(); + led_status_blink(); snprintf(topic, sizeof(topic)-1, "%s/%s", MQTT_TOPIC_BROADCAST_STAT, stat); mgos_mqtt_pub((char*)topic, (char*)msg, strlen(msg), 0, false); @@ -62,7 +62,7 @@ static void mqtt_ev(struct mg_connection *nc, int ev, void *ev_data, void *user_ void mqtt_publish_stat(const char *stat, const char *msg) { char topic[80]; - led_green_blink(); + led_status_blink(); snprintf(topic, sizeof(topic)-1, "%s%s/stat/%s", MQTT_TOPIC_PREFIX, mgos_sys_config_get_device_id(), stat); mgos_mqtt_pub((char*)topic, (char*)msg, strlen(msg), 0, false);