Functions
Functions
Collaboration diagram for Functions:

Functions

NMI_API sint8 m2m_wifi_ble_api_send (uint8 *msg, uint32 len)
 
NMI_API sint8 m2m_wifi_ble_set_gain_table (uint8 table_idx)
 Asynchronous API that notifies the WINC with the Gain Table index from Flash that should use to configure the WiFi and BLE gains. More...
 
NMI_API sint8 m2m_wifi_connect (char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *pvAuthInfo, uint16 u16Ch)
 Asynchronous API to request connection to a specified access point. More...
 
NMI_API sint8 m2m_wifi_connect_sc (char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *pvAuthInfo, uint16 u16Ch, uint8 u8SaveCred)
 Asynchronous API to request connection to a specific AP with option to store credentials in flash. More...
 
NMI_API sint8 m2m_wifi_default_connect (void)
 Asynchronous API that attempts to reconnect to the last-associated access point. More...
 
NMI_API sint8 m2m_wifi_deinit (void *arg)
 Synchronous API that de-initialises the WINC driver. More...
 
NMI_API sint8 m2m_wifi_disable_ap (void)
 Synchronous API to disable access point mode on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_disable_monitoring_mode (void)
 Asynchronous API to disable Wi-Fi monitoring (promiscuous receive) mode. More...
 
NMI_API sint8 m2m_wifi_disconnect (void)
 Synchronous API to request disconnection from a network. More...
 
NMI_API sint8 m2m_wifi_download_mode (void)
 Synchronous API that prepares the WINC IC to enter firmware or certificate download mode. More...
 
NMI_API sint8 m2m_wifi_enable_ap (CONST tstrM2MAPConfig *pstrM2MAPConfig)
 Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_enable_dhcp (uint8 u8DhcpEn)
 Asynchronous function to control the DHCP client functionality within the WINC IC. More...
 
sint8 m2m_wifi_enable_firmware_logs (uint8 u8Enable)
 Enable or Disable logs in run time (Disable Firmware logs will enhance the firmware start-up time and performance) More...
 
NMI_API sint8 m2m_wifi_enable_mac_mcast (uint8 *pu8MulticastMacAddress, uint8 u8AddRemove)
 Asynchronous API to add or remove MAC addresses in the multicast filter. More...
 
NMI_API sint8 m2m_wifi_enable_monitoring_mode (tstrM2MWifiMonitorModeCtrl *pstrMtrCtrl, uint8 *pu8PayloadBuffer, uint16 u16BufferSize, uint16 u16DataOffset)
 Asynchronous call to enable Wi-Fi monitoring (promiscuous receive) mode. More...
 
NMI_API sint8 m2m_wifi_enable_sntp (uint8 bEnable)
 Asynchronous API to enable or disable the SNTP client running on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_get_connection_info (void)
 Asynchronous API for retrieving the WINC IC's connection status. More...
 
NMI_API sint8 m2m_wifi_get_mac_address (uint8 *pu8MacAddr)
 Synchronous API to retrieve the MAC address currently in use on the device. More...
 
NMI_API uint8 m2m_wifi_get_num_ap_found (void)
 Synchronous API to retrieve the number of AP's found during the last scan operation. More...
 
NMI_API sint8 m2m_wifi_get_otp_mac_address (uint8 *pu8MacAddr, uint8 *pu8IsValid)
 Synchronous API to query the MAC address programmed into the WINC ICs OTP memory. More...
 
NMI_API uint8 m2m_wifi_get_sleep_mode (void)
 Synchronous API to retrieve the current power save mode of the WINC IC. More...
 
NMI_API sint8 m2m_wifi_get_sytem_time (void)
 Asynchronous API to obtain the system time in use by the WINC IC. More...
 
NMI_API sint8 m2m_wifi_handle_events (void *arg)
 Synchronous M2M event handler function. More...
 
NMI_API sint8 m2m_wifi_init (tstrWifiInitParam *pWifiInitParam)
 Synchronous API that initialises the WINC driver. More...
 
sint8 m2m_wifi_init_hold (void)
 First part of m2m_wifi_init, up to the point of initializing spi for flash access. More...
 
sint8 m2m_wifi_init_start (tstrWifiInitParam *param)
 Second part of m2m_wifi_init, continuing from where m2m_wifi_init_hold left off. More...
 
NMI_API sint8 m2m_wifi_p2p (uint8 u8Channel)
 Asynchronous API for enabling Wi-Fi Direct (P2P) mode in the WINC IC. More...
 
NMI_API sint8 m2m_wifi_p2p_disconnect (void)
 Synchronous API to disable Wi-Fi Direct (P2P) Mode on the WINC IC. More...
 
sint8 m2m_wifi_reinit (tstrWifiInitParam *param)
 Deinitialize and reinitialize wifi. Resets the WINC. Parameter may be set to NULL, in which case there is no change to the parameters given at initialization. More...
 
sint8 m2m_wifi_reinit_hold (void)
 First part of m2m_wifi_reinit, up to the point of initializing spi for flash access. More...
 
sint8 m2m_wifi_reinit_start (tstrWifiInitParam *param)
 Second part of m2m_wifi_reinit, continuing from where m2m_wifi_reinit_hold left off. More...
 
NMI_API sint8 m2m_wifi_req_curr_rssi (void)
 Asynchronous API to request the current Receive Signal Strength (RSSI) of the current connection. More...
 
NMI_API sint8 m2m_wifi_req_restrict_ble (void)
 Asynchronous API to request restricting of BLE functionality by placing the BLE processor in a low power state. It is recommended to do this if it is know that BLE functionality will not be used for any significant length of time. More...
 
NMI_API sint8 m2m_wifi_req_scan_result (uint8 index)
 Asynchronous API to request the information of an access point discovered via scanning. More...
 
NMI_API sint8 m2m_wifi_req_unrestrict_ble (void)
 Asynchronous API to request un-restricting of BLE functionality by reverting the BLE processor to full power mode. More...
 
NMI_API sint8 m2m_wifi_request_dhcp_client (void)
 Legacy (deprecated) Asynchronous API for starting a DHCP client on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_request_dhcp_server (uint8 *addr)
 Legacy (deprecated) Asynchronous function to start a DHCP client on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_request_scan (uint8 ch)
 Asynchronous API to request the WINC IC perform a scan for networks. More...
 
sint8 m2m_wifi_request_scan_passive (uint8 ch)
 
NMI_API sint8 m2m_wifi_request_sleep (uint32 u32SlpReqTime)
 Asynchronous API to place the WINC IC into sleep mode for a specified period of time. More...
 
NMI_API sint8 m2m_wifi_send_ethernet_pkt (uint8 *pu8Packet, uint16 u16PacketSize)
 Asynchronous API to queue an Ethernet packet for transmission by the WINC IC. More...
 
NMI_API sint8 m2m_wifi_send_wlan_pkt (uint8 *pu8WlanPacket, uint16 u16WlanHeaderLength, uint16 u16WlanPktSize)
 Asynchronous API to queue a raw Wi-Fi packet for transmission by the WINC IC. More...
 
sint8 m2m_wifi_set_battery_voltage (uint16 u16BattVoltx100)
 Enable or Disable logs in run time (Disable Firmware logs will enhance the firmware start-up time and performance) More...
 
NMI_API sint8 m2m_wifi_set_cust_InfoElement (uint8 *pau8M2mCustInfoElement)
 Asynchronous API to add or remove a user-defined Information Element. More...
 
NMI_API sint8 m2m_wifi_set_device_name (uint8 *pu8DeviceName, uint8 u8DeviceNameLength)
 Asynchronous API to set the Wi-Fi Direct "Device Name" of the WINC IC. More...
 
NMI_API sint8 m2m_wifi_set_lsn_int (tstrM2mLsnInt *pstrM2mLsnInt)
 Asynchronous API to set Wi-Fi listen interval for power save operation. More...
 
