// called from a system async event handler whenever g_easyConfigCtx.isWifiNeedToConfigure is true void WiFi_EasyConfigTask(void) { switch (g_easyConfigCtx.state) { case EZ_WAIT_FOR_START: SYS_CONSOLE_MESSAGE("EZ_WAIT_FOR_START\r\n"); g_easyConfigCtx.isWifiNeedToConfigure = false; // first thing to do is delay one second so user can see on the web // page that disconnect is about occur in process of connecting to // designated AP. So create and start timer. g_easyConfigCtx.timer = SYS_TICK_TimerCreate(EasyConfigTimerHandler); SYS_TICK_TimerSetRate(g_easyConfigCtx.timer, SYS_TICK_TicksPerSecondGet() * WF_EASY_CONFIG_DELAY_TIME); g_easyConfigCtx.state = EZ_WAIT_FOR_DELAY; break; case EZ_WAIT_FOR_DELAY: SYS_CONSOLE_MESSAGE("EZ_WAIT_FOR_DELAY\r\n"); g_easyConfigCtx.isWifiNeedToConfigure = false; // delete timer now that delay has occurred SYS_TICK_TimerDelete(g_easyConfigCtx.timer); // connect to AP that user selected on web page EasyConfigConnect(); g_easyConfigCtx.state = EZ_WAIT_FOR_START; break; } }
void WiFi_EasyConfigTask() { uint16_t timeout; switch (EZ_CFGCXT.state) { case EZ_WAIT_FOR_START: // first thing to do is delay one second so user can see on the web // page that disconnect is about occur in process of connecting to // designated AP. So create and start timer. timeout = SYS_TMR_TickCounterFrequencyGet() * WF_EASY_CONFIG_DELAY_TIME; EZ_CFGCXT.timer = SYS_TMR_CallbackSingle(timeout, 0, EasyConfigTimerHandler); EZ_CFGCXT.state = EZ_MIDDLE_START; break; case EZ_MIDDLE_START: break; case EZ_WAIT_FOR_DELAY: // connect to AP that user selected on web page EasyConfigConnect(); EZ_CFGCXT.state = EZ_WAIT_FOR_START; break; } }