// 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; } }
/***************************************************************************** Function: bool DNSClientInit(const TCPIP_STACK_MODULE_CTRL* const stackData, const DNS_CLIENT_MODULE_GONFIG* const dnsData); Summary: Initializes the DNS module. Description: This function perform the initialization of the DNS client module. It has to be called before any other operation with the DNS client is possible. Precondition: Stack is initialized. Parameters: stackData - stack initialization data dnsData - DNS client module specific initialization data Return Values: true - the initialization was performed OK and the module is ready to be used false - The DNS module initialization failed. Remarks: None ***************************************************************************/ bool DNSClientInit(const TCPIP_STACK_MODULE_CTRL* const stackData, const DNS_CLIENT_MODULE_GONFIG* const dnsData) { if(stackData->stackAction == TCPIP_STACK_ACTION_IF_UP) { // interface restart return true; } // stack start up if(dnsInitCount != 0) { // initialize just once dnsInitCount++; return true; } // 1st time init smDNS = DNS_IDLE; Flags.Val = 0; DNSSocket = INVALID_UDP_SOCKET; #if DNS_CLIENT_VERSION_NO >= 2 if(dnsTimerHandle == 0) { // once per service dnsTimerHandle = SYS_TICK_TimerCreate(DNSTmoHandler); if(dnsTimerHandle) { dnsTickPending = 0; SYS_TICK_TimerSetRate(dnsTimerHandle, (SYS_TICK_ResolutionGet() * DNS_CLIENT_TASK_PROCESS_RATE)/1000); } else { return false; } } #endif // DNS_CLIENT_VERSION_NO >= 2 dnsInitCount++; return true; }
/***************************************************************************** Function: void ARPInitialize(const TCPIP_STACK_MODULE_CTRL* const stackCtrl, const ARP_MODULE_CONFIG* const arpData) Summary: Initializes the ARP module. Description: Initializes the ARP module. Calls can be done with the request of not tearing down the ARP cache This helps for ifup/ifdown sequences. Of course, if this is the case the memory allocated for the ARP cache has to be from a persistent heap. Precondition: None Parameters: stackCtrl - stack initialization parameters arpData - ARP specific initialization parameters Returns: true if initialization succeded, false otherwise Remarks: ***************************************************************************/ bool ARPInitialize(const TCPIP_STACK_MODULE_CTRL* const stackCtrl, const ARP_MODULE_CONFIG* const arpData) { OA_HASH_DCPT* cacheDcpt; ARP_CACHE_DCPT* pArpDcpt; size_t memSize; bool newCache; if(stackCtrl->stackAction == TCPIP_STACK_ACTION_IF_UP) { // interface going up return true; } // stack going up pArpDcpt = arpCache + stackCtrl->netIx; // store the delete option for de-initialization pArpDcpt->deleteOld = arpData->deleteOld; if(arpData->deleteOld) { // remove the old stuff, if there _ARPCleanupCache(pArpDcpt); } // else do not re-initialize if(pArpDcpt->cacheDcpt == 0) { // some initialization to be done // allocate hash + descriptor contiguously memSize = sizeof(OA_HASH_DCPT) + arpData->cacheEntries * sizeof(ARP_HASH_ENTRY); cacheDcpt = (OA_HASH_DCPT*)(*stackCtrl->mallocCallback)(stackCtrl->memH, memSize); if(cacheDcpt == 0) { // failed return false; } newCache = true; // populate the entries cacheDcpt->memBlk = cacheDcpt + 1; cacheDcpt->hEntrySize = sizeof(ARP_HASH_ENTRY); cacheDcpt->hEntries = arpData->cacheEntries; cacheDcpt->probeStep = ARP_HASH_PROBE_STEP; OAHashInit(cacheDcpt); pArpDcpt->cacheDcpt = cacheDcpt; SingleListInit(&pArpDcpt->permList); SingleListInit(&pArpDcpt->completeList); SingleListInit(&pArpDcpt->incompleteList); pArpDcpt->purgeThres = (ARP_CACHE_PURGE_THRESHOLD * pArpDcpt->cacheDcpt->hEntries)/100; pArpDcpt->purgeQuanta = ARP_CACHE_PURGE_QUANTA; } else { // didn't create anything now newCache = false; } if(arpTimerHandle == 0) { // once per service SingleListInit(&arpRegisteredUsers); // store the memory allocation handle arpMemH = stackCtrl->memH; arpTimerHandle = SYS_TICK_TimerCreate(ARPTmoHandler); if(arpTimerHandle) { arpTickPending = arpTimeSeconds = 0; SYS_TICK_TimerSetRate(arpTimerHandle, SYS_TICK_ResolutionGet() * ARP_TASK_PROCESS_RATE); } else { // failed if(newCache) { _ARPCleanupCache(pArpDcpt); } return false; } } pArpDcpt->inited = true; return true; }