NMI_API sint8 m2m_wifi_set_mac_address (uint8 au8MacAddress[6])
 Synchronous API for assigning a MAC address to the WINC IC. More...
 
sint8 m2m_wifi_set_power_profile (uint8 u8PwrMode)
 Change the power profile mode. More...
 
NMI_API sint8 m2m_wifi_set_receive_buffer (void *pvBuffer, uint16 u16BufferLen)
 Asynchronous API to set or change the size of the WINC IC's receive buffer. More...
 
NMI_API sint8 m2m_wifi_set_scan_options (tstrM2MScanOption *ptstrM2MScanOption)
 Synchronous API for configuring the behaviour of the WINC IC's network scanning functions. More...
 
NMI_API sint8 m2m_wifi_set_scan_region (uint16 ScanRegion)
 Synchronous API for configuring the regulatory restrictions that may affect the WINC ICs scanning behaviour. More...
 
NMI_API sint8 m2m_wifi_set_sleep_mode (uint8 PsTyp, uint8 BcastEn)
 Synchronous API to set the power-save mode of the WINC IC. More...
 
NMI_API sint8 m2m_wifi_set_static_ip (tstrM2MIPConfig *pstrStaticIPConf)
 Synchronous API to manually assign a (static) IP address to the WINC IC. More...
 
NMI_API sint8 m2m_wifi_set_sytem_time (uint32 u32UTCSeconds)
 Asynchronous function for setting the system time within the WINC IC. More...
 
sint8 m2m_wifi_set_tx_power (uint8 u8TxPwrLevel)
 set the TX power tenuM2mTxPwrLevel More...
 
NMI_API sint8 m2m_wifi_start_provision_mode (tstrM2MAPConfig *pstrAPConfig, char *pcHttpServerDomainName, uint8 bEnableHttpRedirect)
 Asynchronous API for control of Wi-Fi provisioning functionality. More...
 
NMI_API sint8 m2m_wifi_stop_provision_mode (void)
 Synchronous API for terminating provisioning mode on the WINC IC. More...
 
NMI_API sint8 m2m_wifi_wps (uint8 u8TriggerType, const char *pcPinNumber)
 Asynchronous API to engage the WINC IC's Wi-Fi Protected Setup (enrolee) function. More...
 
NMI_API sint8 m2m_wifi_wps_disable (void)
 Synchronous API that disables Wi-Fi Protected Setup mode in the WINC IC. More...
 
NMI_API void m2m_wifi_yield (void)
 Yield from processing more synchronous M2M events. More...
 

Detailed Description

Function Documentation

◆ m2m_wifi_ble_api_send()

NMI_API sint8 m2m_wifi_ble_api_send ( uint8 msg,
uint32  len 
)

Definition at line 1479 of file m2m_wifi.c.

◆ m2m_wifi_ble_set_gain_table()

NMI_API sint8 m2m_wifi_ble_set_gain_table ( uint8  table_idx)

Asynchronous API that notifies the WINC with the Gain Table index from Flash that should use to configure the WiFi and BLE gains.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.

Definition at line 451 of file m2m_wifi.c.

◆ m2m_wifi_connect()

NMI_API sint8 m2m_wifi_connect ( char *  pcSsid,
uint8  u8SsidLen,
uint8  u8SecType,
void *  pvAuthInfo,
uint16  u16Ch 
)

Asynchronous API to request connection to a specified access point.

Prior to a successful connection, the application developers must know the SSID, the security type, and the authentication parameters of the target access point; knowledge of the channel number is optional.

The connection status will be indicated to the application via a M2M_WIFI_RESP_CON_STATE_CHANGED event. The status will be one of those defined in tenuM2mConnState withe M2M_WIFI_CONNECTED indicating a successful connection.

Parameters
[in]pcSsidA buffer holding the SSID corresponding to the requested AP.
[in]u8SsidLenLength of the given SSID (not including the NULL termination). A length less than ZERO or greater than the maximum defined SSID M2M_MAX_SSID_LEN will result in a negative error M2M_ERR_FAIL.
[in]u8SecTypeWi-Fi security type security for the network. It can be one of the following types: -M2M_WIFI_SEC_OPEN -M2M_WIFI_SEC_WEP -M2M_WIFI_SEC_WPA_PSK -M2M_WIFI_SEC_802_1X A value outside these possible values will result in a negative return error M2M_ERR_FAIL.
[in]pvAuthInfoAuthentication parameters required for completing the connection. It is type is based on the security type. If the authentication parameters are NULL or are greater than the maximum length of the authentication parameters length as defined by M2M_MAX_PSK_LEN a negative error will return M2M_ERR_FAIL(-12) indicating connection failure.
[in]u16ChWi-Fi channel number as defined in tenuM2mScanCh enumeration. Specification of a channel number greater than M2M_WIFI_CH_14 returns a negative error M2M_ERR_FAIL(-12) unless the value is M2M_WIFI_CH_ALL (255). A channel number of M2M_WIFI_CH_ALL indicates that the firmware should scan all channels to find the SSID specified in parameter pcSsid.

Failure to find the connection match will return a negative error M2M_DEFAULT_CONN_SCAN_MISMATCH.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
Prior to a successful connection request, the wi-fi driver must have been successfully initialized through the call of the m2m_wifi_init function
See also
tuniM2MWifiAuth tstr1xAuthCredentials tstrM2mWifiWepParams
Warning
  • This function must be called in station mode only.
  • Successful completion of this function does not guarantee success of the WIFI connection, and a negative return value indicates only locally-detected errors.

Definition at line 577 of file m2m_wifi.c.

◆ m2m_wifi_connect_sc()

NMI_API sint8 m2m_wifi_connect_sc ( char *  pcSsid,
uint8  u8SsidLen,
uint8  u8SecType,
void *  pvAuthInfo,
uint16  u16Ch,
uint8  u8SaveCred 
)

Asynchronous API to request connection to a specific AP with option to store credentials in flash.

Prior to a successful connection, the application developers must know the SSID, the security type, and the authentication parameters of the target access point; knowledge of the channel number is optional.

The connection status will be indicated to the application via a M2M_WIFI_RESP_CON_STATE_CHANGED event. The status will be one of those defined in tenuM2mConnState withe M2M_WIFI_CONNECTED indicating a successful connection.

The only difference between this function and m2m_wifi_connect, is the option to save the acess point info ( SSID, password...etc) into flash.

Parameters
[in]pcSsidA buffer holding the SSID corresponding to the requested AP.
[in]u8SsidLenLength of the given SSID (not including the NULL termination). A length less than ZERO or greater than the maximum defined SSID M2M_MAX_SSID_LEN will result in a negative error M2M_ERR_FAIL.
[in]u8SecTypeWi-Fi security type security for the network. It can be one of the following types: -M2M_WIFI_SEC_OPEN -M2M_WIFI_SEC_WEP -M2M_WIFI_SEC_WPA_PSK -M2M_WIFI_SEC_802_1X A value outside these possible values will result in a negative return error M2M_ERR_FAIL.
[in]pvAuthInfoAuthentication parameters required for completing the connection. It is type is based on the security type. If the authentication parameters are NULL or are greater than the maximum length of the authentication parameters length as defined by M2M_MAX_PSK_LEN a negative error will return M2M_ERR_FAIL(-12) indicating connection failure.
[in]u16ChWi-Fi channel number as defined in tenuM2mScanCh enumeration. Specification of a channel number greater than M2M_WIFI_CH_14 returns a negative error M2M_ERR_FAIL(-12) unless the value is M2M_WIFI_CH_ALL (255). A channel number of M2M_WIFI_CH_ALL indicates that the firmware should scan all channels to find the SSID specified in parameter pcSsid.

