From 47b33f837fdf1193a1d4f533a9bb6da02ad347ec Mon Sep 17 00:00:00 2001 From: Benjamin Runnels Date: Sat, 29 Aug 2015 16:24:44 -0500 Subject: [PATCH] merge error fix --- esp-link/cgiwifi.c | 19 +++++++++++++++++-- esp-link/cgiwifi.h | 1 - 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/esp-link/cgiwifi.c b/esp-link/cgiwifi.c index 42ddf24..2354b13 100644 --- a/esp-link/cgiwifi.c +++ b/esp-link/cgiwifi.c @@ -24,7 +24,8 @@ Cgi/template routines for the /wifi url. //#define SLEEP_MODE LIGHT_SLEEP_T #define SLEEP_MODE MODEM_SLEEP_T -// ===== wifi status change callback +// ===== wifi status change callbacks +static WifiStateChangeCb wifi_state_change_cb[4]; uint8_t wifiState = wifiIsDisconnected; // reasons for which a connection failed @@ -88,7 +89,21 @@ static void ICACHE_FLASH_ATTR wifiHandleEventCb(System_Event_t *evt) { default: break; } - if (wifiStatusCb) (*wifiStatusCb)(wifiState); + + for (int i = 0; i < 4; i++) { + if (wifi_state_change_cb[i] != NULL) (wifi_state_change_cb[i])(wifiState); + } +} + +void ICACHE_FLASH_ATTR +wifiAddStateChangeCb(WifiStateChangeCb cb) { + for (int i = 0; i < 4; i++) { + if (wifi_state_change_cb[i] == NULL) { + wifi_state_change_cb[i] = cb; + return; + } + } + os_printf("WIFI: max state change cb count exceeded\n"); } // ===== wifi scanning diff --git a/esp-link/cgiwifi.h b/esp-link/cgiwifi.h index 3f7fe09..a2782a5 100644 --- a/esp-link/cgiwifi.h +++ b/esp-link/cgiwifi.h @@ -17,6 +17,5 @@ void wifiInit(void); void wifiAddStateChangeCb(WifiStateChangeCb cb); extern uint8_t wifiState; -//extern void (*wifiStatusCb)(uint8_t); // callback when wifi status changes #endif