Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
m2m_wifi_enable_monitoring_mode

Asynchronous wi-fi monitoring enable mode (Promiscuous mode) function.

This function enables the monitoring mode, which starts transmission of the packets based on the filter information passed in as a parameter. All packets that meet the filtering criteria are passed to the application layer, to be handled by the assigned monitoring callback function. The monitoring callback function must be implemented before starting the monitoring mode, in-order to handle the packets received. Registering of the implemented callback function is through the callback pointer tpfAppMonCb in the tstrWifiInitParam structure. passed to m2m_wifi_init function at initialization.

Functions

NMI_API sint8 m2m_wifi_enable_monitoring_mode (tstrM2MWifiMonitorModeCtrl *pstrMtrCtrl)
 

NMI_API sint8 m2m_wifi_enable_monitoring_mode ( tstrM2MWifiMonitorModeCtrl pstrMtrCtrl)
Parameters
[in]pstrMtrCtrlPointer to tstrM2MWifiMonitorModeCtrl structure holding the Filtering parameters. A buffer to receive data should be set during initializing m2m_wifi_init(), or m2m_wifi_set_receive_buffer()
See Also
tstrM2MWifiMonitorModeCtrl tstrM2MWifiRxPacketInfo tstrWifiInitParam m2m_wifi_disable_monitoring_mode m2m_wifi_init m2m_wifi_set_receive_buffer
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The example demonstrates the main function where-by the monitoring enable function is called after the initialization of the driver and the packets are handled in the callback function.

#include "m2m_wifi.h"
#include "m2m_types.h"
//Declare receive buffer
uint8 gmgmt[1600];
//Callback functions
void wifi_cb(uint8 u8WiFiEvent, void * pvMsg)
{
;
}
void wifi_monitoring_cb(tstrM2MWifiRxPacketInfo *pstrWifiRxPacket, uint8 *pu8Payload, uint16 u16PayloadSize)
{
if((NULL != pstrWifiRxPacket) && (0 != u16PayloadSize)) {
if(MANAGEMENT == pstrWifiRxPacket->u8FrameType) {
M2M_INFO("***# MGMT PACKET #***\n");
} else if(DATA_BASICTYPE == pstrWifiRxPacket->u8FrameType) {
M2M_INFO("***# DATA PACKET #***\n");
} else if(CONTROL == pstrWifiRxPacket->u8FrameType) {
M2M_INFO("***# CONTROL PACKET #***\n");
}
}
}
int main()
{
//Register wifi_monitoring_cb
param->strEthInitParam.au8ethRcvBuf = gmgmt;
param->strEthInitParam.u16ethRcvBufSize = sizeof(gmgmt);
if(!m2m_wifi_init(&param)) {
//Enable Monitor Mode with filter to receive all data frames on channel 1
tstrM2MWifiMonitorModeCtrl strMonitorCtrl = {0};
strMonitorCtrl.u8ChannelID = 1;
strMonitorCtrl.u8FrameType = DATA_BASICTYPE;
strMonitorCtrl.u8FrameSubtype = M2M_WIFI_FRAME_SUB_TYPE_ANY; //Receive any subtype of data frame
while(1) {
}
}
return 0;
}
*

References hif_send(), m2m_memcpy(), M2M_REQ_DATA_PKT, M2M_REQ_GRP_WIFI, M2M_WIFI_CH_1, M2M_WIFI_CH_14, M2M_WIFI_REQ_ENABLE_MONITORING, NULL, and tstrM2MWifiMonitorModeCtrl::u8ChannelID.

Referenced by os_m2m_wifi_enable_monitoring_mode_imp().