Failure to find the connection match will return a negative error M2M_DEFAULT_CONN_SCAN_MISMATCH.

Parameters
[in]u8SaveCredOption to store the acess point SSID and password into the WINC flash memory or not.
Precondition
Prior to a successful connection request, the wi-fi driver must have been successfully initialized through the call of the m2m_wifi_init function
See also
tuniM2MWifiAuth tstr1xAuthCredentials tstrM2mWifiWepParams
Warning
  • This function must be called in station mode only.
  • Successful completion of this function does not guarantee success of the WIFI connection, and a negative return value indicates only locally-detected errors.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.

Definition at line 581 of file m2m_wifi.c.

◆ m2m_wifi_default_connect()

NMI_API sint8 m2m_wifi_default_connect ( void  )

Asynchronous API that attempts to reconnect to the last-associated access point.

An application calling this function will cause the firmware to attempt to reconnect to the access point with which it had last successfully connected. A failure to connect will result in a response of M2M_WIFI_RESP_DEFAULT_CONNECT indicating a connection error as defined in the structure tstrM2MDefaultConnResp.

Possible errors are:

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
Prior to connecting, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
  • This function maybe called in station mode only.
  • It is important to note that successful completion of a call to m2m_wifi_default_connect() does not guarantee success of the WIFI connection; a negative return value indicates only locally-detected errors.
See also
m2m_wifi_connect

Definition at line 572 of file m2m_wifi.c.

◆ m2m_wifi_deinit()

NMI_API sint8 m2m_wifi_deinit ( void *  arg)

Synchronous API that de-initialises the WINC driver.

This disables the host interface and frees any resources used by the M2M_WIFI layer. The function must be called in the during the final phases of closing the application to ensure that all resources have been correctly released.

Parameters
[in]argOpaque argument, not used in current implementation. Application should use null.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.

Definition at line 534 of file m2m_wifi.c.

◆ m2m_wifi_disable_ap()

NMI_API sint8 m2m_wifi_disable_ap ( void  )

Synchronous API to disable access point mode on the WINC IC.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
m2m_wifi_enable_ap

Definition at line 890 of file m2m_wifi.c.

◆ m2m_wifi_disable_monitoring_mode()

NMI_API sint8 m2m_wifi_disable_monitoring_mode ( void  )

Asynchronous API to disable Wi-Fi monitoring (promiscuous receive) mode.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
m2m_wifi_enable_monitoring_mode

◆ m2m_wifi_disconnect()

NMI_API sint8 m2m_wifi_disconnect ( void  )

Synchronous API to request disconnection from a network.

This function will cause the WINC IC to disconnect from any currently connected access point.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
Disconnection must be made to a successfully connected AP. If the WINC is not in the connected state, a call to this function will hold insignificant.
Warning
This function must be called in station mode only.
See also
m2m_wifi_connect m2m_wifi_default_connect

Definition at line 693 of file m2m_wifi.c.

◆ m2m_wifi_download_mode()

NMI_API void m2m_wifi_download_mode ( void  )

Synchronous API that prepares the WINC IC to enter firmware or certificate download mode.

The WINC board is prepared for download, through initializations for the WINC driver including bus initializations and interrupt enabling, it also halts the chip, to allow for the firmware downloads. Firmware can be downloaded through a number of interfaces, UART, I2C and SPI.

Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Definition at line 322 of file m2m_wifi.c.

◆ m2m_wifi_enable_ap()

NMI_API sint8 m2m_wifi_enable_ap ( CONST tstrM2MAPConfig pstrM2MAPConfig)

Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC IC.

The WINC IC supports the ability to operate as an access point with the limitation that:

  • only 1 station may be associated at any one time
  • open system and WEP are the only security suites supported.
Parameters
[in]pstrM2MAPConfigA structure holding the AP configurations.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
This function is not allowed in P2P or STA modes.
Precondition
See also
tpfAppWifiCb tenuM2mSecType m2m_wifi_init M2M_WIFI_REQ_DHCP_CONF tstrM2mWifiStateChanged tstrM2MAPConfig

Example

The code snippet demonstrates how the AP mode is enabled after the driver is initialized in the application's main function and the handling of the event M2M_WIFI_REQ_DHCP_CONF, to indicate successful connection.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
uint8 *pu8IPAddress = (uint8*)pvMsg;
printf("Associated STA has IP Address \"%u.%u.%u.%u\"\n",pu8IPAddress[0],pu8IPAddress[1],pu8IPAddress[2],pu8IPAddress[3]);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
tstrM2MAPConfig apConfig;
strcpy(apConfig.au8SSID, "WINC_SSID");
apConfig.u8ListenChannel = 1;
apConfig.u8SsidHide = 0;
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[0] = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}

Definition at line 881 of file m2m_wifi.c.

◆ m2m_wifi_enable_dhcp()

NMI_API sint8 m2m_wifi_enable_dhcp ( uint8  u8DhcpEn)

Asynchronous function to control the DHCP client functionality within the WINC IC.

This function allows the application to control the behaviour of the DHCP client function within the WINC IC once it has associated with an access point. DHCP client functionality is enabled by default.

Parameters
[in]u8DhcpEnThe state of the DHCP client feature after successful association with an access point:
  • 0: DHCP client will be disabled after connection.
  • 1: DHCP client will be enabled after connection.
Returns
The function SHALL return 0 for success and a negative value otherwise.
Warning
  • DHCP client is enabled by default
  • This Function should be called to disable DHCP client operation before using m2m_wifi_set_static_ip
See also
m2m_wifi_set_static_ip()

Definition at line 738 of file m2m_wifi.c.

◆ m2m_wifi_enable_firmware_logs()

NMI_API sint8 m2m_wifi_enable_firmware_logs ( uint8  u8Enable)

Enable or Disable logs in run time (Disable Firmware logs will enhance the firmware start-up time and performance)

Parameters
[in]u8EnableSet 1 to enable the logs 0 for disable
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
DISABLE_FIRMWARE_LOGS (build option to disable logs from initializations)
Parameters
[in]u8EnableSet 1 to enable the logs 0 for disable
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
DISABLE_FIRMWARE_LOGS (build option to disable logs from initializations)
Precondition
m2m_wifi_init
Warning

Definition at line 1346 of file m2m_wifi.c.

◆ m2m_wifi_enable_mac_mcast()

NMI_API sint8 m2m_wifi_enable_mac_mcast ( uint8 pu8MulticastMacAddress,
uint8  u8AddRemove 
)

Asynchronous API to add or remove MAC addresses in the multicast filter.

This function allows the application to configure the capability of the WINC IC to receive multicast packets when operating in bypass mode.

Parameters
[in]pu8MulticastMacAddressPointer to MAC address
[in]u8AddRemoveA flag to add or remove the MAC ADDRESS, based on the following values:
  • 0 : remove MAC address
  • 1 : add MAC address
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Note
Maximum number of MAC addresses that could be added is 8.
Warning
This functionality is not supported by current WINC firmware.

◆ m2m_wifi_enable_monitoring_mode()

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

Asynchronous call to enable Wi-Fi monitoring (promiscuous receive) mode.

This function places the reciver into a mode where all frames (or those matching a set of filter criteria) received on air are passed to the application.

A dedicated callback function, tpfAppMonCb, must be registered to handle frames received in promiscuous mode. This is done via an instance of a tstrWifiInitParam structure and a call to the m2m_wifi_init function.

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.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
This mode available as sniffer ONLY, you can not be connected in any modes (Station, Access Point, or P2P).
See also

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.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;
}

◆ m2m_wifi_enable_sntp()

NMI_API sint8 m2m_wifi_enable_sntp ( uint8  bEnable)

Asynchronous API to enable or disable the SNTP client running on the WINC IC.

The SNTP client is enabled by default during chip initialisation. This function can be used to disable or subsequently re-enable the service.

