WINC1500 IoT Software APIs: m2m_wifi_enable_monitoring_mode

WINC1500 IoT Software API

WINC1500 IoT Software APIs  19.5.2
WINC Software API Reference Manual
m2m_wifi_enable_monitoring_mode

Functions

NMI_API sint8 m2m_wifi_enable_monitoring_mode (tstrM2MWifiMonitorModeCtrl *pstrMtrCtrl, uint8 *pu8PayloadBuffer, uint16 u16BufferSize, uint16 u16DataOffset)
 

Detailed Description

Asynchronous Wi-Fi monitoring mode (Promiscuous mode) enabling function. This function enables the monitoring mode, thus allowing two operations to be performed: 1) Transmission of manually configured frames, through using the m2m_wifi_send_wlan_pkt function. 2) Reception of frames based on a defined filtering criteria When the monitoring mode is enabled, reception of all frames that satisfy the filter criteria passed in as a parameter is allowed, on the current wireless channel
. 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.

Function Documentation

◆ m2m_wifi_enable_monitoring_mode()

NMI_API sint8 m2m_wifi_enable_monitoring_mode ( tstrM2MWifiMonitorModeCtrl pstrMtrCtrl,
uint8 pu8PayloadBuffer,
uint16  u16BufferSize,
uint16  u16DataOffset 
)
Parameters
[in]pstrMtrCtrlPointer to tstrM2MWifiMonitorModeCtrl structure holding the filtering parameters.
[in]pu8PayloadBufferPointer to a buffer allocated by the application. The buffer SHALL hold the Data field of the WIFI RX Packet (Or a part from it). If it is set to NULL, the WIFI data payload will be discarded by the monitoring driver.
[in]u16BufferSizeThe total size of the pu8PayloadBuffer in bytes.
[in]u16DataOffsetStarting offset in the DATA FIELD of the received WIFI packet. The application may be interested in reading specific information from the received packet. It must assign the offset to the starting position of it relative to the DATA payload start.
Example, if the SSID is needed to be read from a PROBE REQ packet, the u16Offset MUST be set to 0.
Warning
When This mode is enabled, you can not be connected in any mode (Station, Access Point, or P2P).
See also
tstrM2MWifiMonitorModeCtrl tstrM2MWifiRxPacketInfo tstrWifiInitParam tenuM2mScanCh m2m_wifi_disable_monitoring_mode m2m_wifi_send_wlan_pkt m2m_wifi_send_ethernet_pkt
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.pfAppWifiCb = wifi_cb;
param.pfAppMonCb = wifi_monitoring_cb;
if(!m2m_wifi_init(&param)) {
//Enable Monitor Mode with filter to receive all data frames on channel 1
tstrM2MWifiMonitorModeCtrl strMonitorCtrl = {0};
strMonitorCtrl.u8ChannelID = M2M_WIFI_CH_1;
strMonitorCtrl.u8FrameType = DATA_BASICTYPE;
strMonitorCtrl.u8FrameSubtype = M2M_WIFI_FRAME_SUB_TYPE_ANY; //Receive any subtype of data frame
m2m_wifi_enable_monitoring_mode(&strMonitorCtrl, gmgmt, sizeof(gmgmt), 0);
while(1) {
}
}
return 0;
}
Generated on Thu Jan 26 2017 22:15:21 for WINC1500 IoT Software APIs by   doxygen 1.8.13