From 7dcd4ec6f33d324e8f2558a6361e922dd5e1dbfd Mon Sep 17 00:00:00 2001 From: Dmitry Frank Date: Fri, 22 Dec 2017 16:57:20 +0200 Subject: [PATCH] BREAKING: Move mgos_net API to mgos_event `mgos_net_add_event_handler()` is removed in favor of `mgos_event`-based API. Example: ```c static void my_net_ev_handler(int ev, void *evd, void *arg) { if (ev == MGOS_NET_EV_IP_ACQUIRED) { LOG(LL_INFO, ("Just got IP!")); // Fetch something very useful from somewhere } (void) evd; (void) arg; } // Somewhere else: mgos_event_add_group_handler(MGOS_EVENT_GRP_NET, my_net_ev_handler, NULL); ``` PUBLISHED_FROM=3e468cd9d0698d49713e57429776c29c624b1325 --- src/mgos_mqtt.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mgos_mqtt.c b/src/mgos_mqtt.c index ffecd5e..9148a7f 100644 --- a/src/mgos_mqtt.c +++ b/src/mgos_mqtt.c @@ -220,13 +220,11 @@ void mgos_mqtt_set_connect_fn(mgos_mqtt_connect_fn_t fn, void *fn_arg) { s_connect_fn_arg = fn_arg; } -static void mgos_mqtt_net_ev(enum mgos_net_event ev, - const struct mgos_net_event_data *ev_data, - void *arg) { +static void mgos_mqtt_net_ev(int ev, void *evd, void *arg) { if (ev != MGOS_NET_EV_IP_ACQUIRED) return; mgos_mqtt_global_connect(); - (void) ev_data; + (void) evd; (void) arg; } @@ -275,7 +273,7 @@ bool mgos_mqtt_init(void) { LOG(LL_ERROR, ("MQTT requires server name")); return false; } - mgos_net_add_event_handler(mgos_mqtt_net_ev, NULL); + mgos_event_add_group_handler(MGOS_EVENT_GRP_NET, mgos_mqtt_net_ev, NULL); mgos_mqtt_set_max_qos(mgos_sys_config_get_mqtt_max_qos());