The service is capable of syncrhonising the WINC's system clock to the UTC time from a well-known (and trusted) time server, for example "time.nist.gov". By default the SNTP client will update the system time once every 24 hours. The ability to track the time accurately is important for various applications such as checking expiry of X509 certificates during TLS session establishment.

It is highly recommended to leave SNTP enabled if there is no alternative source of timing information. For systems including an RTC device, SNTP may not be needed and the WINC IC's time may be set using the m2m_wifi_set_sytem_time function.

Parameters
[in]bEnableEnables or disables the SNTP service
  • '0' : disable SNTP
  • '1' : enable SNTP
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
m2m_wifi_set_sytem_time

Definition at line 1290 of file m2m_wifi.c.

◆ m2m_wifi_get_connection_info()

sint8 m2m_wifi_get_connection_info ( void  )

Asynchronous API for retrieving the WINC IC's connection status.

Requests the connection status from the WINC IC including information regarding any access point to which it is currently connected, or any non-AP station that is connected to the WINC. All information will be returned to the application via the Wi-Fi notifiction callback and the event M2M_WIFI_RESP_CONN_INFO.

The connection info can be retrieved using the structure tstrM2MConnInfo which contains:

  • Connection Security
  • Connection RSSI
  • Remote MAC address
  • Remote IP address
  • SSID of the network (in cases where the WINC is in non-AP mode)
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the initialization m2m_wifi_init function.
  • The event M2M_WIFI_RESP_CONN_INFO must be handled in the callback to receive the requested connection info.
Warning
  • In case of WINC AP mode or P2P mode, the SSID field shall be a NULL string.
See also
M2M_WIFI_RESP_CONN_INFO, tstrM2MConnInfo

Example

The code snippet shows an example of how wi-fi connection information is retrieved .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MConnInfo *pstrConnInfo = (tstrM2MConnInfo*)pvMsg;
printf("CONNECTED AP INFO\n");
printf("SSID : %s\n",pstrConnInfo->acSSID);
printf("SEC TYPE : %d\n",pstrConnInfo->u8SecType);
printf("Signal Strength : %d\n", pstrConnInfo->s8RSSI);
printf("Local IP Address : %d.%d.%d.%d\n",
pstrConnInfo->au8IPAddr[0] , pstrConnInfo->au8IPAddr[1], pstrConnInfo->au8IPAddr[2], pstrConnInfo->au8IPAddr[3]);
}
break;
{
// Get the current AP information.
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// connect to the default AP
while(1)
{
}
}
}

Definition at line 1268 of file m2m_wifi.c.

◆ m2m_wifi_get_mac_address()

NMI_API sint8 m2m_wifi_get_mac_address ( uint8 pu8MacAddr)

Synchronous API to retrieve the MAC address currently in use on the device.

Request the current MAC address of the device (the working mac address). (the function is Blocking until response received)

This function obtains the MAC address that is currently in use by the device. If the function returns with M2M_SUCCESS then the content of the memory referenced by pu8MacAddr will be populated with the 6 byte MAC address; otherwise, that memory will be left unchanged.

Parameters
[out]pu8MacAddrPointer to a buffer in memory containing a 6-byte MAC address (provided function returns MEM_SUCCESS)
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See also
m2m_wifi_get_otp_mac_address
Parameters
[out]pu8MacAddrOutput MAC address buffer of 6 bytes size.
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise.
See also
m2m_wifi_get_otp_mac_address
Precondition
m2m_wifi_init required to call any WIFI/socket function

Definition at line 975 of file m2m_wifi.c.

◆ m2m_wifi_get_num_ap_found()

NMI_API uint8 m2m_wifi_get_num_ap_found ( void  )

Synchronous API to retrieve the number of AP's found during the last scan operation.

Reads the number of AP's found in the last Scan Request, The function read the number of AP's from global variable which updated in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE.

This function allows the application to recover the number of access points discovered during the most recent scan activity. This is achieved via a global variable in the WINC driver that is populated when receiving the M2M_WIFI_RESP_SCAN_DONE event.

Returns
Return the number of AP's found in the last Scan Request.
See also
m2m_wifi_request_scan M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT
Precondition
  • m2m_wifi_request_scan must be called first to ensure up to date results are available.
Warning

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
See also
m2m_wifi_request_scan
Returns
Return the number of AP's found in the last Scan Request.
Precondition
m2m_wifi_request_scan need to be called first
Warning
That function need to be called in the wifi_cb in M2M_WIFI_RESP_SCAN_DONE, calling that function in any other place will return undefined/undated numbers. Function used only in STA mode only.

Definition at line 1027 of file m2m_wifi.c.

◆ m2m_wifi_get_otp_mac_address()

NMI_API sint8 m2m_wifi_get_otp_mac_address ( uint8 pu8MacAddr,
uint8 pu8IsValid 
)

Synchronous API to query the MAC address programmed into the WINC ICs OTP memory.

Request the MAC address stored on the OTP (one time programmable) memory of the device. (the function is Blocking until response received)

This function attempts to read the device's MAC address from the One Time Programmable (OTP) memory on the IC. The presence (yes or no) of a MAC address in the OTP memory and, in the case of it being present, its value are returned via RAM pointed to by the input arguments.

Parameters
[out]pu8MacAddrOutput MAC address buffer 6 bytes in size. This is valid only if *pu8Valid equals 1.
[out]pu8IsValidA boolean value set by the callee to indicate the validity of pu8MacAddr in OTP. If no MAC has been programmed in the OTP the value of this parameter will be zero; otherwise it will be non-zero.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See also
m2m_wifi_get_mac_address
Parameters
[out]pu8MacAddrOutput MAC address buffer of 6 bytes size. Valid only if *pu8Valid=1.
[out]pu8IsValidA output boolean value to indicate the validity of pu8MacAddr in OTP. Output zero if the OTP memory is not programmed, non-zero otherwise.
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise.
See also
m2m_wifi_get_mac_address
Precondition
m2m_wifi_init required to call any WIFI/socket function

Definition at line 951 of file m2m_wifi.c.

◆ m2m_wifi_get_sleep_mode()

NMI_API uint8 m2m_wifi_get_sleep_mode ( void  )

Synchronous API to retrieve the current power save mode of the WINC IC.

Get the current Power save mode.

Returns
The current operating power saving mode. The value will be one of those from the enumerated type tenuPowerSaveModes.
See also
tenuPowerSaveModes m2m_wifi_set_sleep_mode
Returns
The current operating power saving mode.
See also
tenuPowerSaveModes , m2m_wifi_set_sleep_mode

Definition at line 1037 of file m2m_wifi.c.

◆ m2m_wifi_get_sytem_time()

NMI_API sint8 m2m_wifi_get_sytem_time ( void  )

Asynchronous API to obtain the system time in use by the WINC IC.

This function will request that the WINC IC send it's current system time to the application. The information will arrive at the application via the tpfAppWifiCb and event M2M_WIFI_RESP_GET_SYS_TIME.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
See also
m2m_wifi_enable_sntp tstrSystemTime
Note
get the system time from the sntp client using the API m2m_wifi_get_sytem_time.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Definition at line 1285 of file m2m_wifi.c.

◆ m2m_wifi_handle_events()

NMI_API sint8 m2m_wifi_handle_events ( void *  arg)

Synchronous M2M event handler function.

This function is responsible for handling interrupts received from the WINC firmware. Applications should call this function periodically in-order to receive the events that are to be handled by the callback functions implemented by the application.

Definition at line 567 of file m2m_wifi.c.

◆ m2m_wifi_init()

NMI_API sint8 m2m_wifi_init ( tstrWifiInitParam pWifiInitParam)

Synchronous API that initialises the WINC driver.

