1.4.3.12 SYS_WIFI_CALLBACK Typedef

C

typedef void (*SYS_WIFI_CALLBACK )(uint32_t event, void * data,void *cookie );

Summary

Pointer to a Wi-Fi system service callback function.

Description

This data type defines a pointer to a Wi-Fi service callback function. Callback functions can be registered by client at initialization or using control message type.

Precondition

The Wi-Fi service must have been initialized using the SYS_WIFI_Initialize function if client registering callback using control message.

Parameters

ParamDescription
eventA event value, event can be any of SYS_WIFI_CTRLMSG types.
dataWi-Fi service Data.
cookieClient register cookie.

Returns

None.

Example

//User can refer the application "wireless_apps_pic32mzw1_wfi32e01\apps\wifi_easy_config" for more information on how to implement callback.
APP_DATA appData;
void WiFiServCallback (uint32_t event, void * data,void *cookie )
{
IPV4_ADDR *IPAddr;
switch(event)
{
case SYS_WIFI_CONNECT:
{
//In STA mode, Wi-Fi service share IP address provided by AP in the callback
IPAddr = (IPV4_ADDR *)data;
SYS_CONSOLE_PRINT("IP address obtained = %d.%d.%d.%d \\r\\n",IPAddr->v[0], IPAddr->v[1], IPAddr->v[2], IPAddr->v[3]);

//In AP mode, Wi-Fi service share MAC address and IP address of the connected STA in the callback
SYS_WIFI_STA_APP_INFO *StaConnInfo = (SYS_WIFI_STA_APP_INFO *)data;
SYS_CONSOLE_PRINT("STA Connected to AP. Got IP address = %d.%d.%d.%d \r\n",
StaConnInfo->ipAddr.v[0], StaConnInfo->ipAddr.v[1], StaConnInfo->ipAddr.v[2], StaConnInfo->ipAddr.v[3]);
SYS_CONSOLE_PRINT("STA Connected to AP. Got MAC address = %x:%x:%x:%x:%x:%x \r\n",
StaConnInfo->macAddr[0], StaConnInfo->macAddr[1], StaConnInfo->macAddr[2],
StaConnInfo->macAddr[3], StaConnInfo->macAddr[4], StaConnInfo->macAddr[5]);

break;
}
case SYS_WIFI_DISCONNECT:
{
SYS_CONSOLE_PRINT("Device DISCONNECTED \\r\\n");
break;
}
case SYS_WIFI_PROVCONFIG:
{
SYS_CONSOLE_PRINT("Received the Provisioning data \\r\\n");
break;
}
}
}
void APP_Initialize(void) {
appData.state = APP_STATE_INIT;
}

void APP_Tasks(void) {

switch (appData.state) {
case APP_STATE_INIT:
{
SYS_WIFI_CtrlMsg(sysObj.syswifi,SYS_WIFI_REGCALLBACK,WiFiServCallback,sizeof(uint8_t *));
appData.state=APP_STATE_SERVICE_TASKS;
break;
}

case APP_STATE_SERVICE_TASKS:
{

break;
}
default:
{
break;
}
}
}

Remarks

None.