void WF_ProcessEvent(UINT8 event, UINT16 eventInfo, UINT8 *extraInfo) { char theStr[128]; /* this function tells the WF driver that we are in this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION); switch (event) { case WF_EVENT_CONNECTION_SUCCESSFUL: MyConsole_SendMsg("WF_Event: Connection Successful\n"); break; case WF_EVENT_CONNECTION_FAILED: sprintf(theStr, "WF_Event: Connection Failed -- eventInfo = %d %s\n", eventInfo, connectionFailureStrings[eventInfo]); MyConsole_SendMsg(theStr); break; case WF_EVENT_CONNECTION_TEMPORARILY_LOST: sprintf(theStr, "WF_Event: Connection Temporarily Lost -- eventInfo = %d %s\n", eventInfo, connectionLostStrings[eventInfo]); MyConsole_SendMsg(theStr); break; case WF_EVENT_CONNECTION_PERMANENTLY_LOST: sprintf(theStr, "WF_Event: Connection Permanently Lost -- eventInfo = %d %s\n", eventInfo, connectionLostStrings[eventInfo]); MyConsole_SendMsg(theStr); break; case WF_EVENT_CONNECTION_REESTABLISHED: MyConsole_SendMsg("WF_Event: Connection Reestablished\r\n"); break; case WF_EVENT_SCAN_RESULTS_READY: sprintf(theStr, "WF_Event: Scan Results Ready -- %d results\n", eventInfo); MyConsole_SendMsg(theStr); break; case WF_EVENT_RX_PACKET_RECEIVED: sprintf(theStr, "Event: Rx Packet Received - length = %d\n", eventInfo); MyConsole_SendMsg(theStr); break; default: WF_ASSERT(FALSE); /* unknown event */ break; } /* Informs the WF driver that we are leaving this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_LEAVING_FUNCTION); }
/***************************************************************************** * FUNCTION: WF_ProcessEvent * * RETURNS: None * * PARAMS: event -- event that occurred * eventInfo -- additional information about the event. Not all events * have associated info, in which case this value will be * set to WF_NO_ADDITIONAL_INFO (0xff) * * NOTES: The Host application must NOT directly call this function. This * function is called by the WiFi Driver code when an event occurs * that may need processing by the Host CPU. * * No other WiFi Driver function should be called from this function, with the * exception of WF_ASSERT. It is recommended that if the application wishes to be * notified of an event that it simply set a flag and let application code in the * main loop handle the event. * * WFSetFuncState must be called when entering and leaving this function. * When WF_ASSERT is enabled this allows a runtime check if any illegal WF functions * are called from within this function. * * For events that the application is not interested in simply leave the * case statement empty. * * Customize this function as needed for your application. *****************************************************************************/ void WF_ProcessEvent(UINT8 event, UINT16 eventInfo) { #if defined(STACK_USE_UART) char buf[8]; #endif /* this function tells the WF driver that we are in this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION); switch (event) { /*--------------------------------------*/ case WF_EVENT_CONNECTION_SUCCESSFUL: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Connection Successful\r\n"); #if defined(EZ_CONFIG_STORE) AppConfig.saveSecurityInfo = TRUE; #endif #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_FAILED: /*--------------------------------------*/ /* eventInfo will contain value from tWFConnectionFailureCodes */ #if defined(STACK_USE_UART) putrsUART("Event: Connection Failed -- eventInfo = "); sprintf(buf, "%d\r\n", eventInfo); putsUART(buf); #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_TEMPORARILY_LOST: /*--------------------------------------*/ /* eventInfo will contain value from tWFConnectionLostCodes */ #if defined(STACK_USE_UART) putrsUART("Event: Connection Temporarily Lost -- eventInfo = "); sprintf(buf, "%d\r\n", eventInfo); putsUART(buf); #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_PERMANENTLY_LOST: /*--------------------------------------*/ /* eventInfo will contain value from tWFConnectionLostCodes */ #if defined(STACK_USE_UART) putrsUART("Event: Connection Permanently Lost -- eventInfo = "); sprintf(buf, "%d\r\n", eventInfo); putsUART(buf); #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_REESTABLISHED: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Connection Reestablished\r\n"); #endif break; /*--------------------------------------*/ case WF_EVENT_SCAN_RESULTS_READY: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Scan Results Ready,"); sprintf(buf, "%d", eventInfo); putsUART(buf); putrsUART("results\r\n"); #endif #if defined ( EZ_CONFIG_SCAN ) WFScanEventHandler(eventInfo); #endif /* EZ_CONFIG_SCAN */ break; /*--------------------------------------*/ case WF_EVENT_RX_PACKET_RECEIVED: /*--------------------------------------*/ #if defined(STACK_USE_UART) // putrsUART("Event: Rx Packet Received - length = "); // sprintf(buf, "%d\r\n", eventInfo); // putsUART(buf); #endif break; default: WF_ASSERT(FALSE); /* unknown event */ break; } /* Informs the WF driver that we are leaving this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_LEAVING_FUNCTION); }
//int1 g_wifiConnected = 0; //int1 g_WifiTempDisFlag = FALSE; //TICK g_WifiTempDisTick; //#define WF_SET_TEMP_DIS() g_WifiTempDisFlag = TRUE; g_WifiTempDisTick = TickGet() //#define WF_CLEAR_TEMP_DIS() g_WifiTempDisFlag = FALSE void WF_ProcessEvent(UINT8 event, UINT16 eventInfo, UINT8 *extraInfo) { /* this function tells the WF driver that we are in this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION); switch (event) { /*--------------------------------------*/ case WF_EVENT_CONNECTION_SUCCESSFUL: /*--------------------------------------*/ wf_debug_printf(wf_debug_putc, "\r\nWIFI Event: Connection Successful\r\n"); //g_wifiConnected = 1; //WF_CLEAR_TEMP_DIS(); break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_FAILED: /*--------------------------------------*/ /* eventInfo will contain value from tWFConnectionFailureReasons */ wf_debug_printf(wf_debug_putc, "\r\nWIFI Event: Connection Failed -- eventInfo = %Lu", eventInfo); g_WifiConnectFail = 1; //g_wifiConnected = 0; //WF_CLEAR_TEMP_DIS(); break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_TEMPORARILY_LOST: /*--------------------------------------*/ wf_debug_printf(wf_debug_putc, "\r\nWIFI Event: Connection Temporarily Lost -- eventInfo = %Lu", eventInfo); #if defined(STACK_USE_CCS_SCAN_TASK) WIFIScanIgnoreResults(); #endif //g_wifiConnected = 0; //WF_SET_TEMP_DIS(); break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_PERMANENTLY_LOST: /*--------------------------------------*/ wf_debug_printf(wf_debug_putc, "\r\nWIFI Event: Connection Permanently Lost -- eventInfo = %Lu", eventInfo); g_WifiConnectFail = 1; //g_wifiConnected = 0; //WF_CLEAR_TEMP_DIS(); break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_REESTABLISHED: /*--------------------------------------*/ wf_debug_printf(wf_debug_putc, "\r\nWIFI Event: Connection Reestablished\r\n"); #if defined(STACK_USE_CCS_SCAN_TASK) WIFIScanIgnoreResults(); #endif //g_wifiConnected = 1; //WF_CLEAR_TEMP_DIS(); break; /*--------------------------------------*/ case WF_EVENT_SCAN_RESULTS_READY: /*--------------------------------------*/ wf_debug_printf(wf_debug_putc, "\r\nWIFI Event: Scan Results Ready,%Lu results\r\n", eventInfo); #if defined ( EZ_CONFIG_SCAN ) && !defined(__18CXX) WFScanEventHandler(eventInfo); #endif /* EZ_CONFIG_SCAN */ #if defined(STACK_USE_CCS_SCAN_TASK) WIFIScanResults(eventInfo); #endif break; case WF_EVENT_KEY_CALCULATION_REQUEST: #if defined(DERIVE_KEY_FROM_PASSPHRASE_IN_HOST) g_WpsPassphrase.valid = TRUE; memcpy((void *)&g_WpsPassphrase.passphrase, (void *)extraInfo, sizeof(g_WpsPassphrase.passphrase)); #if defined(STACK_USE_UART) putrsUART("Event: WPS pass phrase Ready\r\n"); #endif /* STACK_USE_UART */ #endif /* defined(DERIVE_KEY_FROM_PASSPHRASE_IN_HOST) */ break; /*--------------------------------------*/ case WF_EVENT_RX_PACKET_RECEIVED: /*--------------------------------------*/ break; default: WF_ASSERT(FALSE); /* unknown event */ break; } /* Informs the WF driver that we are leaving this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_LEAVING_FUNCTION); }
/***************************************************************************** * FUNCTION: WF_ProcessEvent * * RETURNS: None * * PARAMS: event -- event that occurred * eventInfo -- additional information about the event. Not all events * have associated info, in which case this value will be * set to WF_NO_ADDITIONAL_INFO (0xff) * extraInfo - more additional information about the event * * NOTES: The Host application must NOT directly call this function. This * function is called by the WiFi Driver code when an event occurs * that may need processing by the Host CPU. * * No other WiFi Driver function should be called from this function, with the * exception of WF_ASSERT. It is recommended that if the application wishes to be * notified of an event that it simply set a flag and let application code in the * main loop handle the event. * * WFSetFuncState must be called when entering and leaving this function. * When WF_DEBUG is enabled this allows a runtime check if any illegal WF functions * are called from within this function. * * For events that the application is not interested in simply leave the * case statement empty. * * Customize this function as needed for your application. *****************************************************************************/ void WF_ProcessEvent(uint8_t event, uint16_t eventInfo, uint8_t *extraInfo) { #if defined(STACK_USE_UART) char buf[8]; #endif tMgmtIndicateSoftAPEvent *softAPEvent; /* this function tells the WF driver that we are in this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION); switch (event) { /*--------------------------------------*/ case WF_EVENT_CONNECTION_SUCCESSFUL: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Connection Successful\r\n"); #if defined(EZ_CONFIG_STORE) AppConfig.saveSecurityInfo = true; #endif #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_FAILED: case WF_EVENT_CONNECTION_TEMPORARILY_LOST: case WF_EVENT_CONNECTION_PERMANENTLY_LOST: /*--------------------------------------*/ #if defined(STACK_USE_UART) WF_OutputConnectionDebugMsg(event, eventInfo); #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_REESTABLISHED: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Connection Reestablished\r\n"); #endif #if 0 //This code will cause assert, so I mask them -- Jian Wan #if defined(WF_USE_POWER_SAVE_FUNCTIONS) { bool PsPollEnabled; PsPollEnabled = (MY_DEFAULT_PS_POLL == WF_ENABLED); if (!PsPollEnabled) { /* disable low power (PS-Poll) mode */ #if defined(STACK_USE_UART) putrsUART("Disable PS-Poll\r\n"); #endif WF_PsPollDisable(); } else { /* Enable low power (PS-Poll) mode */ #if defined(STACK_USE_UART) putrsUART("Enable PS-Poll\r\n"); #endif WF_PsPollEnable(true); } } #endif #endif break; /*--------------------------------------*/ case WF_EVENT_SCAN_RESULTS_READY: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Scan Results Ready,"); sprintf(buf, " %d", eventInfo); putsUART(buf); putrsUART("results\r\n"); #endif /* STACK_USE_UART */ #if defined ( EZ_CONFIG_SCAN ) && !defined(__XC8) WFScanEventHandler(eventInfo); #endif /* EZ_CONFIG_SCAN */ #if MY_DEFAULT_NETWORK_TYPE == WF_SOFT_AP g_scan_done = 1; // WF_PRESCAN #endif #if defined(WF_PRE_SCAN_IN_ADHOC) g_prescan_adhoc_done = 1; #endif break; case WF_EVENT_SOFT_AP_EVENT: softAPEvent = (tMgmtIndicateSoftAPEvent *)extraInfo; #if defined(STACK_USE_UART) { char str[96]; char *result = "None"; char *reason = "None"; uint8_t *addr = softAPEvent->address; putrsUART("Event: SoftAP, "); if (softAPEvent->event == SOFTAP_EVENT_CONNECTED) { result = "Connected"; } else if (softAPEvent->event == SOFTAP_EVENT_DISCONNECTED) { result = "Disconnected"; if (softAPEvent->reason == SOFTAP_EVENT_LINK_LOST) reason = "LinkLost"; else if (softAPEvent->reason == SOFTAP_EVENT_RECEIVED_DEAUTH) reason = "ReceivedDeauth"; } sprintf(str, "%s, %s, %x:%x:%x:%x:%x:%x", result, reason, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); putsUART(str); putrsUART("\r\n"); } #endif /* STACK_USE_UART */ break; default: WF_ASSERT(false); /* unknown event */ break; } /* Informs the WF driver that we are leaving this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_LEAVING_FUNCTION); }
/***************************************************************************** * FUNCTION: WF_ProcessEvent * * RETURNS: None * * PARAMS: event -- event that occurred * eventInfo -- additional information about the event. Not all events * have associated info, in which case this value will be * set to WF_NO_ADDITIONAL_INFO (0xff) * extraInfo - more additional information about the event * * NOTES: The Host application must NOT directly call this function. This * function is called by the WiFi Driver code when an event occurs * that may need processing by the Host CPU. * * No other WiFi Driver function should be called from this function, with the * exception of WF_ASSERT. It is recommended that if the application wishes to be * notified of an event that it simply set a flag and let application code in the * main loop handle the event. * * WFSetFuncState must be called when entering and leaving this function. * When WF_DEBUG is enabled this allows a runtime check if any illegal WF functions * are called from within this function. * * For events that the application is not interested in simply leave the * case statement empty. * * Customize this function as needed for your application. *****************************************************************************/ void WF_ProcessEvent(uint8_t event, uint16_t eventInfo, uint8_t *extraInfo) { #if defined(STACK_USE_UART) char buf[8]; #endif tMgmtIndicateSoftAPEvent *softAPEvent; /* this function tells the WF driver that we are in this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION); switch (event) { /*--------------------------------------*/ case WF_EVENT_CONNECTION_SUCCESSFUL: /*--------------------------------------*/ #if defined(EZ_CONFIG_STORE) AppConfig.saveSecurityInfo = true; #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_FAILED: case WF_EVENT_CONNECTION_TEMPORARILY_LOST: case WF_EVENT_CONNECTION_PERMANENTLY_LOST: /*--------------------------------------*/ break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_REESTABLISHED: /*--------------------------------------*/ break; /*--------------------------------------*/ case WF_EVENT_SCAN_RESULTS_READY: /*--------------------------------------*/ #if defined ( EZ_CONFIG_SCAN ) WFScanEventHandler(eventInfo); #endif /* EZ_CONFIG_SCAN */ g_scan_done = 1; // WF_PRESCAN break; case WF_EVENT_SOFT_AP_EVENT: softAPEvent = (tMgmtIndicateSoftAPEvent *) extraInfo; #if defined(STACK_USE_UART) { char str[96]; char *result = "None"; char *reason = "None"; uint8_t *addr = softAPEvent->address; putrsUART("Event: SoftAP, "); if (softAPEvent->event == SOFTAP_EVENT_CONNECTED) { result = "Connected"; } else if (softAPEvent->event == SOFTAP_EVENT_DISCONNECTED) { result = "Disconnected"; if (softAPEvent->reason == SOFTAP_EVENT_LINK_LOST) reason = "LinkLost"; else if (softAPEvent->reason == SOFTAP_EVENT_RECEIVED_DEAUTH) reason = "ReceivedDeauth"; } sprintf(str, "%s, %s, %x:%x:%x:%x:%x:%x", result, reason, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); putsUART(str); putrsUART("\r\n"); } #endif /* STACK_USE_UART */ break; default: WF_ASSERT(false); /* unknown event */ break; } /* Informs the WF driver that we are leaving this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_LEAVING_FUNCTION); }
void WF_ProcessEvent(UINT8 event, UINT16 eventInfo, UINT8 *extraInfo) { #if defined(STACK_USE_UART) char buf[8]; #endif /* defined(STACK_USE_UART) */ /* this function tells the WF driver that we are in this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_ENTERING_FUNCTION); switch (event) { /*--------------------------------------*/ case WF_EVENT_CONNECTION_SUCCESSFUL: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Connection Successful\r\n"); #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_FAILED: case WF_EVENT_CONNECTION_TEMPORARILY_LOST: case WF_EVENT_CONNECTION_PERMANENTLY_LOST: /*--------------------------------------*/ #if defined(STACK_USE_UART) WF_OutputConnectionDebugMsg(event, eventInfo); #endif break; /*--------------------------------------*/ case WF_EVENT_CONNECTION_REESTABLISHED: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Connection Reestablished\r\n"); #endif break; /*--------------------------------------*/ case WF_EVENT_SCAN_RESULTS_READY: /*--------------------------------------*/ #if defined(STACK_USE_UART) putrsUART("Event: Scan Results Ready,"); sprintf(buf, " %d", eventInfo); putsUART(buf); putrsUART("results\r\n"); #endif /* STACK_USE_UART */ #if defined ( EZ_CONFIG_SCAN ) && !defined(__18CXX) WFScanEventHandler(eventInfo); #endif /* EZ_CONFIG_SCAN */ break; case WF_EVENT_KEY_CALCULATION_REQUEST: #if defined(DERIVE_KEY_FROM_PASSPHRASE_IN_HOST) g_WpsPassphrase.valid = TRUE; memcpy((void *)&g_WpsPassphrase.passphrase, (void *)extraInfo, sizeof(g_WpsPassphrase.passphrase)); #if defined(STACK_USE_UART) putrsUART("Event: WPS pass phrase Ready\r\n"); #endif /* STACK_USE_UART */ #endif /* defined(DERIVE_KEY_FROM_PASSPHRASE_IN_HOST) */ break; default: WF_ASSERT(FALSE); /* unknown event */ break; } /* Informs the WF driver that we are leaving this function */ WFSetFuncState(WF_PROCESS_EVENT_FUNC, WF_LEAVING_FUNCTION); }