This function initializes the driver by registering the call back function for M2M_WIFI layer (also the call back function for bypass mode/monitoring mode if defined), initializing the host interface layer and the bus interfaces. Wi-Fi callback registering is essential to allow the handling of the events received, in response to the asynchronous Wi-Fi operations.

Following are the possible Wi-Fi events that are expected to be received through the callback function (provided by the application):

Any application using the WINC driver must call this function at the start of its main function.

Parameters
[in]pWifiInitParamThis is a pointer to the tstrWifiInitParam structure which contains pointers to the application WIFI layer callback, monitoring mode callback and tstrEthInitParam structure (which contains initialisation settings for bypass mode).
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
Prior to this function call, application users must provide a callback function responsible for receiving all the wi-fi events that are received on the M2M_WIFI layer.
Warning
Failure to successfully complete function indicates that the driver couldn't be initialized and a fatal error will prevent the application from proceeding.
See also
m2m_wifi_deinit tenuM2mStaCmd

Definition at line 523 of file m2m_wifi.c.

◆ m2m_wifi_init_hold()

sint8 m2m_wifi_init_hold ( void  )

First part of m2m_wifi_init, up to the point of initializing spi for flash access.

See also
m2m_wifi_init

Definition at line 463 of file m2m_wifi.c.

◆ m2m_wifi_init_start()

sint8 m2m_wifi_init_start ( tstrWifiInitParam param)

Second part of m2m_wifi_init, continuing from where m2m_wifi_init_hold left off.

Parameters
[in]paramStructure containing configration details
See also
m2m_wifi_init

Definition at line 472 of file m2m_wifi.c.

◆ m2m_wifi_p2p()

NMI_API sint8 m2m_wifi_p2p ( uint8  u8Channel)

Asynchronous API for enabling Wi-Fi Direct (P2P) mode in the WINC IC.

Parameters
[in]u8ChannelP2P Listen RF channel.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
Warning
  • This function is not available in the WINC 3400
  • This function is not allowed in AP or STA modes.
See also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_CON_STATE_CHANGED M2M_WIFI_REQ_DHCP_CONF tstrM2mWifiStateChanged

Example

The code snippet shows an example of how the p2p mode operates.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
M2M_INFO("Wifi State :: %s :: ErrCode %d\n", pstrWifiState->u8CurrState? "CONNECTED":"DISCONNECTED",pstrWifiState->u8ErrCode);
// Do something
}
break;
{
uint8 *pu8IPAddress = (uint8*)pvMsg;
printf("P2P IP Address \"%u.%u.%u.%u\"\n",pu8IPAddress[0],pu8IPAddress[1],pu8IPAddress[2],pu8IPAddress[3]);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Trigger P2P
while(1)
{
}
}
}

Definition at line 859 of file m2m_wifi.c.

◆ m2m_wifi_p2p_disconnect()

NMI_API sint8 m2m_wifi_p2p_disconnect ( void  )

Synchronous API to disable Wi-Fi Direct (P2P) Mode on the WINC IC.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
m2m_wifi_p2p

Definition at line 875 of file m2m_wifi.c.

◆ m2m_wifi_reinit()

sint8 m2m_wifi_reinit ( tstrWifiInitParam param)

Deinitialize and reinitialize wifi. Resets the WINC. Parameter may be set to NULL, in which case there is no change to the parameters given at initialization.

Definition at line 552 of file m2m_wifi.c.

◆ m2m_wifi_reinit_hold()

sint8 m2m_wifi_reinit_hold ( void  )

First part of m2m_wifi_reinit, up to the point of initializing spi for flash access.

See also
m2m_wifi_reinit

Definition at line 543 of file m2m_wifi.c.

◆ m2m_wifi_reinit_start()

sint8 m2m_wifi_reinit_start ( tstrWifiInitParam param)

Second part of m2m_wifi_reinit, continuing from where m2m_wifi_reinit_hold left off.

See also
m2m_wifi_reinit

Definition at line 548 of file m2m_wifi.c.

◆ m2m_wifi_req_curr_rssi()

NMI_API sint8 m2m_wifi_req_curr_rssi ( void  )

Asynchronous API to request the current Receive Signal Strength (RSSI) of the current connection.

Request the current RSSI for the current connected AP, the response received in wifi_cb M2M_WIFI_RESP_CURRENT_RSSI.

This function will result in the application receiving the RSSI via a M2M_WIFI_RESP_CURRENT_RSSI event.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition

Example

The code snippet demonstrates how the RSSI request is called in the application's main function and the handling of event received in the callback.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
sint8 *rssi = (sint8*)pvMsg;
M2M_INFO("ch rssi %d\n",*rssi);
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
See also
M2M_WIFI_RESP_CURRENT_RSSI
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise.

Definition at line 903 of file m2m_wifi.c.

◆ m2m_wifi_req_restrict_ble()

NMI_API sint8 m2m_wifi_req_restrict_ble ( void  )

Asynchronous API to request restricting of BLE functionality by placing the BLE processor in a low power state. It is recommended to do this if it is know that BLE functionality will not be used for any significant length of time.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered during initialization. Registration of the callback is done via the m2m_wifi_init API.

Definition at line 910 of file m2m_wifi.c.

◆ m2m_wifi_req_scan_result()

NMI_API sint8 m2m_wifi_req_scan_result ( uint8  index)

Asynchronous API to request the information of an access point discovered via scanning.

Reads the AP information from the Scan Result list with the given index, the response received in wifi_cb M2M_WIFI_RESP_SCAN_RESULT, the response pointer should be casted with tstrM2mWifiscanResult structure.

This function allows the information of any discovered access point to be retrieved. When a scan is completed, the application is informed of the number of networks (access points) discovered. Calling this function with an index, N, will return the information for the Nth access point. The information will be returned to the application via a M2M_WIFI_RESP_SCAN_RESULT event, and the response data may be obtained through casting the pointer (pvMsg) to tstrM2mWifiscanResult.

Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
tstrM2mWifiscanResult m2m_wifi_get_num_ap_found m2m_wifi_request_scan
Precondition
  • m2m_wifi_request_scan must be called first to ensure up to date results are available.
  • A Wi-Fi notification callback of type tpfAppWifiCb must be implemented and registered in order to receive scan data after calling this function. Registration of the callback is done via the m2m_wifi_init function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested connection information.
Warning
  • This API is valid only for STA mode, it may be called regardless of connection state (connected or disconnected).
  • Calling this function without first issuing a scan request may lead to stale data being recovered.
  • Application code should refrain from introducing significant delays between issuing the scan request and scan result requests.

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}
Parameters
[in]indexIndex for the requested result, the index range start from 0 till number of AP's found
See also
tstrM2mWifiscanResult,m2m_wifi_get_num_ap_found,m2m_wifi_request_scan
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise
Precondition
m2m_wifi_request_scan need to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
Warning
Function used only in STA mode only. the scan result updated only if scan request called, else it will be cashed in firmware for the host scan request result, which mean if large delay occur between the scan request and the scan result request, the result will not be up-to-date

Definition at line 1007 of file m2m_wifi.c.

◆ m2m_wifi_req_unrestrict_ble()

NMI_API sint8 m2m_wifi_req_unrestrict_ble ( void  )

Asynchronous API to request un-restricting of BLE functionality by reverting the BLE processor to full power mode.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered during initialization. Registration of the callback is done via the m2m_wifi_init API.

Definition at line 917 of file m2m_wifi.c.

◆ m2m_wifi_request_dhcp_client()

NMI_API sint8 m2m_wifi_request_dhcp_client ( void  )

Legacy (deprecated) Asynchronous API for starting a DHCP client on the WINC IC.

This is a legacy API and is no longer supported. Calls to this API will not result in any changes being made to the state of the WINC IC.

Returns
This function always returns M2M_SUCCESS.
Warning
  • This function has been deprecated. DHCP is used automatically when the WINC IC connects.

