There are several events that can occur on the MRF24WB0M / MRF24WG0M that the host CPU may want to know about. All MRF24WB0M / MRF24WG0M events go through the WF_ProcessEvent() function described in the next section.
The WF_ProcessEvent() function is how the host application is notified of events. This function will be called by the Wi-Fi host driver when an event occurs. This function should not be called directly by the host application. This function, located in WF_Config.c, should be modified by the user as needed. Since this function is called from the WiFi driver there are some restrictions – namely, one cannot call any Wi-Fi driver functions when inside WF_ProcessEvent(). It is recommended that that customer simply set a flag for a specific event and handle it in the main loop. The framework for this function is shown below.
The prototype for this function is:
void WF_ProcessEvent(UINT8 event, UINT16 eventInfo, UINT8 *extraInfo)
There are 3 inputs to the function:
event |
The 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 |
Additional information about the event. When DERIVE_KEY_FROM_PASSPHRASE_IN_HOST is enabled. where host will compute the key from the passphrade, this field contains the WPA Passphrase that will be sent to the host for the computation. |
The table below shows possible values that the event and eventInfo parameters can have. Note that event notification of some events can be optionally disabled via:
- Bit mask eventNotificationAction in the tWFCAElements structure (see Wi-Fi Connection Algorithm), or
- Function WF_CASetEventNotificationAction().
event |
eventInfo |
WF_EVENT_CONNECTION_SUCCESSFUL |
The connection attempt was successful. eventInfo:
(Optional event) |
WF_EVENT_CONNECTION_FAILED |
The connection attempt failed eventInfo:
(Optional event) |
WF_EVENT_CONNECTION_TEMPORARILY_LOST |
An established connection was temporarily lost – the connection algorithm is attempting to reconnect. The eventInfo field indicates why the connection was lost. eventInfo:
(Optional event) |
WF_EVENT_CONNECTION_PERMANENTLY_LOST |
An established connection was permanently lost – the connection algorithm either ran out of retries or was configured not to retry. The eventInfo field indicates why the connection was lost. eventInfo:
|
WF_EVENT_CONNECTION_REESTABLISHED |
A connection that was temporarily lost has been restablished Always WF_NO_ADDITIONAL_INFO (Optional event) |
WF_EVENT_SCAN_RESULTS_READY |
The scan request initiated by calling WF_Scan() has completed and results can be read from the MRF24WB0M / MRF24WG0M. eventInfo: Number of scan results |
WF_EVENT_SOFT_AP_EVENT |
Available only for MRF24WG0M (i) FW version 0x3108 and later and (ii) MLA v5.42.06 release or later. Indication of client's connection status, when a client has connected or disconnected or not powered on/active or received deauthentication. |
WF_EVENT_KEY_CALCULATION_REQUEST |
This event is generated when DERIVE_KEY_FROM_PASSPHRASE_IN_HOST is enabled, MRF24WG0M will transmit the passphase to the host via the field *extraInfo. where the host will then compute the passphrase from the key. Refer to function prototype WF_ConvPassphrase2Key() for more information. |
Below is the framework for WF_ProcessEvent(). Each case statement should be modified as needed to handle events the application is interested in.
void WF_ProcessEvent(UINT8 event, UINT16 eventInfo) { switch (event) { case WF_EVENT_CONNECTION_SUCCESSFUL: /* Application code here */ break; case WF_EVENT_CONNECTION_FAILED: /* Application code here */ break; case WF_EVENT_CONNECTION_TEMPORARILY_LOST: /* Application code here */ break; case WF_EVENT_CONNECTION_PERMANENTLY_LOST: /* Application code here */ break;
case WF_EVENT_CONNECTION_REESTABLISHED: /* Application code here */ break;
case WF_EVENT_SCAN_RESULTS_READY: /* Application code here */ break; default: WF_ASSERT(FALSE); break; } }