Definition at line 717 of file m2m_wifi.c.

◆ m2m_wifi_request_dhcp_server()

NMI_API sint8 m2m_wifi_request_dhcp_server ( uint8 addr)

Legacy (deprecated) Asynchronous function to start a DHCP client on the WINC IC.

This is a legacy API and is no longer supported. Calls to this API will not result in any changes being made to the state of the WINC IC.

Parameters
[in]addrThe address to issue to a connected client (only one client is supported)
Returns
This function always returns M2M_SUCCESS.
Warning
  • This function has been deprecated. DHCP is used automatically when the WINC IC connects.

Definition at line 722 of file m2m_wifi.c.

◆ m2m_wifi_request_scan()

NMI_API sint8 m2m_wifi_request_scan ( uint8  ch)

Asynchronous API to request the WINC IC perform a scan for networks.

Scan statuses are delivered to the application via the Wi-Fi event callback (tpfAppWifiCb) in three stages. The first step involves the event M2M_WIFI_RESP_SCAN_DONE which, if successful, provides the number of detected networks (access points). The application must then read the list of access points via multiple calls to the asynchronous m2m_wifi_req_scan_result API. For each call to this function, the application will receive (step three) the event M2M_WIFI_RESP_SCAN_RESULT.

Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh, with a value of M2M_WIFI_CH_ALL to scan all channels.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
This API is valid only for STA mode, it may be called regardless of connection state (connected or disconnected).
Precondition
See also
M2M_WIFI_RESP_SCAN_DONE
M2M_WIFI_RESP_SCAN_RESULT
tpfAppWifiCb
tstrM2mWifiscanResult
tenuM2mScanCh
m2m_wifi_init
m2m_wifi_handle_events
m2m_wifi_req_scan_result

Example

The code snippet demonstrates an example of how the scan request is called from the application's main function and the handling of the events received in response.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
static uint8 u8ScanResultIdx = 0;
switch(u8WiFiEvent)
{
{
tstrM2mScanDone *pstrInfo = (tstrM2mScanDone*)pvMsg;
printf("Num of AP found %d\n",pstrInfo->u8NumofCh);
if(pstrInfo->s8ScanState == M2M_SUCCESS)
{
u8ScanResultIdx = 0;
if(pstrInfo->u8NumofCh >= 1)
{
m2m_wifi_req_scan_result(u8ScanResultIdx);
u8ScanResultIdx ++;
}
else
{
printf("No AP Found Rescan\n");
}
}
else
{
printf("(ERR) Scan fail with error <%d>\n",pstrInfo->s8ScanState);
}
}
break;
{
tstrM2mWifiscanResult *pstrScanResult =(tstrM2mWifiscanResult*)pvMsg;
uint8 u8NumFoundAPs = m2m_wifi_get_num_ap_found();
printf(">>%02d RI %d SEC %s CH %02d BSSID %02X:%02X:%02X:%02X:%02X:%02X SSID %s\n",
pstrScanResult->u8index,pstrScanResult->s8rssi,
pstrScanResult->u8AuthType,
pstrScanResult->u8ch,
pstrScanResult->au8BSSID[0], pstrScanResult->au8BSSID[1], pstrScanResult->au8BSSID[2],
pstrScanResult->au8BSSID[3], pstrScanResult->au8BSSID[4], pstrScanResult->au8BSSID[5],
pstrScanResult->au8SSID);
if(u8ScanResultIdx < u8NumFoundAPs)
{
// Read the next scan result
u8ScanResultIdx ++;
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Scan all channels
while(1)
{
}
}
}

Definition at line 775 of file m2m_wifi.c.

◆ m2m_wifi_request_scan_passive()

sint8 m2m_wifi_request_scan_passive ( uint8  ch)
Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh, with a value of M2M_WIFI_CH_ALL to scan all channels.
Warning
This function is not allowed in P2P or AP modes. It works only for STA mode (both connected or disconnected states).
Precondition
See also
m2m_wifi_request_scan
M2M_WIFI_RESP_SCAN_DONE
M2M_WIFI_RESP_SCAN_RESULT
tpfAppWifiCb
tstrM2MScanOption
tstrM2mWifiscanResult
tenuM2mScanCh
m2m_wifi_init
m2m_wifi_handle_events
m2m_wifi_req_scan_result
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Definition at line 792 of file m2m_wifi.c.

◆ m2m_wifi_request_sleep()

NMI_API sint8 m2m_wifi_request_sleep ( uint32  u32SlpReqTime)

Asynchronous API to place the WINC IC into sleep mode for a specified period of time.

This function allows a WINC IC that is running in M2M_PS_MANUAL mode to be placed into sleep state for a specified period of time (measured in milliseconds).

Parameters
[in]u32SlpReqTimeThe time in ms that the WINC IC should sleep for
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
Warning
  • This API is currently unsupported on the WINC3400
See also
tenuPowerSaveModes m2m_wifi_set_sleep_mode

Definition at line 1075 of file m2m_wifi.c.

◆ m2m_wifi_send_ethernet_pkt()

NMI_API sint8 m2m_wifi_send_ethernet_pkt ( uint8 pu8Packet,
uint16  u16PacketSize 
)

Asynchronous API to queue an Ethernet packet for transmission by the WINC IC.

Parameters
[in]pu8PacketPointer to a buffer holding the whole Ethernet frame.
[in]u16PacketSizeThe size of the whole bytes in packet.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
Warning
This function is only available in builds supporting monitoring mode.

Definition at line 924 of file m2m_wifi.c.

◆ m2m_wifi_send_wlan_pkt()

NMI_API sint8 m2m_wifi_send_wlan_pkt ( uint8 pu8WlanPacket,
uint16  u16WlanHeaderLength,
uint16  u16WlanPktSize 
)

Asynchronous API to queue a raw Wi-Fi packet for transmission by the WINC IC.

Parameters
[in]pu8WlanPacketPointer to a buffer holding the whole WIFI frame.
[in]u16WlanHeaderLengthThe size of the WIFI packet header ONLY.
[in]u16WlanPktSizeThe size of the whole bytes in packet.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
Warning
This function is only available in builds supporting monitoring mode.

◆ m2m_wifi_set_battery_voltage()

NMI_API sint8 m2m_wifi_set_battery_voltage ( uint16  u16BattVoltx100)

Enable or Disable logs in run time (Disable Firmware logs will enhance the firmware start-up time and performance)

Parameters
[in]u16BattVoltx100battery voltage multiplied by 100
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
DISABLE_FIRMWARE_LOGS (build option to disable logs from initializations)
Precondition
m2m_wifi_init
Warning

Definition at line 1366 of file m2m_wifi.c.

◆ m2m_wifi_set_cust_InfoElement()

NMI_API sint8 m2m_wifi_set_cust_InfoElement ( uint8 pau8M2mCustInfoElement)

Asynchronous API to add or remove a user-defined Information Element.

This function allows the application to provide a custom Information Element to the WINC IC that will be included in all beacon and probe response frames.

Parameters
[in]pau8M2mCustInfoElementPointer to Buffer containing the IE to be used. If null, this removes any current custom IE. If non-null, the pointer must reference data in the following format:
               --------------- ---------- ---------- ------------------- -------- -------- ----------- ----------------------  
              | Byte[0]       | Byte[1]  | Byte[2]  | Byte[3:length1+2] | ..... | Byte[n] | Byte[n+1] | Byte[n+2:lengthx+2]  | 
              |---------------|----------|----------|-------------------|-------- --------|-----------|------------------| 
              | #of all Bytes | IE1 ID   | Length1  | Data1(Hex Coded)  | ..... | IEx ID  | Lengthx   | Datax(Hex Coded)     | 
               --------------- ---------- ---------- ------------------- -------- -------- ----------- ---------------------- 
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
  • Size of All elements combined must not exceed 255 byte.
  • Used in Access Point Mode

Example

The example demonstrates how the information elements are set using this function.

char elementData[21];
static char state = 0; // To Add, Append, and Delete
if(0 == state) { //Add 3 IEs
state = 1;
//Total Number of Bytes
elementData[0]=12;
//First IE
elementData[1]=200; elementData[2]=1; elementData[3]='A';
//Second IE
elementData[4]=201; elementData[5]=2; elementData[6]='B'; elementData[7]='C';
//Third IE
elementData[8]=202; elementData[9]=3; elementData[10]='D'; elementData[11]=0; elementData[12]='F';
} else if(1 == state) {
//Append 2 IEs to others, Notice that we keep old data in array starting with\n
//element 13 and total number of bytes increased to 20
state = 2;
//Total Number of Bytes
elementData[0]=20;
//Fourth IE
elementData[13]=203; elementData[14]=1; elementData[15]='G';
//Fifth IE
elementData[16]=204; elementData[17]=3; elementData[18]='X'; elementData[19]=5; elementData[20]='Z';
} else if(2 == state) { //Delete All IEs
state = 0;
//Total Number of Bytes
elementData[0]=0;
}

Definition at line 753 of file m2m_wifi.c.

◆ m2m_wifi_set_device_name()

NMI_API sint8 m2m_wifi_set_device_name ( uint8 pu8DeviceName,
uint8  u8DeviceNameLength 
)

Asynchronous API to set the Wi-Fi Direct "Device Name" of the WINC IC.

Set the WINC3400 device name which is used as P2P device name.

Parameters
[in]pu8DeviceNameBuffer holding the device name.
[in]u8DeviceNameLengthLength of the device name. Should not exceed the maximum device name's length M2M_DEVICE_NAME_MAX.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Parameters
[in]pu8DeviceNameBuffer holding the device name.
[in]u8DeviceNameLengthLength of the device name.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
Warning
The Function called once after initialization.

Definition at line 1098 of file m2m_wifi.c.

◆ m2m_wifi_set_lsn_int()

NMI_API sint8 m2m_wifi_set_lsn_int ( tstrM2mLsnInt pstrM2mLsnInt)

Asynchronous API to set Wi-Fi listen interval for power save operation.

Set the Wi-Fi listen interval for power save operation. It is represented in units of AP Beacon periods.

Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configurations.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
The function m2m_wifi_set_sleep_mode shall be called first
See also
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configurations.
Returns
The function SHALL return 0 for success and a negative value otherwise.
See also
tstrM2mLsnInt , m2m_wifi_set_sleep_mode
Precondition
m2m_wifi_set_sleep_mode shall be called first
Warning
The Function called once after initialization.

Definition at line 748 of file m2m_wifi.c.

◆ m2m_wifi_set_mac_address()

NMI_API sint8 m2m_wifi_set_mac_address ( uint8  au8MacAddress[6])

Synchronous API for assigning a MAC address to the WINC IC.

This function is intended to allow non-production software to assign a MAC address to the WINC IC.

Parameters
[in]au8MacAddressMAC Address to be provisioned to the WINC.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
This function is intended for development use only and not for use in production software.

Definition at line 697 of file m2m_wifi.c.

◆ m2m_wifi_set_power_profile()

NMI_API sint8 m2m_wifi_set_power_profile ( uint8  u8PwrMode)

Change the power profile mode.

Parameters
[in]u8PwrModeChange the WINC power profile to one of the modes: PWR_LOW1, PWR_LOW2, PWR_HIGH, PWR_AUTO.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
tenuM2mPwrMode
Warning
May only be called after initialization, before any connection request, and may not be used to change the power mode thereafter.
Parameters
[in]u8PwrModeChange the WINC power profile to different mode PWR_LOW1/PWR_LOW2/PWR_HIGH/PWR_AUTO (tenuM2mPwrMode)
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
tenuM2mPwrMode
Precondition
m2m_wifi_init
Warning
must be called after the initializations and before any connection request and can't be changed in run time,

Definition at line 1308 of file m2m_wifi.c.

◆ m2m_wifi_set_receive_buffer()

NMI_API sint8 m2m_wifi_set_receive_buffer ( void *  pvBuffer,
uint16  u16BufferLen 
)

Asynchronous API to set or change the size of the WINC IC's receive buffer.

Parameters
[in]pvBufferPointer to Buffer to receive data. A NULL pointer causes a negative error M2M_ERR_FAIL.
[in]u16BufferLenLength of data to be received. Maximum length of data should not exceed the size defined by TCP/IP defined as SOCKET_BUFFER_MAX_LENGTH
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
This functionality is not supported by current WINC firmware.

◆ m2m_wifi_set_scan_options()

sint8 m2m_wifi_set_scan_options ( tstrM2MScanOption ptstrM2MScanOption)

Synchronous API for configuring the behaviour of the WINC IC's network scanning functions.

This function allows the application to tune the scanning behaviour of the WINC IC using the parameters described in tstrM2MScanOption.

Parameters
[in]ptstrM2MScanOption;Pointer to the structure holding the Scan Parameters.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
tenuM2mScanCh m2m_wifi_request_scan tstrM2MScanOption

Definition at line 758 of file m2m_wifi.c.

◆ m2m_wifi_set_scan_region()

sint8 m2m_wifi_set_scan_region ( uint16  ScanRegion)

Synchronous API for configuring the regulatory restrictions that may affect the WINC ICs scanning behaviour.

This function sets a property called the scan region, a parameter that affects the range of channels that the WINC IC may legally scan given a geographic region.

Parameters
[in]ScanRegion
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
tenuM2mScanRegion m2m_wifi_request_scan

Definition at line 767 of file m2m_wifi.c.

◆ m2m_wifi_set_sleep_mode()

NMI_API sint8 m2m_wifi_set_sleep_mode ( uint8  PsTyp,
uint8  BcastEn 
)

Synchronous API to set the power-save mode of the WINC IC.

Set the power saving mode for the WINC3400.

Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag.
  • If set to 1, the WINC IC will wake for each DTIM beacon to ensure broadcast traffic can be received.
  • If set to 0, the WINC IC will not wakeup at the DTIM beacon, instead it will wake every N beacon periods as per the negotiated Listen Interval.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See also
tenuPowerSaveModes m2m_wifi_get_sleep_mode
Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WINC3400 must be awake each DTIM Beacon for receiving Broadcast traffic. If it is 0, the WINC3400 will not wakeup at the DTIM Beacon, but its wakeup depends only on the the configured Listen Interval.
Returns
The function SHALL return 0 for success and a negative value otherwise.
See also
tenuPowerSaveModes
Warning
The function called once after initialization.

Definition at line 1055 of file m2m_wifi.c.

◆ m2m_wifi_set_static_ip()

NMI_API sint8 m2m_wifi_set_static_ip ( tstrM2MIPConfig pstrStaticIPConf)

Synchronous API to manually assign a (static) IP address to the WINC IC.

Typically an infrastructure access point will be able to provide an IP address to all clients after they associate. The WINC will request configuration via DHCP automatically after successfully connecting to an access point. This function should only be called in the event that the network has no DHCP server and the application knows the specifics of the network.

Parameters
[in]pstrStaticIPConfPointer to a structure holding the static IP Configurations (IP, Gateway, subnet mask and DNS address).
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
The application must first call m2m_wifi_enable_dhcp to request that DHCP functionality is disabled prior to calling this function.
Warning
Exercise caution using this function. DHCP is the preferred method for configuring IP addresses.
See also
tstrM2MIPConfig

Definition at line 705 of file m2m_wifi.c.

◆ m2m_wifi_set_sytem_time()

NMI_API sint8 m2m_wifi_set_sytem_time ( uint32  u32UTCSeconds)

Asynchronous function for setting the system time within the WINC IC.

Parameters
[in]u32UTCSecondsUTC value in seconds.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
See also
Note
If there is an RTC on the host MCU, the SNTP may be disabled and the host may set the system time within the firmware using the API m2m_wifi_set_sytem_time.

Definition at line 1273 of file m2m_wifi.c.

◆ m2m_wifi_set_tx_power()

NMI_API sint8 m2m_wifi_set_tx_power ( uint8  u8TxPwrLevel)

set the TX power tenuM2mTxPwrLevel

Parameters
[in]u8TxPwrLevelchange the TX power tenuM2mTxPwrLevel
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
tenuM2mTxPwrLevel
Parameters
[in]u8TxPwrLevelchange the TX power tenuM2mTxPwrLevel
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See also
tenuM2mTxPwrLevel
Precondition
m2m_wifi_init
Warning

Definition at line 1326 of file m2m_wifi.c.

◆ m2m_wifi_start_provision_mode()

NMI_API sint8 m2m_wifi_start_provision_mode ( tstrM2MAPConfig pstrAPConfig,
char *  pcHttpServerDomainName,
uint8  bEnableHttpRedirect 
)

Asynchronous API for control of Wi-Fi provisioning functionality.

This function allows the application to start the WINC IC in 'provisioning mode', a special mode that triggers the WINC to create a Wi-Fi access point, DHCP server, and HTTP server.

The HTTP server presents a provisioning page to a connected client which lists the access points detected in the vicinity of the WINC, and allows one of these to be selected and any appropriate credentials to be entered. This allows a headless system to be provisioned (configured to connect with an access point).

Provisioning status is returned in a M2M_WIFI_RESP_PROVISION_INFO event.

Parameters
[in]pstrAPConfigAP configuration parameters as defined in tstrM2MAPConfig configuration structure. A NULL value passed in, will result in a negative error M2M_ERR_FAIL.
[in]pcHttpServerDomainNameDomain name of the HTTP Provision WEB server which others will use to load the provisioning Home page. For example "wincconf.net".
[in]bEnableHttpRedirectA flag to enable/disable the HTTP redirect feature. Possible values are:
  • Zero: DO NOT Use HTTP Redirect. In this case the associated device could open the provisioning page ONLY when the HTTP Provision URL of the WINC HTTP Server is correctly written on the browser.
  • Non-Zero: Use HTTP Redirect. In this case, all http traffic (http://URL) from the associated device (Phone, PC, ...etc) will be redirected to the WINC HTTP Provisioning Home page.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the initialization m2m_wifi_init function.
  • The event M2M_WIFI_RESP_CONN_INFO must be handled in the callback to receive the requested connection info.
See also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_PROVISION_INFO m2m_wifi_stop_provision_mode tstrM2MAPConfig
Warning
DO Not use ".local" in the pcHttpServerDomainName.

Example

The example demonstrates a code snippet for how provisioning is triggered and the response event received accordingly.

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MProvisionInfo *pstrProvInfo = (tstrM2MProvisionInfo*)pvMsg;
if(pstrProvInfo->u8Status == M2M_SUCCESS)
{
m2m_wifi_connect((char*)pstrProvInfo->au8SSID, (uint8)strlen(pstrProvInfo->au8SSID), pstrProvInfo->u8SecType,
pstrProvInfo->au8Password, M2M_WIFI_CH_ALL);
printf("PROV SSID : %s\n",pstrProvInfo->au8SSID);
printf("PROV PSK : %s\n",pstrProvInfo->au8Password);
}
else
{
printf("(ERR) Provisioning Failed\n");
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
tstrM2MAPConfig apConfig;
uint8 bEnableRedirect = 1;
strcpy(apConfig.au8SSID, "WINC_SSID");
apConfig.u8ListenChannel = 1;
apConfig.u8SsidHide = 0;
// IP Address
apConfig.au8DHCPServerIP[0] = 192;
apConfig.au8DHCPServerIP[1] = 168;
apConfig.au8DHCPServerIP[2] = 1;
apConfig.au8DHCPServerIP[0] = 1;
m2m_wifi_start_provision_mode(&apConfig, "atmelwincconf.com", bEnableRedirect);
while(1)
{
}
}
}

Definition at line 1233 of file m2m_wifi.c.

◆ m2m_wifi_stop_provision_mode()

sint8 m2m_wifi_stop_provision_mode ( void  )

Synchronous API for terminating provisioning mode on the WINC IC.

This function will terminate any currently active provisioning mode on the WINC IC, returning the IC to idle.

Returns
The function returns ZERO for success and a negative value otherwise.
Precondition
An active provisioning session must be active before it is terminated through this function.
See also
m2m_wifi_start_provision_mode

Definition at line 1263 of file m2m_wifi.c.

◆ m2m_wifi_wps()

NMI_API sint8 m2m_wifi_wps ( uint8  u8TriggerType,
const char *  pcPinNumber 
)

Asynchronous API to engage the WINC IC's Wi-Fi Protected Setup (enrolee) function.

This function can be called to make the WINC enter WPS (Wi-Fi Protected Setup) mode. The result is passed to the Wi-Fi notification callback with the event M2M_WIFI_REQ_WPS.

Parameters
[in]u8TriggerTypeWPS Trigger method. This may be:
[in]pcPinNumberValid only if the u8TriggerType is WPS_PIN_TRIGGER, this parameter contains the PIN number. The number must follow the format as given in the WSC1.0 specification.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.
Warning
This function is not supported in AP or P2P modes.
Precondition
  • A Wi-Fi notification callback of type (tpfAppWifiCb MUST be implemented and registered at startup. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_REQ_WPS must be handled in the callback to receive the WPS status.
  • The WINC device MUST be in IDLE or STA mode. If AP or P2P mode is active, the WPS will not be performed.
  • The m2m_wifi_handle_events MUST be called to receive the responses in the callback.
See also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_REQ_WPS tenuWPSTrigger tstrM2MWPSInfo

Example

The code snippet shows an example of how wifi WPS is triggered .

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
tstrM2MWPSInfo *pstrWPS = (tstrM2MWPSInfo*)pvMsg;
if(pstrWPS->u8AuthType != 0)
{
printf("WPS SSID : %s\n",pstrWPS->au8SSID);
printf("WPS PSK : %s\n",pstrWPS->au8PSK);
printf("WPS SSID Auth Type : %s\n",pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN ? "OPEN" : "WPA/WPA2");
printf("WPS Channel : %d\n",pstrWPS->u8Ch + 1);
// establish Wi-Fi connection
m2m_wifi_connect((char*)pstrWPS->au8SSID, (uint8)m2m_strlen(pstrWPS->au8SSID),
pstrWPS->u8AuthType, pstrWPS->au8PSK, pstrWPS->u8Ch);
}
else
{
printf("(ERR) WPS Is not enabled OR Timed out\n");
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Trigger WPS in Push button mode.
while(1)
{
}
}
}

Definition at line 809 of file m2m_wifi.c.

◆ m2m_wifi_wps_disable()

NMI_API sint8 m2m_wifi_wps_disable ( void  )

Synchronous API that disables Wi-Fi Protected Setup mode in the WINC IC.

Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC, and a negative value otherwise.

Definition at line 820 of file m2m_wifi.c.

◆ m2m_wifi_yield()

NMI_API void m2m_wifi_yield ( void  )

Yield from processing more synchronous M2M events.

This function causes the synchronous M2M event handler function to yield from processing further events and return control to the caller.

Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.
Precondition
Prior to receiving Wi-Fi interrupts, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
Failure to successfully complete this function indicates bus errors and hence a fatal error that will prevent the application from proceeding.

Definition at line 562 of file m2m_wifi.c.



inertial_sense_ros
Author(s):
autogenerated on Sun Feb 28 2021 03:18:00