Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
WINC3400 (Wi-Fi + BLE)

Macros

#define WIFI_1X_TLS_HS_FLAGS_DEFAULT
 
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH   NBIT1
 
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK   NBIT2
 
#define WIFI_1X_TLS_HS_FLAGS_REQUIRE_TIME   NBIT3
 
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING   NBIT4
 
#define WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT   NBIT6
 

Functions

static sint8 legacy_connect_prepare_msg (tstrM2mWifiConnHdr *pstrConnHdr, tstrM2mWifiConnectLegacy_1_2 *pstrConnect)
 
NMI_API sint8 m2m_ota_get_firmware_version (tstrM2mRev *pstrRev)
 Get the OTA Firmware version. More...
 
static sint8 m2m_validate_ap_parameters (CONST tstrM2MAPModeConfig *pstrM2MAPModeConfig)
 
static sint8 m2m_validate_scan_options (tstrM2MScanOption *ptstrM2MScanOption)
 
sint8 m2m_wifi_1x_get_option (tenu1xOption enuOptionName, void *pOptionValue, size_t *pOptionLen)
 API to get (read) options relating to Wi-Fi connection using WPA(2) Enterprise authentication. More...
 
sint8 m2m_wifi_1x_set_option (tenu1xOption enuOptionName, const void *pOptionValue, size_t OptionLen)
 API to set (write) options relating to Wi-Fi connection using WPA(2) Enterprise authentication. More...
 
static void m2m_wifi_cb (uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
 
sint8 m2m_wifi_configure_sntp (uint8 *pu8NTPServerName, uint8 u8NTPServerNameLength, tenuSNTPUseDHCP useDHCP)
 Configures what NTP server the SNTP client should use. More...
 
sint8 m2m_wifi_connect (char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *pvAuthInfo, uint16 u16Ch)
 DEPRECATED in v19.6.1 - Kept only for legacy purposes.
Legacy asynchronous API to request connection to a specified access point. More...
 
sint8 m2m_wifi_connect_1x_mschap2 (tenuCredStoreOption enuCredStoreOption, tstrNetworkId *pstrNetworkId, tstrAuth1xMschap2 *pstrAuth1xMschap2)
 Asynchronous API to connect to an access point using WPA(2) Enterprise authentication with MS-CHAP-V2 credentials. More...
 
sint8 m2m_wifi_connect_1x_tls (tenuCredStoreOption enuCredStoreOption, tstrNetworkId *pstrNetworkId, tstrAuth1xTls *pstrAuth1xTls)
 Asynchronous API to connect to an access point using WPA(2) Enterprise authentication with MS-CHAP-V2 credentials. More...
 
sint8 m2m_wifi_connect_open (tenuCredStoreOption enuCredStoreOption, tstrNetworkId *pstrNetworkId)
 Asynchronous API to connect to an access point using open authentication. More...
 
static sint8 m2m_wifi_connect_prepare_msg (tenuCredStoreOption enuCredStoreOption, tenuM2mSecType enuAuthType, uint16 u16AuthSize, tstrNetworkId *pstrNetworkId, tstrM2mWifiConnHdr *pstrWifiConn)
 
sint8 m2m_wifi_connect_psk (tenuCredStoreOption enuCredStoreOption, tstrNetworkId *pstrNetworkId, tstrAuthPsk *pstrAuthPsk)
 Asynchronous API to connect to an access point using WPA(2) PSK authentication. More...
 
sint8 m2m_wifi_connect_sc (char *pcSsid, uint8 u8SsidLen, uint8 u8SecType, void *pvAuthInfo, uint16 u16Ch, uint8 u8NoSaveCred)
 DEPRECATED in v19.6.1 - Kept only for legacy purposes.
Legacy asynchronous API to request connection to a specific AP with the option to save credentials in Flash. More...
 
sint8 m2m_wifi_connect_wep (tenuCredStoreOption enuCredStoreOption, tstrNetworkId *pstrNetworkId, tstrAuthWep *pstrAuthWep)
 Asynchronous API to connect to an access point using WEP authentication. More...
 
sint8 m2m_wifi_default_connect (void)
 Asynchronous API that attempts to reconnect to the last-associated access point. More...
 
sint8 m2m_wifi_deinit (void *arg)
 De-initialize the WINC driver and host interface. More...
 
sint8 m2m_wifi_delete_sc (char *pcSsid, uint8 u8SsidLen)
 Asynchronous API that deletes connection credentials (PSK, WEP key, 802.1X password) from WINC flash. Either deletes all credentials, or for a specific SSID. More...
 
sint8 m2m_wifi_disable_ap (void)
 Synchronous API to disable access point mode on the WINC IC. More...
 
sint8 m2m_wifi_disable_roaming (void)
 Disable WiFi STA roaming. More...
 
sint8 m2m_wifi_disconnect (void)
 Synchronous API to request disconnection from a network. More...
 
sint8 m2m_wifi_download_mode ()
 Prepares the WINC board before downloading any data (Firmware, Certificates, etc). More...
 
sint8 m2m_wifi_enable_ap (CONST tstrM2MAPConfig *pstrM2MAPConfig)
 Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC IC. More...
 
sint8 m2m_wifi_enable_ap_ext (CONST tstrM2MAPModeConfig *pstrM2MAPModeConfig)
 Asynchronous API to enable access point (AKA "hot-spot") mode on the WINC IC with extended options. More...
 
sint8 m2m_wifi_enable_dhcp (uint8 u8DhcpEn)
 Enable/Disable the DHCP client after connection. 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)
 Add MAC filter to receive Multicast packets. More...
 
sint8 m2m_wifi_enable_roaming (uint8 bEnableDhcp)
 Enable WiFi STA roaming. More...
 
sint8 m2m_wifi_enable_sntp (uint8 bEnable)
 Synchronous function to enable/disable the native Simple Network Time Protocol(SNTP) client in the WINC15x0 firmware. More...
 
uint32 m2m_wifi_get_chipId (void)
 Get the WINC Chip ID. More...
 
sint8 m2m_wifi_get_connection_info (void)
 Request the status information of the currently connected Wi-Fi AP. The result is passed to the Wi-Fi notification callback with the event M2M_WIFI_RESP_CONN_INFO. More...
 
sint8 m2m_wifi_get_firmware_version (tstrM2mRev *pstrRev)
 Get Firmware version info. More...
 
sint8 m2m_wifi_get_mac_address (uint8 *pu8MacAddr)
 Request the current MAC address of the device (the working mac address). (the function is Blocking until response received) More...
 
uint8 m2m_wifi_get_num_ap_found (void)
 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. More...
 
sint8 m2m_wifi_get_otp_mac_address (uint8 *pu8MacAddr, uint8 *pu8IsValid)
 Request the MAC address stored on the OTP (one time programmable) memory of the device. (the function is Blocking until response received) More...
 
uint8 m2m_wifi_get_sleep_mode (void)
 Get the current Power save mode. More...
 
uint8 m2m_wifi_get_state (void)
 Get the wifi state. More...
 
sint8 m2m_wifi_get_system_time (void)
 Asynchronous API to obtain the system time in use by the WINC IC. More...
 
sint8 m2m_wifi_handle_events (void *arg)
 Synchronous M2M event handler function. More...
 
sint8 m2m_wifi_init (tstrWifiInitParam *param)
 Synchronous API to initialize 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...
 
sint8 m2m_wifi_p2p (uint8 u8Channel)
 
sint8 m2m_wifi_p2p_disconnect (void)
 
sint8 m2m_wifi_prng_get_random_bytes (uint8 *pu8PrngBuff, uint16 u16PrngSize)
 Get random bytes using the PRNG bytes. More...
 
sint8 m2m_wifi_reinit (tstrWifiInitParam *param)
 De-initialize and then initialize wifi. Resets the WINC. 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...
 
sint8 m2m_wifi_req_curr_rssi (void)
 Request the current RSSI for the current connected AP, the response received in wifi_cb M2M_WIFI_RESP_CURRENT_RSSI. More...
 
sint8 m2m_wifi_req_scan_result (uint8 index)
 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. More...
 
sint8 m2m_wifi_request_dhcp_client (void)
 Legacy (deprecated) Asynchronous API for starting a DHCP client on the WINC IC. More...
 
sint8 m2m_wifi_request_dhcp_server (uint8 *addr)
 Dhcp requested by the firmware automatically in STA/AP mode). More...
 
sint8 m2m_wifi_request_scan (uint8 ch)
 Asynchronous API to request the WINC IC to scan for networks. More...
 
sint8 m2m_wifi_request_scan_ssid_list (uint8 ch, uint8 *u8Ssidlist)
 Asynchronous wi-fi scan request on the given channel and the hidden scan list. More...
 
sint8 m2m_wifi_request_sleep (uint32 u32SlpReqTime)
 API to place the WINC IC into sleep mode for a specified period of time. More...
 
sint8 m2m_wifi_send_ethernet_pkt (uint8 *pu8Packet, uint16 u16PacketSize)
 Synchronous function to transmit an Ethernet packet. 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...
 
sint8 m2m_wifi_set_cust_InfoElement (uint8 *pau8M2mCustInfoElement)
 API to add or remove a user-defined Information Element. More...
 
sint8 m2m_wifi_set_device_name (uint8 *pu8DeviceName, uint8 u8DeviceNameLength)
 Set the WILC1000 device name which is used as P2P device name. More...
 
sint8 m2m_wifi_set_lsn_int (tstrM2mLsnInt *pstrM2mLsnInt)
 Set the Wi-Fi listen interval for power save operation. It is represented in units of AP Beacon periods. More...
 
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)
 set the ethernet receive buffer, should be called in the receive call back. More...
 
sint8 m2m_wifi_set_scan_options (tstrM2MScanOption *ptstrM2MScanOption)
 Synchronous API for configuring the behaviour of the WINC IC's network scanning functions. More...
 
sint8 m2m_wifi_set_scan_region (uint16 ScanRegion)
 Synchronous API for configuring the regulatory restrictions that may affect the WINC ICs scanning behaviour. More...
 
sint8 m2m_wifi_set_sleep_mode (uint8 PsTyp, uint8 BcastEn)
 Set the power saving mode for the WILC1000. More...
 
sint8 m2m_wifi_set_static_ip (tstrM2MIPConfig *pstrStaticIPConf)
 Synchronous API to manually assign a (static) IP address to the WINC IC. More...
 
sint8 m2m_wifi_set_stop_scan_on_first (uint8 u8StopScanOption)
 Synchronous API for enabling/disabling the stop scan on first result of the WINC IC's network scanning functions. More...
 
sint8 m2m_wifi_set_system_time (uint32 u32UTCSeconds)
 Function for setting the system time within the WINC IC. More...
 
sint8 m2m_wifi_set_tx_power (uint8 u8TxPwrLevel)
 set the TX power More...
 
sint8 m2m_wifi_start_provision_mode (tstrM2MAPConfig *pstrM2MAPConfig, char *pcHttpServerDomainName, uint8 bEnableHttpRedirect)
 Asynchronous API for control of Wi-Fi provisioning functionality. More...
 
sint8 m2m_wifi_start_provision_mode_ext (tstrM2MAPModeConfig *pstrAPModeConfig, char *pcHttpServerDomainName, uint8 bEnableHttpRedirect)
 Asynchronous API for control of Wi-Fi provisioning functionality with extended options. More...
 
sint8 m2m_wifi_stop_provision_mode (void)
 Synchronous API for terminating provisioning mode on the WINC IC. More...
 
sint8 m2m_wifi_wps (uint8 u8TriggerType, const char *pcPinNumber)
 Asynchronous API to engage the WINC IC's Wi-Fi Protected Setup (enrollee) function. More...
 
sint8 m2m_wifi_wps_disable (void)
 Disable the WILC WPS operation. More...
 
void m2m_wifi_yield (void)
 Yield from processing more synchronous M2M events. More...
 

Variables

static uint8 gau81xRootSha1 [20] = {0}
 
static uint8gau8ethRcvBuf = NULL
 
static tpfAppEthCb gpfAppEthCb = NULL
 
static tpfAppWifiCb gpfAppWifiCb = NULL
 
static uint16 gu16ethRcvBufSize
 
static uint32 gu321xTlsHsFlags = WIFI_1X_TLS_HS_FLAGS_DEFAULT
 
static volatile uint8 gu8ChNum
 

#define WIFI_1X_TLS_HS_FLAGS_DEFAULT
Value:
( \
)
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING
Definition: winc3400/wifi_drv/driver/source/m2m_wifi.c:49
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH
Definition: winc3400/wifi_drv/driver/source/m2m_wifi.c:46
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK
Definition: winc3400/wifi_drv/driver/source/m2m_wifi.c:47
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH   NBIT1
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK   NBIT2
#define WIFI_1X_TLS_HS_FLAGS_REQUIRE_TIME   NBIT3
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING   NBIT4
#define WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT   NBIT6

NMI_API sint8 m2m_ota_get_firmware_version ( tstrM2mRev pstrRev)

Get the OTA Firmware version.

Synchronous API to obtain the firmware version of the WINC image that is stored in the inactive flash partition. This is the image that would run on the WINC if m2m_ota_switch_firmware or m2m_ota_rollback were called, followed by a reset of the WINC.

Synchronous API to obtain the firmware version of the WINC image that is stored in the inactive flash partition. This is the image that would run on the WINC IC if m2m_ota_switch_firmware or m2m_ota_rollback were called, followed by a reset of the WINC IC.

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

Get OTA Firmware version info from the inactive partition, as defined in the structure tstrM2mRev.

Parameters
[out]pstrRevPointer to the structure tstrM2mRev that contains the firmware version parameters.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Parameters
[out]pstrRevpointer holds address of structure "tstrM2mRev" that contains the ota fw version parameters
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
Parameters
[out]pstrRevPointer to variable of type tstrM2mRev which contains the ota fw version parameters.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.

References hif_chip_sleep(), hif_chip_wake(), M2M_SUCCESS, and nm_get_ota_firmware_info().

sint8 m2m_wifi_1x_get_option ( tenu1xOption  enuOptionName,
void *  pOptionValue,
size_t *  pOptionLen 
)

API to get (read) options relating to Wi-Fi connection using WPA(2) Enterprise authentication.

The following options can be read:\n
    @ref WIFI_1X_BYPASS_SERVER_AUTH\n
    @ref WIFI_1X_SESSION_CACHING\n
    @ref WIFI_1X_SPECIFIC_ROOTCERT\n
    @ref WIFI_1X_TIME_VERIF_MODE\n
Parameters
[in]enuOptionNameThe option to get.
[out]pOptionValuePointer to a buffer containing the value to set. The buffer must be at least as long as OptionLen. If OptionLen is 0, then pOptionValue may be NULL.
[in,out]pOptionLenPointer to a length. When calling the function, this length must be the length of the buffer available for reading the option value. When the function returns, this length is the length of the data that has been populated by the function.
Returns
The function returns M2M_SUCCESS if the parameters are valid and M2M_ERR_INVALID_ARG otherwise.
The following options can be read:\n
    @ref WIFI_1X_BYPASS_SERVER_AUTH\n
    @ref WIFI_1X_TIME_VERIF_MODE\n
    @ref WIFI_1X_SESSION_CACHING\n
    @ref WIFI_1X_SPECIFIC_ROOTCERT\n
Parameters
[in]enuOptionNameThe option to get.
[out]pOptionValuePointer to a buffer to be filled with the value being read. The buffer must be at least as long as the length in pOptionLen
[in,out]pOptionLenPointer to a length. When calling the function, this length must be the length of the buffer available for reading the option value. When the function returns, this length is the length of the data that has been populated by the function.
Returns
The function returns M2M_SUCCESS if the parameters are valid and M2M_ERR_INVALID_ARG otherwise.

References gau81xRootSha1, gu321xTlsHsFlags, M2M_ERR_INVALID_ARG, m2m_memcpy(), M2M_SUCCESS, NULL, SSL_CERT_EXP_CHECK_DISABLE, SSL_CERT_EXP_CHECK_EN_IF_SYS_TIME, SSL_CERT_EXP_CHECK_ENABLE, TLS_CERT_EXP_CHECK_DISABLE, TLS_CERT_EXP_CHECK_EN_IF_SYS_TIME, TLS_CERT_EXP_CHECK_ENABLE, WIFI_1X_BYPASS_SERVER_AUTH, WIFI_1X_SESSION_CACHING, WIFI_1X_SPECIFIC_ROOTCERT, WIFI_1X_TIME_VERIF_MODE, WIFI_1X_TLS_HS_FLAGS_PEER_AUTH, WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK, WIFI_1X_TLS_HS_FLAGS_REQUIRE_TIME, WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING, and WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT.

sint8 m2m_wifi_1x_set_option ( tenu1xOption  enuOptionName,
const void *  pOptionValue,
size_t  OptionLen 
)

API to set (write) options relating to Wi-Fi connection using WPA(2) Enterprise authentication.

The following options can be set:\n
    @ref WIFI_1X_BYPASS_SERVER_AUTH\n
    @ref WIFI_1X_SESSION_CACHING\n
    @ref WIFI_1X_SPECIFIC_ROOTCERT\n
    @ref WIFI_1X_TIME_VERIF_MODE\n
The setting applies to all subsequent connection attempts via @ref m2m_wifi_connect_1x_mschap2
or @ref m2m_wifi_connect_1x_tls.\n
Connection attempts via @ref m2m_wifi_default_connect use the
settings which were in place at the time of the original connection.
Parameters
[in]enuOptionNameThe option to set.
[in]pOptionValuePointer to a buffer containing the value to set. The buffer must be at least as long as OptionLen. If OptionLen is 0, then pOptionValue may be NULL.
[in]OptionLenThe length of the option value being set.
Returns
The function returns M2M_SUCCESS if the parameters are valid and M2M_ERR_INVALID_ARG otherwise.
The following options can be set:\n
    @ref WIFI_1X_BYPASS_SERVER_AUTH\n
    @ref WIFI_1X_TIME_VERIF_MODE\n
    @ref WIFI_1X_SESSION_CACHING\n
    @ref WIFI_1X_SPECIFIC_ROOTCERT\n
The setting applies to all subsequent connection attempts via @ref m2m_wifi_connect_1x_mschap2
or @ref m2m_wifi_connect_1x_tls.\n
Connection attempts via @ref m2m_wifi_default_connect use the
settings which were in place at the time of the original connection.
Parameters
[in]enuOptionNameThe option to set.
[in]pOptionValuePointer to a buffer containing the value to set. The buffer must be at least as long as OptionLen. If OptionLen is 0, then pOptionValue may be NULL.
[in]OptionLenThe length of the option value being set.
Returns
The function returns M2M_SUCCESS if the parameters are valid and M2M_ERR_INVALID_ARG otherwise.

References gau81xRootSha1, gu321xTlsHsFlags, M2M_ERR_INVALID_ARG, m2m_memcpy(), m2m_memset(), M2M_SUCCESS, NULL, SSL_CERT_EXP_CHECK_DISABLE, SSL_CERT_EXP_CHECK_EN_IF_SYS_TIME, SSL_CERT_EXP_CHECK_ENABLE, TLS_CERT_EXP_CHECK_DISABLE, TLS_CERT_EXP_CHECK_EN_IF_SYS_TIME, TLS_CERT_EXP_CHECK_ENABLE, WIFI_1X_BYPASS_SERVER_AUTH, WIFI_1X_SESSION_CACHING, WIFI_1X_SPECIFIC_ROOTCERT, WIFI_1X_TIME_VERIF_MODE, WIFI_1X_TLS_HS_FLAGS_PEER_AUTH, WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK, WIFI_1X_TLS_HS_FLAGS_REQUIRE_TIME, WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING, and WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT.

sint8 m2m_wifi_configure_sntp ( uint8 pu8NTPServerName,
uint8  u8NTPServerNameLength,
tenuSNTPUseDHCP  useDHCP 
)

Configures what NTP server the SNTP client should use.

Parameters
[in]pu8NTPServerNameBuffer holding the NTP server name. If the first character is an asterisk (*) then it will be treated as a server pool, where the asterisk will be replaced with an incrementing value from 0 to 3 each time a server fails (example: *.pool.ntp.org).
[in]u8NTPServerNameLengthLength of the NTP server name. Should not exceed the maximum NTP server name length of M2M_NTP_MAX_SERVER_NAME_LENGTH
[in]useDHCPShould the NTP server provided by the DHCP server be used.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
Configures what NTP server the SNTP client should use. Only 1 server name can be provided, if the configured server name begins with an asterisk then it will be treated as a server pool.
The SNTP client can also use the NTP server provided by the DHCP server through option 42.
By default the NTP server provided by DHCP will be tried first, then the built-in default NTP server (time.nist.gov) will be used.
Parameters
[in]pu8NTPServerNameBuffer holding the NTP server name. If the first character is an asterisk (*) then it will be treated as a server pool, where the asterisk will be replaced with an incrementing value from 0 to 3 each time a server fails (example: *.pool.ntp.org).
[in]u8NTPServerNameLengthLength of the NTP server name. Should not exceed the maximum NTP server name length of M2M_NTP_MAX_SERVER_NAME_LENGTH.
[in]useDHCPExplicity tell the WINC if it should use the NTP server provided by the DHCP server or not.
Warning
SNTP should be configured before the connection takes place. If SNTP is configured after the device connects to a network, the new configuration can take a minimum of 24h to be applied. However, it can take even longer since it is triggered by DHCP renewal. Currently there is also a known issue in which if the WINC obtains the NTP server from DHCP and then connects to a different network, it will still use the NTP from the previous network. Configuring a server name will overwrite the built-in default server until next reboot.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
Configures what NTP server the SNTP client should use. Only 1 server name can be provided, if the configured server name begins with an asterisk then it will be treated as a server pool.
The SNTP client can also use the NTP server provided by the DHCP server through option 42.
By default the NTP server provided by DHCP will be tried first, then the built-in default NTP server (time.nist.gov) will be used.
Parameters
[in]pu8NTPServerNameBuffer holding the NTP server name. If the first character is an asterisk (*) then it will be treated as a server pool, where the asterisk will be replaced with an incrementing value from 0 to 3 each time a server fails (example: *.pool.ntp.org).
[in]u8NTPServerNameLengthLength of the NTP server name. Should not exceed the maximum NTP server name length of M2M_NTP_MAX_SERVER_NAME_LENGTH.
[in]useDHCPExplicity tell the WINC if it should use the NTP server provided by the DHCP server or not.
Warning
SNTP should be configured before the connection takes place. If SNTP is configured after the device connects to a network, the new configuration can take a minimum of 24h to be applied. However, it can take even longer since it is triggered by DHCP renewal. Currently there is also a known issue in which if the WINC obtains the NTP server from DHCP and then connects to a different network, it will still use the NTP from the previous network. Configuring a server name will overwrite the built-in default server until next reboot.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.

References tstrM2MSNTPConfig::acNTPServer, tstrM2MSNTPConfig::enuUseDHCP, hif_send(), M2M_ERR_FAIL, m2m_memcpy(), M2M_NTP_MAX_SERVER_NAME_LENGTH, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_CONFIG_SNTP, and NULL.

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

DEPRECATED in v19.6.1 - Kept only for legacy purposes.
Legacy asynchronous API to request connection to a specified access point.

Legacy asynchronous API to request connection to a specified access point.

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]puniAuthInfoAuthentication parameters required for completing the connection. 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. Channel number greater than M2M_WIFI_CH_14 returns a negative error M2M_ERR_FAIL(-12). Except if the value is M2M_WIFI_CH_ALL(255), since this indicates that the firmware should scan all channels to find the SSID requested to connect to.
Precondition
Prior to a successful connection request, the wi-fi driver must have been successfully intialized through the call of the 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 for successful operations and a negative value otherwise.
Prior to a successful connection, the application must define the SSID of the AP, the security
type, the authentication information parameters and the channel number to which the connection
will be established.

The connection status is known when a response of @ref M2M_WIFI_RESP_CON_STATE_CHANGED is
received based on the states defined in @ref tenuM2mConnState, successful connection is defined
by @ref M2M_WIFI_CONNECTED

The only difference between this function and @ref m2m_wifi_default_connect, is the set of connection parameters.
Connection using this function is expected to be made to a specific AP and to a specified channel.
Parameters
[in]pcSsidA buffer holding the SSID corresponding to the requested AP. SSID must not contain '\0'.
[in]u8SsidLenLength of the given SSID (not including the NULL termination). A length 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. Its 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. Specifying 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, since this 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.

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
Warning
If there is a '\0' character within the first u8SsidLen characters, then this function will assume that the input u8SsidLen was incorrect, set length to strlen(pcSsid) and continue.
This function has been deprecated since v19.6.1 and will no longer be supported afterwards. The following should be used instead: m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls

Additionally:

  • 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.
See Also
tstr1xAuthCredentials tstrM2mWifiWepParams
This API is maintained for purposes of compatibility with legacy applications. It is
implemented as a wrapper for the following new APIs:
    @ref m2m_wifi_connect_open
    @ref m2m_wifi_connect_wep
    @ref m2m_wifi_connect_psk
    @ref m2m_wifi_connect_1x_mschap2
    @ref m2m_wifi_connect_1x_tls
These new APIs allow more flexibility and it is recommended that applications use them instead.
Parameters
[in]pcSsidA buffer holding the SSID corresponding to the requested AP. SSID must not contain '\0'.
[in]u8SsidLenLength of the given SSID (not including any NULL termination). A length greater than or equal to 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. Its 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 indicating connection failure.
[in]u16ChWi-Fi channel number as defined in tenuM2mScanCh enumeration. Specifying a channel number greater than M2M_WIFI_CH_14 returns a negative error M2M_ERR_FAIL, unless the value is M2M_WIFI_CH_ALL, since this 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.

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.
Warning
If there is a '\0' character within the first u8SsidLen characters, then this function will assume that the input u8SsidLen was incorrect, set length to strlen(pcSsid) and continue.
It is recommended that the following Wi-Fi connect APIs are used instead: m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls

Additionally:

  • 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.
See Also
tuniM2MWifiAuth tstr1xAuthCredentials tstrM2mWifiWepParams

References m2m_wifi_connect_sc().

sint8 m2m_wifi_connect_1x_mschap2 ( tenuCredStoreOption  enuCredStoreOption,
tstrNetworkId pstrNetworkId,
tstrAuth1xMschap2 pstrAuth1xMschap2 
)

Asynchronous API to connect to an access point using WPA(2) Enterprise authentication with MS-CHAP-V2 credentials.

Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the Enterprise MS-CHAP-V2 credentials provided in pstrAuth1xMschap2.
On successful connection, the connection details may be saved in WINC's flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuth1xMschap2) are stored in WINC's flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuth1xMschap2Structure specifying the MS-CHAP-V2 credentials.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.
Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the Enterprise MS-CHAP-V2 credentials provided in pstrAuth1xMschap2.
On successful connection, the connection details may be saved in WINC flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuth1xMschap2) are stored in WINC flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuth1xMschap2Structure specifying the MS-CHAP-V2 credentials.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.

References tstrM2mWifi1xHdr::au81xAuthDetails, tstrM2mWifi1xHdr::au8TlsSpecificRootNameSha1, tstrAuth1xMschap2::bPrependDomain, tstrAuth1xMschap2::bUnencryptedUserName, gau81xRootSha1, gu321xTlsHsFlags, hif_send(), M2M_802_1X_MSCHAP2_FLAG, M2M_802_1X_PREPEND_DOMAIN_FLAG, M2M_802_1X_UNENCRYPTED_USERNAME_FLAG, M2M_AUTH_1X_PASSWORD_LEN_MAX, M2M_AUTH_1X_USER_LEN_MAX, M2M_ERR_INVALID_ARG, M2M_ERR_MEM_ALLOC, m2m_memcpy(), m2m_memset(), M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_wifi_connect_prepare_msg(), M2M_WIFI_REQ_CONN, M2M_WIFI_SEC_802_1X, NULL, tstrAuth1xMschap2::pu8Domain, tstrAuth1xMschap2::pu8Password, tstrAuth1xMschap2::pu8UserName, tstrAuth1xMschap2::u16DomainLen, tstrAuth1xMschap2::u16PasswordLen, tstrM2mWifi1xHdr::u16PrivateKeyLength, tstrM2mWifi1xHdr::u16PrivateKeyOffset, tstrAuth1xMschap2::u16UserNameLen, tstrM2mWifi1xHdr::u32TlsHsFlags, tstrM2mWifi1xHdr::u8DomainLength, tstrM2mWifi1xHdr::u8Flags, tstrM2mWifi1xHdr::u8HdrLength, and tstrM2mWifi1xHdr::u8UserNameLength.

sint8 m2m_wifi_connect_1x_tls ( tenuCredStoreOption  enuCredStoreOption,
tstrNetworkId pstrNetworkId,
tstrAuth1xTls pstrAuth1xTls 
)

Asynchronous API to connect to an access point using WPA(2) Enterprise authentication with MS-CHAP-V2 credentials.

Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the Enterprise TLS credentials provided in pstrAuth1xTls.
On successful connection, the connection details may be saved in WINC's flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuth1xTls) are stored in WINC's flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuth1xTlsStructure specifying the EAP-TLS credentials.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.
Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the Enterprise TLS credentials provided in pstrAuth1xTls.
On successful connection, the connection details may be saved in WINC flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuth1xTls) are stored in WINC flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuth1xTlsStructure specifying the EAP-TLS credentials.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.

References tstrM2mWifi1xHdr::au81xAuthDetails, tstrM2mWifi1xHdr::au8TlsSpecificRootNameSha1, tstrAuth1xTls::bPrependDomain, tstrAuth1xTls::bUnencryptedUserName, gau81xRootSha1, gu321xTlsHsFlags, hif_send(), M2M_802_1X_PREPEND_DOMAIN_FLAG, M2M_802_1X_TLS_CLIENT_CERTIFICATE, M2M_802_1X_TLS_FLAG, M2M_802_1X_UNENCRYPTED_USERNAME_FLAG, M2M_AUTH_1X_CERT_LEN_MAX, M2M_AUTH_1X_PRIVATEKEY_LEN_MAX, M2M_AUTH_1X_USER_LEN_MAX, M2M_ERR_INVALID_ARG, M2M_ERR_MEM_ALLOC, m2m_memcpy(), m2m_memset(), M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_wifi_connect_prepare_msg(), M2M_WIFI_IND_CONN_PARAM, M2M_WIFI_REQ_CONN, M2M_WIFI_SEC_802_1X, NULL, tstrAuth1xTls::pu8Certificate, tstrAuth1xTls::pu8Domain, tstrAuth1xTls::pu8PrivateKey_Exp, tstrAuth1xTls::pu8PrivateKey_Mod, tstrAuth1xTls::pu8UserName, tstrAuth1xTls::u16CertificateLen, tstrM2mWifi1xHdr::u16CertificateLength, tstrM2mWifi1xHdr::u16CertificateOffset, tstrAuth1xTls::u16DomainLen, tstrM2mWifiAuthInfoHdr::u16InfoLen, tstrM2mWifiAuthInfoHdr::u16InfoPos, tstrAuth1xTls::u16PrivateKeyLen, tstrM2mWifi1xHdr::u16PrivateKeyLength, tstrM2mWifi1xHdr::u16PrivateKeyOffset, tstrAuth1xTls::u16UserNameLen, tstrM2mWifi1xHdr::u32TlsHsFlags, tstrM2mWifi1xHdr::u8DomainLength, tstrM2mWifi1xHdr::u8Flags, tstrM2mWifi1xHdr::u8HdrLength, tstrM2mWifiAuthInfoHdr::u8Type, and tstrM2mWifi1xHdr::u8UserNameLength.

sint8 m2m_wifi_connect_open ( tenuCredStoreOption  enuCredStoreOption,
tstrNetworkId pstrNetworkId 
)

Asynchronous API to connect to an access point using open authentication.

Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
open authentication.
On successful connection, the connection details may be saved in WINC's flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId) are stored in WINC's flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.
Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
open authentication.
On successful connection, the connection details may be saved in WINC flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId) are stored in WINC flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.

References hif_send(), legacy_connect_prepare_msg(), M2M_ERR_INVALID_ARG, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_wifi_connect_prepare_msg(), M2M_WIFI_REQ_CONN, M2M_WIFI_REQ_CONNECT, M2M_WIFI_SEC_OPEN, and NULL.

sint8 m2m_wifi_connect_psk ( tenuCredStoreOption  enuCredStoreOption,
tstrNetworkId pstrNetworkId,
tstrAuthPsk pstrAuthPsk 
)

Asynchronous API to connect to an access point using WPA(2) PSK authentication.

Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the PSK passphrase provided in pstrAuthPsk.
On successful connection, the connection details may be saved in WINC's flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuthPsk) are stored in WINC's flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuthPskStructure specifying the Passphrase/PSK.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.
Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the PSK passphrase provided in pstrAuthPsk.
On successful connection, the connection details may be saved in WINC flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuthPsk) are stored in WINC flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuthPskStructure specifying the Passphrase/PSK.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.

References tstrM2mWifiPsk::au8Passphrase, tuniM2MWifiAuthLegacy_1_2::au8PSK, hexstr_2_bytes(), hif_send(), legacy_connect_prepare_msg(), M2M_ERR_INVALID_ARG, M2M_ERR_MEM_ALLOC, M2M_MAX_PSK_LEN, m2m_memcpy(), m2m_memset(), M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_wifi_connect_prepare_msg(), M2M_WIFI_REQ_CONN, M2M_WIFI_REQ_CONNECT, M2M_WIFI_SEC_WPA_PSK, NULL, tstrAuthPsk::pu8Passphrase, tstrAuthPsk::pu8Psk, tstrM2mWifiConnectLegacy_1_2::strSec, tstrAuthPsk::u8PassphraseLen, tstrM2mWifiPsk::u8PassphraseLen, and tstrM2MWifiSecInfoLegacy_1_2::uniAuth.

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

DEPRECATED in v19.6.1 - Kept only for legacy purposes.
Legacy asynchronous API to request connection to a specific AP with the option to save credentials in Flash.

Legacy asynchronous API to request connection to a specific AP with the option to save credentials in Flash.

Prior to a successful connection, the application developers must know the SSID of the AP, the security
type, the authentication information parameters and the channel number to which the connection will
be established.

The connection status is known when a response of @ref M2M_WIFI_RESP_CON_STATE_CHANGED is received based
on the states defined in @ref tenuM2mConnState, successful connection is defined by @ref M2M_WIFI_CONNECTED
The only difference between this function and @ref m2m_wifi_connect, is the option to save the access point
info (SSID, password...etc) or not.
Connection using this function is expected to be made to a specific AP and to a specified channel.
Parameters
[in]pcSsidA buffer holding the SSID corresponding to the requested AP. SSID must not contain '\0'.
[in]u8SsidLenLength of the given SSID (not including the NULL termination). A length 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 see tenuM2mSecType. 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. Its 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. 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]u8NoSaveCredOption to store the access 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.
Warning
If there is a '\0' character within the first u8SsidLen characters, then this function will assume that the input u8SsidLen was incorrect, set length to strlen(pcSsid) and continue.
This function has been deprecated since v19.6.1 and will no longer be supported afterwards. The following should be used instead: m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls

Additionally:

  • 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.
See Also
tenuM2mSecType tstr1xAuthCredentials tstrM2mWifiWepParams
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
This API is maintained for purposes of compatibility with legacy applications. It is
implemented as a wrapper for the following new APIs:
    @ref m2m_wifi_connect_open
    @ref m2m_wifi_connect_wep
    @ref m2m_wifi_connect_psk
    @ref m2m_wifi_connect_1x_mschap2
    @ref m2m_wifi_connect_1x_tls
These new APIs allow more flexibility and it is recommended that applications use them instead.
Parameters
[in]pcSsidA buffer holding the SSID corresponding to the requested AP. SSID must not contain '\0'.
[in]u8SsidLenLength of the given SSID (not including any NULL termination). A length greater than or equal to M2M_MAX_SSID_LEN will result in a negative error M2M_ERR_FAIL.
[in]u8SecTypeWi-Fi security type security for the network (see tenuM2mSecType). 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. Its 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 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 unless the value is M2M_WIFI_CH_ALL. 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 access 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.
Warning
If there is a '\0' character within the first u8SsidLen characters, then this function will assume that the input u8SsidLen was incorrect, set length to strlen(pcSsid) and continue.
It is recommended that the following Wi-Fi connect APIs are used instead: m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls

Additionally:

  • 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.
See Also
tuniM2MWifiAuth tenuM2mSecType tstr1xAuthCredentials tstrM2mWifiWepParams
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

References tstr1xAuthCredentials::au8Passwd, tstr1xAuthCredentials::au8UserName, tstrM2mWifiWepParams::au8WepKey, M2M_ERR_INVALID_ARG, M2M_MAX_PSK_LEN, M2M_MAX_SSID_LEN, m2m_strlen(), m2m_wifi_connect_1x_mschap2(), m2m_wifi_connect_open(), m2m_wifi_connect_psk(), m2m_wifi_connect_wep(), M2M_WIFI_SEC_802_1X, M2M_WIFI_SEC_OPEN, M2M_WIFI_SEC_WEP, M2M_WIFI_SEC_WPA_PSK, NULL, tstrAuthPsk::pu8Passphrase, tstrAuthPsk::pu8Psk, tstrNetworkId::pu8Ssid, tstrM2mWifiWepParams::u8KeyIndx, tstrM2mWifiWepParams::u8KeySz, tstrAuthPsk::u8PassphraseLen, tstrNetworkId::u8SsidLen, WIFI_CRED_DONTSAVE, and WIFI_CRED_SAVE_ENCRYPTED.

sint8 m2m_wifi_connect_wep ( tenuCredStoreOption  enuCredStoreOption,
tstrNetworkId pstrNetworkId,
tstrAuthWep pstrAuthWep 
)

Asynchronous API to connect to an access point using WEP authentication.

Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the WEP key provided in pstrAuthWep.
On successful connection, the connection details may be saved in WINC's flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuthWep) are stored in WINC's flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuthWepStructure specifying the WEP key.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.
Asynchronous Wi-Fi connection function. An application calling this function will cause the
firmware to attempt to connect to an access point matching the details in pstrNetworkId, with
the WEP key provided in pstrAuthWep.
On successful connection, the connection details may be saved in WINC flash, according to
the option selected in enuCredStoreOption.
Once connection has been attempted (whether successful or otherwise), a response event
@ref M2M_WIFI_RESP_CON_STATE_CHANGED will be sent to the callback function @ref tpfAppWifiCb
provided during initialization @ref m2m_wifi_init.

Possible results indicated by the response event are:
- @ref M2M_WIFI_DISCONNECTED if the connection attempt failed.
- @ref M2M_WIFI_CONNECTED if the connection attempt succeeded.
Precondition
Prior to attempting connection, the WINC driver must have been initialized by calling the m2m_wifi_init function.
Warning
This function is handled in station mode only.
Parameters
[in]enuCredStoreOptionOption to specify whether connection details (i.e. the contents of pstrNetworkId and pstrAuthWep) are stored in WINC flash and, if so, whether they are encrypted before storing.
[in]pstrNetworkIdStructure specifying SSID/BSSID and Wi-Fi channel.
[in]pstrAuthWepStructure specifying the WEP key.
Returns
The function returns M2M_SUCCESS if the connect request has been successfully passed to the firmware and a negative value otherwise.

References tstrM2mWifiWepParamsLegacy_1_2::au8WepKey, tstrM2mWifiWep::au8WepKey, hexstr_2_bytes(), hif_send(), legacy_connect_prepare_msg(), M2M_ERR_INVALID_ARG, M2M_ERR_MEM_ALLOC, m2m_memcpy(), M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_wifi_connect_prepare_msg(), M2M_WIFI_REQ_CONN, M2M_WIFI_REQ_CONNECT, M2M_WIFI_SEC_WEP, NULL, tstrAuthWep::pu8WepKey, tstrM2mWifiConnectLegacy_1_2::strSec, tuniM2MWifiAuthLegacy_1_2::strWepInfo, tstrM2mWifiWep::u8KeyIndex, tstrAuthWep::u8KeyIndx, tstrM2mWifiWepParamsLegacy_1_2::u8KeyIndx, tstrM2mWifiWep::u8KeyLen, tstrAuthWep::u8KeySz, tstrM2mWifiWepParamsLegacy_1_2::u8KeySz, tstrM2MWifiSecInfoLegacy_1_2::uniAuth, WEP_104_KEY_STRING_SIZE, WEP_40_KEY_STRING_SIZE, and WEP_KEY_MAX_INDEX.

sint8 m2m_wifi_default_connect ( void  )

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

Asynchronous Wi-Fi connection function. An application calling this function will cause
the firmware to correspondingly connect to the last successfully connected AP from the 
cached connections.\n
A failure to connect will result in a response of @ref M2M_WIFI_RESP_DEFAULT_CONNECT 
indicating the connection error as defined in the structure @ref tstrM2MDefaultConnResp.

Possible errors are: 
The connection list is empty @ref M2M_DEFAULT_CONN_EMPTY_LIST or a mismatch for the 
saved AP name @ref M2M_DEFAULT_CONN_SCAN_MISMATCH.
Precondition
Prior to connecting, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
This function must be 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
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Asynchronous Wi-Fi connection function. 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 @ref M2M_WIFI_RESP_DEFAULT_CONNECT
indicating a connection error as defined in the structure @ref tstrM2MDefaultConnResp.

Possible errors are:
@ref M2M_DEFAULT_CONN_EMPTY_LIST indicating that the connection list is empty, or
@ref M2M_DEFAULT_CONN_SCAN_MISMATCH indicating a mismatch for the saved AP name.
Precondition
Prior to connecting, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
This function must be 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
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DEFAULT_CONNECT, and NULL.

sint8 m2m_wifi_deinit ( void *  arg)

De-initialize the WINC driver and host interface.

Synchronous API to de-initialize the WINC driver and host interface.

Parameters
[in]argGeneric argument. Not used in current implementation.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Synchronous de-initialization function for the WINC driver.
De-initializes the host interface and frees any resources used by the M2M_WIFI layer. 
This function must be called in the application closing phase to ensure that all
resources have been correctly released.
No arguments are expected to be passed in. 
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.
Note
This function must be called at the de-initialization stage of the application. Generally this function should be the last function before switching off the chip and it should be followed only by nm_bsp_deinit function call. Every function call of m2m_wifi_init should be matched with a call to m2m_wifi_deinit.
See Also
nm_bsp_deinit m2m_wifi_init m2m_wifi_init_hold m2m_wifi_download_mode
De-initialization function for the WINC driver.
De-initializes the host interface and frees any resources used by the M2M_WIFI layer.
This function must be called in the application closing phase 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.
Note
This function must be called at the de-initialization stage of the application. Generally this function should be the last function before switching off the chip and it should be followed only by nm_bsp_deinit function call. Every function call of m2m_wifi_init should be matched with a call to m2m_wifi_deinit.
See Also
nm_bsp_deinit m2m_wifi_init m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit m2m_wifi_reinit_hold m2m_wifi_reinit_start m2m_wifi_download_mode m2m_wifi_download_mode

References hif_deinit(), M2M_SUCCESS, nm_drv_deinit(), and NULL.

sint8 m2m_wifi_delete_sc ( char *  pcSsid,
uint8  u8SsidLen 
)

Asynchronous API that deletes connection credentials (PSK, WEP key, 802.1X password) from WINC flash. Either deletes all credentials, or for a specific SSID.

Causes WINC to delete connection credentials. If the parameter is NULL, then WINC will delete
all credentials from flash. Otherwise WINC will only delete credentials for matching SSID.
Callback will report the status of the operation (success or not).
Parameters
[in]pcSsidSSID to match on when deleting credentials. SSID must not contain '\0'. NULL is a valid argument here, in which case all credentials are deleted.
[in]u8SsidLenLength of SSID provided in pcSsid. Must be less than M2M_MAX_SSID_LEN. This parameter is ignored if pcSsid is NULL.
Precondition
Prior to deleting credentials, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
The option to delete for a specific SSID is currently not supported; all credentials are deleted regardless of the input parameters.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Causes WINC to delete connection credentials. If the parameter is NULL, then WINC will delete
all credentials from flash. Otherwise WINC will only delete credentials for matching SSID.
Callback will report the status of the operation (success or not).
Parameters
[in]pcSsidSSID to match on when deleting credentials. SSID must not contain '\0'. NULL is a valid argument here, in which case all credentials are deleted.
[in]u8SsidLenLength of SSID provided in pcSsid. Must be less than M2M_MAX_SSID_LEN. This parameter is ignored if pcSsid is NULL.
Precondition
Prior to deleting credentials, the WINC driver should have been successfully initialized by calling the m2m_wifi_init function.
Warning
The option to delete for a specific SSID is currently not supported; all credentials are deleted regardless of the input parameters.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

References tstrM2mWifiApId::au8SSID, hif_send(), M2M_ERR_INVALID_ARG, M2M_MAX_SSID_LEN, m2m_memcpy(), m2m_memset(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQRSP_DELETE_APID, and NULL.

sint8 m2m_wifi_disable_ap ( void  )

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

Synchronous API to disable access point mode on the WINC.

See Also
m2m_wifi_enable_ap
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Must be called only when the AP is enabled through the @ref m2m_wifi_enable_ap
function. Otherwise the call to this function will not be useful.
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

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DISABLE_AP, and NULL.

sint8 m2m_wifi_disable_roaming ( void  )

Disable WiFi STA roaming.

Precondition
Must be called after the initialization.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
See Also
m2m_wifi_init

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_ROAMING, NULL, and tstrM2mWiFiRoaming::u8EnableRoaming.

sint8 m2m_wifi_disconnect ( void  )

Synchronous API to request disconnection from a network.

Precondition
Disconnection must be made to a successfully connected AP. If the WILC 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
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Request a Wi-Fi disconnect from the currently connected AP.
After the disconnect is complete the driver should receive a response of @ref M2M_WIFI_RESP_CON_STATE_CHANGED based on the states defined
in @ref tenuM2mConnState, successful disconnection is defined by @ref M2M_WIFI_DISCONNECTED .
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Disconnection request 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_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls m2m_wifi_default_connect
Request a Wi-Fi disconnect from the currently connected AP.
The connection status will be indicated to the application via a @ref M2M_WIFI_RESP_CON_STATE_CHANGED event.
The status will be one of those defined in @ref tenuM2mConnState, with @ref M2M_WIFI_DISCONNECTED indicating
a successful disconnection.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Precondition
Disconnection request 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_connect_sc m2m_wifi_default_connect m2m_wifi_connect_open m2m_wifi_connect_wep m2m_wifi_connect_psk m2m_wifi_connect_1x_mschap2 m2m_wifi_connect_1x_tls

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_DISCONNECT, and NULL.

sint8 m2m_wifi_download_mode ( void  )

Prepares the WINC board before downloading any data (Firmware, Certificates, etc).

Prepares the WINC before downloading any data (Firmware, Certificates, etc).

This function should be called before attempting to download any data to the WINC board.
Performs the appropriate WINC driver initialization, this includes bus initialization,
interrupt enabling and it halts the chip to allow for the firmware downloads. Firmware
can be downloaded through a number of interfaces, UART, I2C and SPI.
Precondition
Prior to call m2m_wifi_download_mode, the Application should ensure that the wifi is not initialized. This can be done by calling m2m_wifi_get_state and in case the wifi state differs from WIFI_STATE_DEINIT, a m2m_wifi_deinit needs to be issued.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
This function should be called before attempting to download any data to the WINC.
Performs the appropriate WINC driver initialization, this includes bus initialization,
interrupt enabling and it halts the chip to allow for the firmware downloads. Firmware
can be downloaded through a number of interfaces, UART, I2C and SPI.
Precondition
Prior to call m2m_wifi_download_mode, the Application should ensure that the wifi is not initialized. This can be done by calling m2m_wifi_get_state and in case the wifi state differs from WIFI_STATE_DEINIT, a m2m_wifi_deinit needs to be issued.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References enable_interrupts(), gu8WifiState, M2M_SUCCESS, nm_drv_init_download_mode(), and WIFI_STATE_INIT.

sint8 m2m_wifi_enable_ap ( CONST tstrM2MAPConfig pstrM2MAPConfig)

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

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

Parameters
[in]pstrM2MAPConfigA structure holding the AP configurations.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at intalization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The m2m_wifi_handle_events MUST be called to receive the responses in the callback.
See Also
tpfAppWifiCb tenuM2mSecType m2m_wifi_init tstrM2mWifiStateChanged tstrM2MAPConfig
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

Example

The code snippet demonstrates how the AP mode is enabled after the driver is initialized in the application's main function

#include "m2m_wifi.h"
#include "m2m_types.h"
void wifi_event_cb(uint8 u8WiFiEvent, void * pvMsg)
{
switch(u8WiFiEvent)
{
{
printf("STA has Associated\n");
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
tstrM2MAPConfig apConfig;
strcpy(apConfig.au8SSID, "WILC_SSID");
strcpy((char *)cfg.uniAuth.au8PSK, "12345678");
apConfig.u8ListenChannel = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}
The WINC IC supports the ability to operate as an access point with the following limitations:
  - Only 1 station may be associated at any given 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.
Precondition
Warning
This function is not allowed in STA mode.
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[3] = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}
The WINC supports the ability to operate as an access point with the following limitations:
- Only 1 station may be associated at any given 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[3] = 1;
// Trigger AP
m2m_wifi_enable_ap(&apConfig);
while(1)
{
}
}
}

References tstrM2MAPConfigExt::au8DefRouterIP, tstrM2MAPConfigExt::au8DNSServerIP, tuniM2MWifiAuth::au8PMK, tstrM2MAPConfigExt::au8SubnetMask, hif_send(), m2m_memcpy(), M2M_REQ_GRP_WIFI, m2m_strlen(), M2M_SUCCESS, m2m_wifi_enable_ap_ext(), M2M_WIFI_REQ_ENABLE_AP, M2M_WIFI_SEC_WPA_PSK, NULL, pbkdf2_sha1(), tstrM2MAPModeConfig::strApConfig, tstrM2MAPModeConfig::strApConfigExt, tstrM2MAPConfig::u8IsPMKUsed, and tstrM2MAPConfig::uniAuth.

sint8 m2m_wifi_enable_ap_ext ( CONST tstrM2MAPModeConfig pstrM2MAPModeConfig)

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

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

The WINC IC supports the ability to operate as an access point with the following limitations:
- Only 1 station may be associated at any given time.
- Open system and WEP are the only security suites supported.
Parameters
[in]pstrM2MAPModeConfigA 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.
Precondition
Warning
This function is not allowed in STA mode.
See Also
tpfAppWifiCb tenuM2mSecType m2m_wifi_init M2M_WIFI_REQ_DHCP_CONF tstrM2mWifiStateChanged tstrM2MAPModeConfig tstrM2MAPConfigExt

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))
{
tstrM2MAPModeConfig apModeConfig;
strcpy(apConfig.strApConfig.au8SSID, "WINC_SSID");
apModeConfig.strApConfig.u8ListenChannel = 1;
apModeConfig.strApConfig.u8SsidHide = 0;
// IP Address
apModeConfig.strApConfig.au8DHCPServerIP[0] = 192;
apModeConfig.strApConfig.au8DHCPServerIP[1] = 168;
apModeConfig.strApConfig.au8DHCPServerIP[2] = 1;
apModeConfig.strApConfig.au8DHCPServerIP[3] = 1;
// Default router IP
// DNS Server IP
// Subnet mask
apModeConfig.strApConfigExt.au8SubnetMask[0] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[1] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[2] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[3] = 0;
// Trigger AP
m2m_wifi_enable_ap_ext(&apModeConfig);
while(1)
{
}
}
}
The WINC supports the ability to operate as an access point with the following limitations:
- Only 1 station may be associated at any given time.
- Open system and WEP are the only security suites supported.
Parameters
[in]pstrM2MAPModeConfigA 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 tstrM2MAPModeConfig

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))
{
tstrM2MAPModeConfig apModeConfig;
strcpy(apModeConfig.strApConfig.au8SSID, "WINC_SSID");
apModeConfig.strApConfig.u8ListenChannel = 1;
apModeConfig.strApConfig.u8SsidHide = 0;
// IP Address
apModeConfig.strApConfig.au8DHCPServerIP[0] = 192;
apModeConfig.strApConfig.au8DHCPServerIP[1] = 168;
apModeConfig.strApConfig.au8DHCPServerIP[2] = 1;
apModeConfig.strApConfig.au8DHCPServerIP[3] = 1;
// Default router IP
// DNS Server IP
// Subnet mask
apModeConfig.strApConfigExt.au8SubnetMask[0] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[1] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[2] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[3] = 0;
// Trigger AP
m2m_wifi_enable_ap_ext(&apModeConfig);
while(1)
{
}
}
}

References hif_send(), M2M_ERR_FAIL, M2M_ERR_SEND, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_validate_ap_parameters(), M2M_WIFI_REQ_ENABLE_AP, M2M_WIFI_REQ_ENABLE_AP_LEGACY, and NULL.

sint8 m2m_wifi_enable_dhcp ( uint8  u8DhcpEn)

Enable/Disable the DHCP client after connection.

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

Synchronous Wi-Fi DHCP enable function. This function will Enable/Disable the DHCP protocol.
Parameters
[in]u8DhcpEnThe state of the DHCP client feature after successful association with an access point:
  • 1: Enables DHCP client after connection.
  • 0: Disables DHCP client after connection.
Returns
The function SHALL return M2M_SUCCESS for successful operation and a negative value otherwise.
Warning
DHCP client is enabled by default. This Function should be called before using m2m_wifi_set_static_ip
See Also
m2m_wifi_set_static_ip
This function allows the application to control the behaviour of the DHCP client function within
the WINC 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:
  • 1: Enables DHCP client after connection.
  • 0: Disables DHCP client after connection.
Returns
The function returns M2M_SUCCESS for successful operation 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

References hif_send(), M2M_IP_REQ_DISABLE_DHCP, M2M_IP_REQ_ENABLE_DHCP, M2M_REQ_GROUP_IP, and NULL.

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)

Enable or Disable logs in run time.

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
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.
Precondition
Must be called after initialization through the following function m2m_wifi_init().
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) m2m_wifi_init
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
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.
Precondition
Must be called after initialization through the following function m2m_wifi_init.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
DISABLE_FIRMWARE_LOGS (build option to disable logs from initializations) m2m_wifi_init

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SET_ENABLE_LOGS, NULL, and tstrM2mEnableLogs::u8Enable.

NMI_API sint8 m2m_wifi_enable_mac_mcast ( uint8 pu8MulticastMacAddress,
uint8  u8AddRemove 
)

Add MAC filter to receive Multicast packets.

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

Synchronous function for filtering received MAC addresses.

Parameters
[in]pu8MulticastMacAddressPointer to the MAC address.
[in]u8AddRemoveFlag to Add/Remove MAC address.
Returns
The function SHALL return 0 for success and a negative value otherwise.
Synchronous function for filtering received MAC addresses from certain MAC address groups.
This function allows the addition/removal of certain MAC addresses, used in the multicast filter.
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
Note
Maximum number of MAC addresses that could be added is 8.
Warning
This function is available in ETHERNET/bypass mode ONLY. Make sure that the application defines ETH_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_set_receive_buffer m2m_wifi_send_ethernet_pkt
This function will configure the WINC to receive/ignore multicast packets from certain
MAC address groups when operating in bypass mode.
This function requests the given MAC addresses to be added/removed from the multicast filter.
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
Note
Maximum number of MAC addresses that could be added is 8.
Warning
This function is available in ETHERNET/bypass mode ONLY. Make sure that the application defines ETH_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_set_receive_buffer m2m_wifi_send_ethernet_pkt

References tstrM2MMulticastMac::au8macaddress, hif_send(), M2M_DBG, M2M_ERR_FAIL, M2M_MAC_ADDRES_LEN, m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_MAC_MCAST, NULL, and tstrM2MMulticastMac::u8AddRemove.

sint8 m2m_wifi_enable_roaming ( uint8  bEnableDhcp)

Enable WiFi STA roaming.

m2m_wifi_enable_roaming enables the firmware to trigger the roaming algorithm/steps on link loss with the current AP.
If roaming is successful, 
    the @ref M2M_WIFI_RESP_CON_STATE_CHANGED message with state as @ref M2M_WIFI_ROAMED is sent to host.
    Additionally a @ref M2M_WIFI_REQ_DHCP_CONF message with new DHCP lease details is sent to host (only if bEnableDhcp=1).
If roaming is unsuccessful,
    @ref M2M_WIFI_RESP_CON_STATE_CHANGED message with state as @ref M2M_WIFI_DISCONNECTED is sent to host.
Parameters
[in]bEnableDhcp0 : Disables DHCP client execution after roaming to new AP 1 : Enables DHCP client execution after roaming to new AP
Precondition
Must be called after the initialization. The roaming algorithm/procedure is internal to the firmware.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
See Also
m2m_wifi_init
m2m_wifi_enable_roaming enables the firmware to trigger the roaming algorithm/steps on link loss with the current AP.
If roaming is successful, the @ref M2M_WIFI_RESP_CON_STATE_CHANGED message with state as @ref M2M_WIFI_ROAMED is sent to the host.
Additionally a @ref M2M_WIFI_REQ_DHCP_CONF message with new DHCP lease details is sent to host (only if bEnableDhcp=1).
If roaming is unsuccessful, a @ref M2M_WIFI_RESP_CON_STATE_CHANGED message with state as @ref M2M_WIFI_DISCONNECTED is sent to host.
Parameters
[in]bEnableDhcp0 : Disables DHCP client execution after roaming to new AP 1 : Enables DHCP client execution after roaming to new AP
Precondition
Must be called after the initialization. The roaming algorithm/procedure is internal to the firmware.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
See Also
m2m_wifi_init

References hif_send(), M2M_ERR_INVALID_ARG, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_ROAMING, NULL, tstrM2mWiFiRoaming::u8EnableDhcp, and tstrM2mWiFiRoaming::u8EnableRoaming.

sint8 m2m_wifi_enable_sntp ( uint8  bEnable)

Synchronous function to enable/disable the native Simple Network Time Protocol(SNTP) client in the WINC15x0 firmware.

Asynchronous API to enable or disable the native Simple Network Time Protocol(SNTP) client running on the WINC.

The SNTP is enabled by default at start-up.The SNTP client at firmware is used to 
synchronize the system clock to the UTC time from the well known time servers (e.g. "time-c.nist.gov").
The SNTP client uses a default update cycle of 1 day.

The UTC is important for checking the expiration date of X509 certificates used while establishing
TLS (Transport Layer Security) connections.

It is highly recommended to use it if there is no other means to get the UTC time. If there is a RTC
on the host MCU, the SNTP could be disabled and the host should set the system time to the firmware 
using the @ref m2m_wifi_set_system_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_system_time
The SNTP client is enabled by default during chip initialization. This function can be used to
disable or subsequently re-enable the service.

The service is capable of synchronizing the WINC 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 (Transport Layer Security)
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's time
may be set using the @ref m2m_wifi_set_system_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_system_time

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_DISABLE_SNTP_CLIENT, M2M_WIFI_REQ_ENABLE_SNTP_CLIENT, and NULL.

uint32 m2m_wifi_get_chipId ( void  )

Get the WINC Chip ID.

Synchronous API to obtain the firmware WINC chip ID.

Returns
The function SHALL return chipID >0 or 0 for failure.
The function returns chipID > 0 or 0 for failure.

References nmi_get_chipid().

sint8 m2m_wifi_get_connection_info ( void  )

Request the status information of the currently connected Wi-Fi AP. The result is passed to the Wi-Fi notification callback with the event M2M_WIFI_RESP_CONN_INFO.

Asynchronous API for retrieving the WINC connection status.

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

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 intialization m2m_wifi_init function.
  • The event M2M_WIFI_RESP_CONN_INFO must be handled in the callback to receive the requested connection info.
Warning
Calling this function is valid ONLY in the STA CONNECTED state. Otherwise, the WILC SW shall ignore the request silently.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_CONN_INFO tstrM2MConnInfo
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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;
default:
break;
}
}
int main()
{
tuniM2MWifiAuth sta_auth_param;
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// connect to the AP
m2m_wifi_connect((char *)DEMO_WLAN_SSID, sizeof(DEMO_WLAN_SSID),
M2M_WIFI_SEC_OPEN, &sta_auth_param, M2M_WIFI_CH_ALL);
while(1)
{
}
}
}
Asynchronous connection status retrieval function, retrieves the status information of the 
currently connected AP. 
The result is passed to the Wi-Fi notification callback through the event 
@ref M2M_WIFI_RESP_CONN_INFO. Connection information is retrieved from 
the structure @ref tstrM2MConnInfo.

Connection Information retrieved:
-Connection Security
-Connection RSSI
-Remote MAC address
-Remote IP address

In case the WINC is operating in station mode, the SSID of the AP is also retrieved.
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 the WINC is operating in AP mode, the SSID field will be returned as a NULL string.
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_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)
{
}
}
}
Requests the connection status from the WINC 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 notification callback through
the event @ref M2M_WIFI_RESP_CONN_INFO.

The connection info can be retrieved using the structure @ref 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)
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 the WINC is operating in AP mode or P2P mode, the SSID field will be returned as a NULL string.
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_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)
{
}
}
}

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_GET_CONN_INFO, and NULL.

sint8 m2m_wifi_get_firmware_version ( tstrM2mRev pstrRev)

Get Firmware version info.

Synchronous API to obtain the firmware version currently running on the WINC.

Synchronous API to obtain the firmware version currently running on the WINC IC.

Get the Firmware version info from the active partition, as defined in the structure tstrM2mRev.

Parameters
[out]pstrRevPointer to the structure tstrM2mRev that contains the firmware version parameters.
Precondition
Must be called after initialization through the following function m2m_wifi_init.
See Also
m2m_wifi_init
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Parameters
[out]pstrRevpointer holds address of structure "tstrM2mRev" that contains the firmware version parameters
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
Get the Firmware version info from the active partition, as defined in the structure @ref tstrM2mRev.
Parameters
[out]pstrRevPointer to a variable of type tstrM2mRev, which contains the firmware version parameters.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
Precondition
Must be called after initialization through the following function m2m_wifi_init.
See Also
m2m_wifi_init

References hif_chip_sleep(), hif_chip_wake(), M2M_SUCCESS, and nm_get_firmware_full_info().

sint8 m2m_wifi_get_mac_address ( uint8 pu8MacAddr)

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

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

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
Function to retrieve the current MAC address. 
The function is blocking until the response is received.
Precondition
Prior call to m2m_wifi_init is required before any WIFI/socket function.
Parameters
[out]pu8MacAddrPointer to a buffer in memory containing a 6-byte MAC address (provided function returns M2M_SUCCESS).
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See Also
m2m_wifi_get_otp_mac_address
This function obtains the MAC address that is currently in use by the device. If the function
returns with @ref 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.
Precondition
Prior call to m2m_wifi_init is required before any WIFI/socket function.
Parameters
[out]pu8MacAddrPointer to a buffer in memory containing a 6-byte MAC address (provided function returns M2M_SUCCESS).
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See Also
m2m_wifi_get_otp_mac_address

References hif_chip_sleep(), hif_chip_wake(), M2M_SUCCESS, and nmi_get_mac_address().

uint8 m2m_wifi_get_num_ap_found ( void  )

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.

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

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.
See Also
m2m_wifi_request_scan M2M_WIFI_RESP_SCAN_DONE M2M_WIFI_RESP_SCAN_RESULT
Precondition
m2m_wifi_request_scan need to be called first
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at intialization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_RESP_SCAN_DONE must be handled in the callback to receive the requested connection information.
Warning
This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
Returns
Return the number of AP's found in the last Scan Request.

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)
{
}
}
}
The function reads the number of APs from global variable which was updated in the Wi-Fi 
callback function through the @ref M2M_WIFI_RESP_SCAN_DONE event.
Function used only in STA mode only. 
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.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at initialization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_RESP_SCAN_DONE must be handled in the callback to receive the requested scan information.
Warning
This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
Returns
Return the number of AP's found in the last Scan Request.

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)
{
}
}
}
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 @ref M2M_WIFI_RESP_SCAN_DONE event.
Function to be used in STA mode only.
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.
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered at initialization. Registering the callback is done through passing it to the m2m_wifi_init.
  • The event M2M_WIFI_RESP_SCAN_DONE must be handled in the callback to receive the requested scan information.
Warning
This function must be called only in the wi-fi callback function when the events M2M_WIFI_RESP_SCAN_DONE or M2M_WIFI_RESP_SCAN_RESULT are received. Calling this function in any other place will result in undefined/outdated numbers.
Returns
Returns the number of AP's found in the last Scan Request.

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)
{
}
}
}

References gu8ChNum.

sint8 m2m_wifi_get_otp_mac_address ( uint8 pu8MacAddr,
uint8 pu8IsValid 
)

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

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

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

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
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.
Precondition
m2m_wifi_init required to call any WIFI/socket function
See Also
m2m_wifi_get_mac_address
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
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 is returned via RAM pointed to by the input arguments.

Request the MAC address stored on the One Time Programmable(OTP) memory of the device.
The function is blocking until the response is received.
Precondition
Prior call to m2m_wifi_init is required before any WIFI/socket function.
Parameters
[out]pu8MacAddrOutput MAC address buffer 6 bytes in size. Valid only if *pu8Valid=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
This function attempts to read the device's MAC address from the One Time Programmable (OTP)
memory on the WINC. The presence (yes or no) of a MAC address in the OTP memory and, in the case
of it being present, its value is returned via RAM pointed to by the input arguments.

Request the MAC address stored on the One Time Programmable(OTP) memory of the device.
The function is blocking until the response is received.
Precondition
Prior call to m2m_wifi_init is required before any WIFI/socket function.
Parameters
[out]pu8MacAddrOutput MAC address buffer 6 bytes in size. Valid only if *pu8Valid=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

References hif_chip_sleep(), hif_chip_wake(), m2m_memcpy(), M2M_SUCCESS, and nmi_get_otp_mac_address().

uint8 m2m_wifi_get_sleep_mode ( void  )

Get the current Power save mode.

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

Synchronous power save mode retrieval function.

Returns
The current operating power saving mode.
See Also
tenuPowerSaveModes , m2m_wifi_set_sleep_mode
tenuPowerSaveModes m2m_wifi_set_sleep_mode
Returns
The current operating power saving mode.
The current operating power saving mode based on the enumerated sleep modes tenuPowerSaveModes.
See Also
tenuPowerSaveModes m2m_wifi_set_sleep_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

References hif_get_sleep_mode().

uint8 m2m_wifi_get_state ( void  )

Get the wifi state.

Returns
The function returns the current wifi state (see tenuWifiState for the possible states).
Note
Check the WINC state. See tenuWifiState for possible states.
WIFI_STATE_INIT state represents WINC initialized but not started, this is a suitable state for safe flash access.
See Also
m2m_wifi_init m2m_wifi_download_mode

References gu8WifiState, nm_get_state(), NM_STATE_DEINIT, NM_STATE_INIT, NM_STATE_START, WIFI_STATE_DEINIT, WIFI_STATE_INIT, and WIFI_STATE_START.

sint8 m2m_wifi_get_system_time ( void  )

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

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

See Also
m2m_wifi_enable_sntp tstrSystemTime
Note
get the system time from the sntp client using the API m2m_wifi_get_system_time.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Asynchronous function used to retrieve the system time through the use of the 
response @ref M2M_WIFI_RESP_GET_SYS_TIME.
Response time retrieved is parsed into the members defined in the 
structure @ref tstrSystemTime.
Note
Get the system time from the SNTP client using the API m2m_wifi_get_system_time.
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_sntp tstrSystemTime
This function will request the WINC to report its current system time to the application. The
information will arrive at the application via the @ref tpfAppWifiCb and event @ref M2M_WIFI_RESP_GET_SYS_TIME.
Response time retrieved is parsed into the members defined in the structure @ref tstrSystemTime.
Note
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_sntp tstrSystemTime

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_GET_SYS_TIME, and NULL.

sint8 m2m_wifi_handle_events ( void *  arg)

Synchronous M2M event handler function.

Precondition
Prior to receiving wi-fi interrupts, the WILC 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.
Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.
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.

Handle the various events received from the WINC board.
Whenever an event happens in the WINC board (e.g. Connection, Disconnection, DHCP, etc),
the WINC will interrupt the host to let it know that a new event has occurred. The host driver
will attempt to handle these events whenever the application decides to do so by calling
the m2m_wifi_handle_events function.
It is mandatory to call this function periodically and independently of any other condition.
It is ideal to include this function in the main and the most frequent loop of the
    host application.
Precondition
Prior to receiving events, 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.
Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.
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.

Handle the various events received from the WINC.
Whenever an event happens in the WINC (e.g. Connection, Disconnection, DHCP, etc),
the WINC will interrupt the host to let it know that a new event has occurred. The host driver
will attempt to handle these events whenever the application decides to do so by calling
the m2m_wifi_handle_events function.
It is mandatory to call this function periodically and independently of any other condition.
It is ideal to include this function in the main and the most frequent loop of the
host application.
Precondition
Prior to receiving events, 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.
Returns
The function returns M2M_SUCCESS for successful interrupt handling and a negative value otherwise.

References hif_handle_isr(), M2M_SUCCESS, m2m_wifi_get_state(), and WIFI_STATE_START.

Referenced by m2m_ble_event_get(), m2m_ble_plf_wait_func(), main(), os_hif_task(), and wifi_ap_provision().

sint8 m2m_wifi_init ( tstrWifiInitParam param)

Synchronous API to initialize the WINC driver.

Parameters
[in]pWifiInitParamThis is a pointer to the tstrWifiInitParam structure which holds the pointer to the application WIFI layer call back function, monitoring mode call back and tstrEthInitParam strucutre.
Precondition
Prior to this function call, application users must provide a call back 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
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
This function initializes the WINC driver by registering the callback function for the M2M_WIFI layer
(also the callback 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.

The possible Wi-Fi events that are expected to be received through the callback
function (provided by the application) to the M2M_WIFI layer are listed below:

 - @ref M2M_WIFI_RESP_CON_STATE_CHANGED
 - @ref M2M_WIFI_RESP_CONN_INFO
 - @ref M2M_WIFI_REQ_DHCP_CONF
 - @ref M2M_WIFI_REQ_WPS
 - @ref M2M_WIFI_RESP_IP_CONFLICT
 - @ref M2M_WIFI_RESP_SCAN_DONE
 - @ref M2M_WIFI_RESP_SCAN_RESULT
 - @ref M2M_WIFI_RESP_CURRENT_RSSI
 - @ref M2M_WIFI_RESP_CLIENT_INFO
 - @ref M2M_WIFI_RESP_PROVISION_INFO
 - @ref M2M_WIFI_RESP_DEFAULT_CONNECT
 - @ref M2M_WIFI_RESP_ETHERNET_RX_PACKET (if bypass mode is enabled)
 - @ref M2M_WIFI_RESP_WIFI_RX_PACKET (if monitoring mode is enabled)

Any application using the WINC driver must call this function at the start of its main function.
Parameters
[in]pWifiInitParamThis is a pointer to a structure of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function, monitoring mode callback and tstrEthInitParam structure (which contains initialization settings for bypass mode).
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
Prior to this function call, The application should initialize the BSP using nm_bsp_init. Also, application users must provide a call back function responsible for receiving all the wi-fi events that are received on the M2M_WIFI layer.
Warning
Failure to successfully complete indicates that the driver could not be initialized and a fatal error will prevent the application from proceeding, proper error handling should be implemented by the application.
See Also
m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start tstrWifiInitParam tenuM2mStaCmd tenuM2mStaCmd
This function initializes the WINC driver by registering the callback function for the M2M_WIFI layer
(also the callback 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.

The possible Wi-Fi events that are expected to be received through the callback
function (provided by the application) to the M2M_WIFI layer are listed below:

 - @ref M2M_WIFI_RESP_CON_STATE_CHANGED
 - @ref M2M_WIFI_RESP_CONN_INFO
 - @ref M2M_WIFI_REQ_DHCP_CONF
 - @ref M2M_WIFI_REQ_WPS
 - @ref M2M_WIFI_RESP_IP_CONFLICT
 - @ref M2M_WIFI_RESP_SCAN_DONE
 - @ref M2M_WIFI_RESP_SCAN_RESULT
 - @ref M2M_WIFI_RESP_CURRENT_RSSI
 - @ref M2M_WIFI_RESP_CLIENT_INFO
 - @ref M2M_WIFI_RESP_PROVISION_INFO
 - @ref M2M_WIFI_RESP_DEFAULT_CONNECT
 - @ref M2M_WIFI_RESP_ETHERNET_RX_PACKET (if bypass mode is enabled)
 - @ref M2M_WIFI_RESP_WIFI_RX_PACKET (if monitoring mode is enabled)

Any application using the WINC driver must call this function at the start of its main function.
Parameters
[in]pWifiInitParamThis is a pointer to a variable of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function, monitoring mode callback and tstrEthInitParam structure (which contains initialization settings for bypass mode).
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
Prior to this function call, the application should initialize the BSP using nm_bsp_init. Also, the application 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 indicates that the driver could not be initialized and a fatal error will prevent the application from proceeding, proper error handling should be implemented by the application.
See Also
m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit m2m_wifi_reinit_hold m2m_wifi_reinit_start m2m_wifi_download_mode tstrWifiInitParam tenuM2mStaCmd

References tstrEthInitParam::au8ethRcvBuf, gpfAppEthCb, gpfAppMonCb, gpfAppWifiCb, gpu8ethRcvBuf, gu16ethRcvBufSize, gu8scanInProgress, hif_init(), hif_register_cb(), M2M_REQ_GRP_WIFI, M2M_SUCCESS, m2m_wifi_cb(), m2m_wifi_init_hold(), m2m_wifi_init_start(), nm_drv_deinit(), nm_drv_init(), NULL, tstrEthInitParam::pfAppEthCb, tstrWifiInitParam::pfAppMonCb, tstrWifiInitParam::pfAppWifiCb, tstrHifinitParam::pu8RcvBuff, tstrWifiInitParam::strEthInitParam, strHifInitParam, tstrEthInitParam::u16ethRcvBufSize, and tstrHifinitParam::u32RcvBuffSize.

sint8 m2m_wifi_init_start ( tstrWifiInitParam param)

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

Parameters
[in]pWifiInitParamThis is a pointer to a variable of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function (see tpfAppWifiCb), monitoring mode callback (see tpfAppEthCb) and tstrEthInitParam structure (which contains initialization settings for bypass mode).
See Also
m2m_wifi_init tstrWifiInitParam
Parameters
[in]pWifiInitParamThis is a pointer to a variable of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function (see tpfAppWifiCb), monitoring mode callback (see tpfAppEthCb) and tstrEthInitParam structure (which contains initialization settings for bypass mode).
See Also
m2m_wifi_init m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_reinit m2m_wifi_reinit_hold m2m_wifi_reinit_start m2m_wifi_download_mode tstrWifiInitParam

References tstrEthInitParam::au8ethRcvBuf, tstrM2mRev::BuildDate, tstrM2mRev::BuildTime, tstrWifiInitParam::GainTableIndex, gau8ethRcvBuf, gpfAppEthCb, gpfAppWifiCb, gu16ethRcvBufSize, gu8scanInProgress, gu8WifiState, hif_enable_access(), hif_init(), hif_register_cb(), M2M_DRIVER_VERSION_MAJOR_NO, M2M_DRIVER_VERSION_MINOR_NO, M2M_DRIVER_VERSION_PATCH_NO, M2M_ERR, M2M_ERR_FAIL, M2M_ERR_FW_VER_MISMATCH, M2M_HIF_BLOCK_VALUE, M2M_HIF_MAJOR_VALUE, M2M_HIF_MINOR_VALUE, M2M_INFO, m2m_ota_get_firmware_version(), M2M_RELEASE_VERSION_MAJOR_NO, M2M_RELEASE_VERSION_MINOR_NO, M2M_RELEASE_VERSION_PATCH_NO, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_wifi_ble_set_gain_table(), m2m_wifi_cb(), m2m_wifi_get_firmware_version(), M2M_WIFI_MODE_ETHERNET, M2M_WIFI_MODE_NORMAL, nm_drv_deinit(), nm_drv_init_start(), nm_get_firmware_full_info(), NULL, tstrEthInitParam::pfAppEthCb, tstrWifiInitParam::pfAppWifiCb, tstrWifiInitParam::strEthInitParam, tstrEthInitParam::u16ethRcvBufSize, tstrM2mRev::u16FirmwareSvnNum, tstrM2mRev::u8DriverMajor, tstrM2mRev::u8DriverMinor, tstrM2mRev::u8DriverPatch, tstrEthInitParam::u8EthernetEnable, tstrM2mRev::u8FirmwareMajor, tstrM2mRev::u8FirmwareMinor, tstrM2mRev::u8FirmwarePatch, WIFI_STATE_DEINIT, and WIFI_STATE_START.

sint8 m2m_wifi_p2p_disconnect ( void  )
Precondition
The p2p mode must have be enabled and active before a disconnect can be called.
See Also
m2m_wifi_p2p
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DISABLE_P2P, and NULL.

sint8 m2m_wifi_prng_get_random_bytes ( uint8 pu8PrngBuff,
uint16  u16PrngSize 
)

Get random bytes using the PRNG bytes.

Asynchronous function for retrieving from the firmware a pseudo-random set of bytes.

Parameters
[in]u16PrngSizeSize of the required random bytes to be generated.
[in]pu8PrngBuffPointer to user allocated buffer.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
Asynchronous function for retrieving from the firmware a pseudo-random set of bytes as specified in the size passed in as a parameter.
The registered wifi-cb function retrieves the random bytes through the response @ref M2M_WIFI_RESP_GET_PRNG
Parameters
[in]pu8PrngBuffPointer to a buffer to receive data.
[in]u16PrngSizeRequested size in bytes. Maximum 1580.
Warning
Size greater than the maximum specified (1580) causes a negative error M2M_ERR_FAIL.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Asynchronous function for retrieving from the firmware a pseudo-random set of bytes as specified in the size passed in as a parameter.
The registered wifi-cb function retrieves the random bytes through the response @ref M2M_WIFI_RESP_GET_PRNG
Parameters
[in]pu8PrngBuffPointer to a buffer to receive data.
[in]u16PrngSizeRequest size in bytes
Warning
Size greater than the maximum specified (M2M_BUFFER_MAX_SIZE - sizeof(tstrPrng)) causes a negative error M2M_ERR_FAIL.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_BUFFER_MAX_SIZE, M2M_ERR, M2M_ERR_FAIL, M2M_HIF_HDR_OFFSET, M2M_HIF_MAX_PACKET_SIZE, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_GET_PRNG, NULL, tstrPrng::pu8RngBuff, and tstrPrng::u16PrngSize.

sint8 m2m_wifi_reinit ( tstrWifiInitParam param)

De-initialize and then initialize wifi. Resets the WINC.

Parameters
[in]pWifiInitParamThis is a pointer to a variable of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function (see tpfAppWifiCb), monitoring mode callback (see tpfAppEthCb) and tstrEthInitParam structure (which contains initialization settings for bypass mode).
Note
m2m_wifi_reinit wraps a call to m2m_wifi_deinit and to m2m_wifi_init.
See Also
m2m_wifi_deinit m2m_wifi_init tstrWifiInitParam
Parameters
[in]pWifiInitParamThis is a pointer to a variable of type tstrWifiInitParam which contains pointers to the application WIFI layer callback function (see tpfAppWifiCb), monitoring mode callback (see tpfAppEthCb) and tstrEthInitParam structure (which contains initialization settings for bypass mode).
Note
m2m_wifi_reinit wraps a call to m2m_wifi_deinit and to m2m_wifi_init.
See Also
m2m_wifi_init m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit_hold m2m_wifi_reinit_start m2m_wifi_download_mode tstrWifiInitParam

References M2M_ERR_FAIL, M2M_SUCCESS, m2m_wifi_reinit_hold(), and m2m_wifi_reinit_start().

sint8 m2m_wifi_reinit_hold ( void  )

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

Note
m2m_wifi_reinit_hold wraps a call to m2m_wifi_deinit and to m2m_wifi_init_hold.
See Also
m2m_wifi_deinit m2m_wifi_reinit m2m_wifi_init_hold
Note
m2m_wifi_reinit_hold wraps a call to m2m_wifi_deinit and to m2m_wifi_init_hold.
See Also
m2m_wifi_init m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit m2m_wifi_reinit_start m2m_wifi_download_mode

References m2m_wifi_deinit(), m2m_wifi_init_hold(), and NULL.

sint8 m2m_wifi_reinit_start ( tstrWifiInitParam param)

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

Parameters
[in]pWifiInitParamThis is a pointer to the tstrWifiInitParam structure which contains pointers to the application WIFI layer callback function (see tpfAppWifiCb), monitoring mode callback (see tpfAppEthCb) and tstrEthInitParam structure (which contains initialization settings for bypass mode).
See Also
m2m_wifi_reinit m2m_wifi_init_start tstrWifiInitParam
Parameters
[in]pWifiInitParamThis is a pointer to the tstrWifiInitParam structure which contains pointers to the application WIFI layer callback function (see tpfAppWifiCb), monitoring mode callback (see tpfAppEthCb) and tstrEthInitParam structure (which contains initialization settings for bypass mode).
See Also
m2m_wifi_init m2m_wifi_deinit m2m_wifi_init_hold m2m_wifi_init_start m2m_wifi_reinit m2m_wifi_reinit_hold m2m_wifi_download_mode tstrWifiInitParam

References m2m_wifi_init_start().

sint8 m2m_wifi_req_curr_rssi ( void  )

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

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

See Also
M2M_WIFI_RESP_CURRENT_RSSI
Returns
The function shall return M2M_SUCCESS for success and a negative value otherwise.
Precondition
- A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered before intialization. Registering the callback is done through passing it to the m2m_wifi_init through the tstrWifiInitParam intialization structure.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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)
{
}
}
}
This function will result in the application receiving the RSSI via a
@ref M2M_WIFI_RESP_CURRENT_RSSI event.
Precondition
  • A Wi-Fi notification callback of type tpfAppWifiCb MUST be implemented and registered during initialization. Registration of the callback is done through passing it to m2m_wifi_init via the tstrWifiInitParam initialization structure.
  • The event M2M_WIFI_RESP_CURRENT_RSSI must be handled in the callback to receive the requested Rssi information.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

Example

The code snippet demonstrates how the RSSI request is called in the application's main function and the handling of the 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)
{
}
}
}

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_CURRENT_RSSI, and NULL.

sint8 m2m_wifi_req_scan_result ( uint8  index)

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.

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

Synchronous call to read the AP information from the SCAN Result list.

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_SUCCESE 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
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
Precondition
m2m_wifi_request_scan needs to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found
  • 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 function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested connection information.
Warning
Tthe scan results are updated only if the scan request is called. Calling this function only without a scan request will lead to firmware errors. Refrain from introducing a large delay between the scan request and the scan result request.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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
Synchronous call to read the AP information from the SCAN Result list with the given index.
This function is expected to be called when the response events @ref M2M_WIFI_RESP_SCAN_RESULT or
@ref M2M_WIFI_RESP_SCAN_DONE are received in the wi-fi callback function.
The response information received can be obtained through the casting to the 
@ref tstrM2mWifiscanResult structure.
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 needs to be called first, then m2m_wifi_get_num_ap_found to get the number of AP's found.
  • 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 function.
  • The event M2M_WIFI_RESP_SCAN_RESULT must be handled in the callback to receive the requested scan information.
Warning
  • Function used in STA mode only. the scan results are updated only if the scan request is called.
  • Calling this function only without a scan request will lead to firmware errors.
  • Application code should refrain from introducing a large delay between the scan request and the scan result request, to prevent errors occurring.

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
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
@ref M2M_WIFI_RESP_SCAN_RESULT event, and the response data may be obtained through casting
the pointer (pvMsg) to @ref 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 scan information.
Warning
  • This API is valid only for STA mode, it may be called regardless of the 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 the 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)
{
}
}
}

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SCAN_RESULT, NULL, and tstrM2mReqScanResult::u8Index.

sint8 m2m_wifi_request_dhcp_client ( void  )

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

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

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. 
Warning
This function has been deprecated. DHCP is used automatically when the WINC IC connects.
Returns
This function always returns M2M_SUCCESS.
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.
Warning
This function has been deprecated. DHCP is used automatically when the WINC connects.
Returns
This function always returns M2M_SUCCESS.
sint8 m2m_wifi_request_dhcp_server ( uint8 addr)

Dhcp requested by the firmware automatically in STA/AP mode).

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

Warning
This function is legacy and exists only for compatibility with older applications. DHCP server is started automatically when enabling the AP mode.
Returns
This function always returns M2M_SUCCESS.
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.
Parameters
[in]addrThe address to issue to a connected client (only one client is supported)
Warning
This function is legacy and exists only for compatibility with older applications. DHCP server is started automatically when enabling the AP mode.
Returns
This function always returns M2M_SUCCESS.
sint8 m2m_wifi_request_scan ( uint8  ch)

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

Asynchronous API to request the WINC to scan for networks.

Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh. With a value of M2M_WIFI_CH_ALL(255)), means to scan all channels.
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
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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)
{
}
}
}
Scan statuses are delivered to the application via the Wi-Fi event callback (@ref tpfAppWifiCb) in
three stages. The first step involves the event @ref 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 @ref m2m_wifi_req_scan_result API. For
each call to this function, the application will receive (step three) the event
@ref 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.
Precondition
Warning
This API is valid only for STA mode, it may be called regardless of connection state (connected or disconnected states).
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)
{
}
}
}
Scan statuses are delivered to the application via the Wi-Fi event callback (@ref tpfAppWifiCb) in
three stages. The first step involves the event @ref 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 @ref m2m_wifi_req_scan_result API. For
each call to this function, the application will receive (step three) the event
@ref 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.
Precondition
Warning
This API is valid only for STA mode, it may be called regardless of connection state (connected or disconnected states).
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)
{
}
}
}

References gu8scanInProgress, hif_send(), M2M_ERR, M2M_ERR_INVALID_ARG, M2M_ERR_SCAN_IN_PROGRESS, m2m_memset(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_CH_1, M2M_WIFI_CH_14, M2M_WIFI_CH_ALL, M2M_WIFI_REQ_SCAN, NULL, and tstrM2MScan::u8ChNum.

sint8 m2m_wifi_request_scan_ssid_list ( uint8  ch,
uint8 u8Ssidlist 
)

Asynchronous wi-fi scan request on the given channel and the hidden scan list.

The scan status is delivered in the wi-fi event callback and then the application
is to read the scan results sequentially. 
The number of  APs found (N) is returned in event @ref M2M_WIFI_RESP_SCAN_DONE with the number of found
APs.
The application could read the list of APs by calling the function @ref m2m_wifi_req_scan_result N times.
Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh. With a value of M2M_WIFI_CH_ALL, means to scan all channels.
[in]u8SsidListu8SsidList is a buffer containing a list of hidden SSIDs to include during the scan. The first byte in the buffer, u8SsidList[0], is the number of SSIDs encoded in the string. The number of hidden SSIDs cannot exceed MAX_HIDDEN_SITES. All SSIDs are concatenated in the following bytes and each SSID is prefixed with a one-byte header containing its length. The total number of bytes in u8SsidList buffer, including length byte, cannot exceed 133 bytes (MAX_HIDDEN_SITES SSIDs x 32 bytes each, which is max SSID length). For instance, encoding the two hidden SSIDs "DEMO_AP" and "TEST" results in the following buffer content:
uint8 u8SsidList[14];
u8SsidList[0] = 2; // Number of SSIDs is 2
u8SsidList[1] = 7; // Length of the string "DEMO_AP" without NULL termination
memcpy(&u8SsidList[2], "DEMO_AP", 7); // Bytes index 2-9 containing the string DEMO_AP
u8SsidList[9] = 4; // Length of the string "TEST" without NULL termination
memcpy(&u8SsidList[10], "TEST", 4); // Bytes index 10-13 containing the string TEST
Note
It works with STA/AP mode (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
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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"
static void request_scan_hidden_demo_ap(void);
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");
request_scan_hidden_demo_ap();
}
}
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;
}
}
static void request_scan_hidden_demo_ap(void)
{
uint8 list[9];
char ssid[] = "DEMO_AP";
uint8 len = (uint8)(sizeof(ssid)-1);
list[0] = 1;
list[1] = len;
memcpy(&list[2], ssid, len); // copy 7 bytes
// Scan all channels
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
request_scan_hidden_demo_ap();
while(1)
{
}
}
}
The scan status is delivered in the wi-fi event callback and then the application
is to read the scan results sequentially.
The number of  APs found (N) is returned in event @ref M2M_WIFI_RESP_SCAN_DONE with the number of found
APs.
The application could read the list of APs by calling the function @ref m2m_wifi_req_scan_result N times.
Parameters
[in]chRF Channel ID for SCAN operation. It should be set according to tenuM2mScanCh. With a value of M2M_WIFI_CH_ALL, means to scan all channels.
[in]u8SsidListu8SsidList is a buffer containing a list of hidden SSIDs to include during the scan. The first byte in the buffer, u8SsidList[0], is the number of SSIDs encoded in the string. The number of hidden SSIDs cannot exceed MAX_HIDDEN_SITES. All SSIDs are concatenated in the following bytes and each SSID is prefixed with a one-byte header containing its length. The total number of bytes in u8SsidList buffer, including length byte, cannot exceed 133 bytes (MAX_HIDDEN_SITES SSIDs x 32 bytes each, which is max SSID length). For instance, encoding the two hidden SSIDs "DEMO_AP" and "TEST" results in the following buffer content:
uint8 u8SsidList[14];
u8SsidList[0] = 2; // Number of SSIDs is 2
u8SsidList[1] = 7; // Length of the string "DEMO_AP" without NULL termination
memcpy(&u8SsidList[2], "DEMO_AP", 7); // Bytes index 2-9 containing the string DEMO_AP
u8SsidList[9] = 4; // Length of the string "TEST" without NULL termination
memcpy(&u8SsidList[10], "TEST", 4); // Bytes index 10-13 containing the string TEST
Note
It works with STA/AP mode (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
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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"
static void request_scan_hidden_demo_ap(void);
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");
request_scan_hidden_demo_ap();
}
}
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;
}
}
static void request_scan_hidden_demo_ap(void)
{
uint8 list[9];
char ssid[] = "DEMO_AP";
uint8 len = (uint8)(sizeof(ssid)-1);
list[0] = 1;
list[1] = len;
memcpy(&list[2], ssid, len); // copy 7 bytes
// Scan all channels
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
request_scan_hidden_demo_ap();
while(1)
{
}
}
}

References gu8scanInProgress, hif_send(), M2M_ERR_INVALID_ARG, M2M_ERR_SCAN_IN_PROGRESS, M2M_MAX_SSID_LEN, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_CH_1, M2M_WIFI_CH_14, M2M_WIFI_CH_ALL, M2M_WIFI_REQ_SCAN_SSID_LIST, MAX_HIDDEN_SITES, NULL, and tstrM2MScan::u8ChNum.

sint8 m2m_wifi_request_sleep ( uint32  u32SlpReqTime)

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

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

Synchronous power-save sleep request function, which requests the WINC device to sleep in the currently configured
power save mode, as set using @ref m2m_wifi_set_sleep_mode, for a specific time as defined by the passed in parameter.
This function should be used in the @ref M2M_PS_MANUAL power save mode only.
A wake up request is automatically performed by the WINC device when any host driver API function, e.g. Wi-Fi or socket operation is called.
Parameters
[in]u32SlpReqTimeRequest sleep time in ms.
The best recommended sleep duration is left to be determined by the application. Taking into account that if the application sends notifications very rarely, sleeping for a long time can be a power-efficient decision. In contrast, applications that are sensitive for long periods of absence can experience performance degradation in the connection if long sleeping times are used.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
Warning
The function should be called in M2M_PS_MANUAL power save mode only. As enumerated in tenuPowerSaveModes. It's also important to note that during the sleeping time while in the M2M_PS_MANUAL mode, AP beacon monitoring is bypassed and the wifi-connection may drop if the sleep period is elongated.
See Also
tenuPowerSaveModes m2m_wifi_set_sleep_mode
Power-save sleep request function, which requests the WINC device to sleep in the currently configured
power save mode, as set using @ref m2m_wifi_set_sleep_mode, for a specific time as defined by the parameter
u32SlpReqTime (measured in milliseconds).
This function should be used when the WINC is running in @ref M2M_PS_MANUAL power save mode only.
A wake up request is automatically performed by the WINC device when any host driver API function, e.g. Wi-Fi or socket operation is called.
Parameters
[in]u32SlpReqTimeRequest sleep time in ms.
The best recommended sleep duration is left to be determined by the application. Taking into account that if the application sends notifications very rarely, sleeping for a long time can be a power-efficient decision. In contrast, applications that are sensitive for long periods of absence can experience performance degradation in the connection if long sleeping times are used.
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

References hif_get_sleep_mode(), hif_send(), M2M_PS_MANUAL, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DOZE, NULL, and tstrM2mSlpReqTime::u32SleepTime.

sint8 m2m_wifi_send_ethernet_pkt ( uint8 pu8Packet,
uint16  u16PacketSize 
)

Synchronous function to transmit an Ethernet packet.

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

Transmit a packet directly in ETHERNET/bypass mode where the TCP/IP stack is disabled 
and the implementation of this packet is left to the application developer. 
The Ethernet packet composition is left to the application developer. 
Note
Packets are the user's responsibility.
Warning
This function available in ETHERNET/Bypass mode ONLY. Make sure that application defines ETH_MODE.
Parameters
[in]pu8PacketPointer to a buffer holding the whole Ethernet frame.
[in]u16PacketSizeThe size of the whole packet in bytes.
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_mac_mcast m2m_wifi_set_receive_buffer
Transmit a packet directly in ETHERNET/bypass mode where the TCP/IP stack is disabled
and the implementation of this packet is left to the application developer.
The Ethernet packet composition is left to the application developer.
Note
Packets are the user's responsibility.
Warning
This function available in ETHERNET/Bypass mode ONLY. Make sure that application defines ETH_MODE.
Parameters
[in]pu8PacketPointer to a buffer holding the whole Ethernet frame.
[in]u16PacketSizeThe size of the whole packet in bytes.
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_mac_mcast m2m_wifi_set_receive_buffer

References hif_send(), M2M_ETHERNET_HDR_LEN, M2M_ETHERNET_HDR_OFFSET, M2M_HIF_HDR_OFFSET, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SEND_ETHERNET_PACKET, NULL, tstrM2MWifiTxPacketInfo::u16HeaderLength, and tstrM2MWifiTxPacketInfo::u16PacketSize.

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)

Set the battery voltage to update the firmware calculations.
Not implemented in WINC3400 firmware.

Set the battery voltage to update the firmware calculations.
Not implemented in WINC3400 firmware.

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
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
Precondition
Must be called after initialization through the following function m2m_wifi_init.
Parameters
[in]u16BattVoltx100Battery voltage multiplied by 100
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_init

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SET_BATTERY_VOLTAGE, NULL, and tstrM2mBatteryVoltage::u16BattVolt.

sint8 m2m_wifi_set_cust_InfoElement ( uint8 pau8M2mCustInfoElement)

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

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

Synchronous function to Add/Remove user-defined Information Element to the WIFIBeacon and Probe Response frames while chip mode is Access Point Mode.\n
According to the information element layout shown bellow, if it is required to set new data for the information elements, pass in the buffer with the
information according to the sizes and ordering defined bellow. However, if it's required to delete these IEs, fill the buffer with zeros.
Parameters
[in]pau8M2mCustInfoElementPointer to Buffer containing the IE to be sent. It is the application developer's responsibility to ensure on the correctness of the information element's ordering passed in.
Warning
Size of All elements combined must not exceed 255 byte. Used in Access Point Mode.
Note
IEs Format will be follow the following layout:
    --------------- ---------- ---------- ------------------- -------- -------- ----------- -----------------------
              | 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.
See Also
m2m_wifi_enable_sntp

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;
}
This function allows the application to provide a custom Information Element to the
WINC that will be included in all beacon and probe response frames, while in Access Point mode.
If it is required to delete these IEs, fill the buffer with zeros.
Parameters
[in]pau8M2mCustInfoElementPointer to Buffer containing the IE to be used. It is the application developer's responsibility to ensure on the correctness of the information element's ordering passed in. If the pointer is 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)    |
    --------------- ---------- ---------- ------------------- -------- -------- ----------- -----------------------
Warning
Size of All elements combined must not exceed 255 byte. Used in Access Point Mode.
Note
IEs Format will follow the above format.
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_sntp

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

References hif_send(), M2M_ERR, M2M_ERR_FAIL, m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_CUST_INFO_ELEMENT, and NULL.

sint8 m2m_wifi_set_device_name ( uint8 pu8DeviceName,
uint8  u8DeviceNameLength 
)

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

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

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

Asynchronous API to set the "Device Name" of the WINC IC.

Sets the WINC device name. The name string is used as a device name in DHCP hostname (option 12).

m2m_wifi_set_device_name Set the WILC device name which is to be used as a P2P device name.

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.
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.
Warning
The function called once after initialization.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Sets the WINC device name. The name string is used as a device name in DHCP
hostname (option 12).
If a device is not set through this function a default name is assigned.
The default name is WINC-XX-YY, where XX and YY are the last 2 octets of the OTP 
MAC address. If OTP (eFuse) is programmed, then the default name is WINC-00-00.
Warning
The function called once after initialization.
Used for DHCP client hostname option (12).
Device name shall contain only characters allowed in valid internet host name as defined in RFC 952 and 1123.
Parameters
[in]pu8DeviceNameBuffer holding the device name. Device name is a null terminated C string.
[in]u8DeviceNameLengthLength of the device name. Should not exceed the maximum device name's length M2M_DEVICE_NAME_MAX (including null character).
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
Sets the WINC device name. The name string is used as a device name in DHCP
hostname (option 12).
If a device is not set through this function a default name is assigned.
The default name is WINC-XX-YY, where XX and YY are the last 2 octets of the OTP
MAC address. If OTP (eFuse) is programmed, then the default name is WINC-00-00.
Warning
The function called once after initialization.
Used for DHCP client hostname option (12).
Device name shall contain only characters allowed in valid internet host name as defined in RFC 952 and 1123.
Parameters
[in]pu8DeviceNameBuffer holding the device name. Device name is a null terminated C string.
[in]u8DeviceNameLengthLength of the device name. Should not exceed the maximum device name's length M2M_DEVICE_NAME_MAX (including null character).
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

References tstrM2MDeviceNameConfig::au8DeviceName, hif_send(), M2M_DEVICE_NAME_MAX, m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_SET_DEVICE_NAME, and NULL.

sint8 m2m_wifi_set_lsn_int ( tstrM2mLsnInt pstrM2mLsnInt)

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

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

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

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.
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configurations.
Precondition
Function m2m_wifi_set_sleep_mode shall be called first
Warning
The function should be called once after initialization.
See Also
tstrM2mLsnInt m2m_wifi_set_sleep_mode
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
This is one of the two synchronous power-save setting functions that
allow the host MCU application to tweak the system power consumption. Such tweaking can be done by modifying the 
Wi-Fi listen interval. The listen interval is how many beacon periods the station can sleep before it wakes up to receive data buffered in the AP.
It is represented in units of AP beacon periods(100ms).  
Warning
The function should be called once after initialization.
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configuration.
Precondition
The function m2m_wifi_set_sleep_mode shall be called first, to set the power saving mode required.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mLsnInt m2m_wifi_set_sleep_mode
This is one of the two synchronous power-save setting functions that
allow the host MCU application to tweak the system power consumption. Such tweaking can be done by modifying the
Wi-Fi listen interval. The listen interval is how many beacon periods the station can sleep before it wakes up to receive data buffered in the AP.
It is represented in units of AP beacon periods(100ms).
Warning
The function should be called once after initialization.
Parameters
[in]pstrM2mLsnIntStructure holding the listen interval configuration.
Precondition
The function m2m_wifi_set_sleep_mode shall be called first, to set the power saving mode required.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tstrM2mLsnInt m2m_wifi_set_sleep_mode

References hif_send(), m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_LSN_INT, NM_BSP_B_L_16, NULL, and tstrM2mLsnInt::u16LsnInt.

sint8 m2m_wifi_set_mac_address ( uint8  au8MacAddress[6])

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

Asynchronous API for assigning a MAC address to the WINC.

    This function override the already assigned MAC address of the WINC board with a user provided one. This is for experimental 
    use only and should never be used in the production SW.
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.
This function is intended to allow non-production software to assign a MAC address to the WINC.
Warning
This function is intended for development use only and not for use in production software.
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.

References tstrM2mSetMacAddress::au8Mac, hif_send(), m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_MAC_ADDRESS, and NULL.

sint8 m2m_wifi_set_power_profile ( uint8  u8PwrMode)

Change the power profile mode.

Change the power profile mode
Not implemented in WINC3400 firmware.

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,
Parameters
[in]u8PwrModeChange the WINC power profile to different mode based on the enumeration tenuM2mPwrMode.
Warning
May only be called after initialization, before any connection request, and may not be used to change the power mode thereafter.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mPwrMode m2m_wifi_init
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,
Parameters
[in]u8PwrModeChange the WINC power profile to different mode based on the enumeration tenuM2mPwrMode.
Not implemented in WINC3400 firmware.
Warning
May only be called after initialization, before any connection request, and may not be used to change the power mode thereafter.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mPwrMode m2m_wifi_init

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SET_POWER_PROFILE, NULL, and tstrM2mPwrMode::u8PwrMode.

NMI_API sint8 m2m_wifi_set_receive_buffer ( void *  pvBuffer,
uint16  u16BufferLen 
)

set the ethernet receive buffer, should be called in the receive call back.

Synchronous function for setting or modifying the receiver buffer's length.

Parameters
[in]pvBufferPointer to the ethernet receive buffer.
[in]u16BufferLenLength of the buffer.
Returns
The function SHALL return 0 for success and a negative value otherwise.
Synchronous function for setting or modifying the receiver buffer's length. 
In the ETHERNET/bypass mode the application should define a callback of type 
@ref tpfAppEthCb, through which the application handles the received 
ethernet frames. It is through this callback function that the user can 
dynamically modify the length of the currently used receiver buffer.
Parameters
[in]pvBufferPointer to Buffer to receive data. 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
Warning
This function is available in the Ethernet/bypass mode ONLY. Make sure that the application defines ETH_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_mac_mcast m2m_wifi_send_ethernet_pkt
Synchronous function for setting or modifying the receiver buffer's length.
In the ETHERNET/bypass mode the application should define a callback of type
@ref tpfAppEthCb, through which the application handles the received
ethernet frames. It is through this callback function that the user can
dynamically modify the length of the currently used receiver buffer.
Parameters
[in]pvBufferPointer to Buffer to receive data. 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
Warning
This function is available in the Ethernet/bypass mode ONLY. Make sure that the application defines ETH_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_mac_mcast m2m_wifi_send_ethernet_pkt

References gau8ethRcvBuf, gpu8ethRcvBuf, gu16ethRcvBufSize, hif_set_receive_buffer(), M2M_ERR, M2M_ERR_FAIL, M2M_SUCCESS, and NULL.

sint8 m2m_wifi_set_scan_options ( tstrM2MScanOption ptstrM2MScanOption)

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

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

This function sets the configuration parameters for the scan operation.
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
This function allows the application to tune the scanning behaviour of the WINC using the
parameters described in @ref 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

References hif_send(), M2M_ERR_FAIL, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, m2m_validate_scan_options(), M2M_WIFI_REQ_SET_SCAN_OPTION, and NULL.

sint8 m2m_wifi_set_scan_region ( uint16  ScanRegion)

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

Synchronous API for configuring the regulatory restrictions that may affect the WINC 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.

For 2.4GHz, supported in the current release, the requested scan region can't exceed the
maximum number of channels (14).
Parameters
[in]ScanRegionASIA NORTH_AMERICA
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
This function sets a property called the scan region, a parameter that affects the range of
channels that the WINC may legally scan given a geographic region.

For 2.4GHz, supported in the current release, the requested scan region cannot exceed the
maximum number of channels (14).
Parameters
[in]ScanRegionASIA EUROPE NORTH_AMERICA
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

References hif_send(), M2M_ERR_FAIL, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_SCAN_REGION, NULL, and tstrM2MScanRegion::u16ScanRegion.

sint8 m2m_wifi_set_sleep_mode ( uint8  PsTyp,
uint8  BcastEn 
)

Set the power saving mode for the WILC1000.

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

Set the power saving mode for the WINC3400.

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

Set the power saving mode for the WINC1500.

Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WILC1000 must be awake each DTIM Beacon for receiving Broadcast traffic. If it is 0, the WILC1000 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.
Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WILC1000 must be awake each DTIM beacon for receiving broadcast traffic. If it is 0, the WILC1000 will not wakeup at the DTIM beacon, but its wakeup depends only on the the configured Listen Interval.
See Also
tenuPowerSaveModes m2m_wifi_get_sleep_mode
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Parameters
[in]PsTypDesired power saving mode. Supported types are defined in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WINC1500 must be awake each DTIM Beacon for receiving Broadcast traffic. If it is 0, the WINC1500 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.
This is one of the two synchronous power-save setting functions that allow the host MCU application
to tweak the system power consumption. Such tweaking can be done through one of two ways:
- 1) Changing the power save mode, to one of the allowed power save modes (see @ref tenuPowerSaveModes). This is done by setting the first parameter.
- 2) Configuring DTIM monitoring: Configuring beacon monitoring parameters by enabling or disabling the reception of broadcast/multicast data.
     This is done by setting the second parameter.
Parameters
[in]PsTypDesired power saving mode. Supported types are enumerated in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If it is 1, the WINC will be awake for each DTIM beacon in order to check for and receive broadcast traffic. If it is 0, the WINC will ignore broadcast traffic. Through this flag the WINC will not wakeup at the DTIM beacon, but instead it will wakeup only based on the configured Listen Interval.
Warning
The function called once after initialization.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See Also
tenuPowerSaveModes m2m_wifi_get_sleep_mode m2m_wifi_set_lsn_int
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.
This is one of the two synchronous power-save setting functions that allow the host MCU application
to tweak the system power consumption. Such tweaking can be done through one of two ways:
- 1) Changing the power save mode, to one of the allowed power save modes (see @ref tenuPowerSaveModes). This is done by setting the first parameter.
- 2) Configuring DTIM monitoring: Configuring beacon monitoring parameters by enabling or disabling the reception of broadcast/multicast data.
     This is done by setting the second parameter.
Parameters
[in]PsTypDesired power saving mode. Supported types are enumerated in tenuPowerSaveModes.
[in]BcastEnBroadcast reception enable flag. If set to 1, the WINC will wake for each DTIM beacon to ensure broadcast traffic can be received. If set to 0, the WINC will not wakeup at the DTIM beacon, ignoring broadcast traffic, instead it will wake every N beacon periods, as per the negotiated Listen Interval.
Warning
The function called once after initialization.
Returns
The function returns M2M_SUCCESS for successful operation and a negative value otherwise.
See Also
tenuPowerSaveModes m2m_wifi_get_sleep_mode m2m_wifi_set_lsn_int

References hif_get_sleep_mode(), hif_send(), hif_set_sleep_mode(), M2M_INFO, M2M_NO_PS, M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SLEEP, NULL, tstrM2mPsType::u8BcastEn, and tstrM2mPsType::u8PsType.

sint8 m2m_wifi_set_static_ip ( tstrM2MIPConfig pstrStaticIPConf)

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

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

Assign a static IP address to the WINC board.
This function assigns a static IP address in case the AP doesn't have a DHCP 
server or in case the application wants to assign a predefined known IP 
address. The user must keep in mind that assigning a static IP address might
result in an IP address conflict. In case of an IP address conflict observed 
by the WINC board the user will get a response of @ref M2M_WIFI_RESP_IP_CONFLICT 
in the wifi callback. The application is then responsible to either solve the 
conflict or assign another IP address. 
Precondition
The application must disable auto DHCP using m2m_wifi_enable_dhcp before assigning a static IP address.
Warning
Normally this function should not be used. DHCP configuration is requested automatically after successful Wi-Fi connection is established.
Parameters
[in]pstrStaticIPConfPointer to a structure holding the static IP configuration (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.
See Also
tstrM2MIPConfig
Assigns a static IP address to the WINC.
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 or in case the application
wants to assign a predefined known IP address and the application.
This function can be used to assign a static IP address in case the application knows the specifics of the network.
The user must keep in mind that assigning a static IP address might
result in an IP address conflict. In case of an IP address conflict observed
by the WINC the user will get a response of @ref M2M_WIFI_RESP_IP_CONFLICT
in the wifi callback. The application is then responsible to either solve the
conflict or assign another IP address.
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.
Parameters
[in]pstrStaticIPConfPointer to a structure holding the static IP configuration (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.
See Also
tstrM2MIPConfig

References hif_send(), M2M_IP_REQ_STATIC_IP_CONF, M2M_REQ_GROUP_IP, NM_BSP_B_L_32, NULL, tstrM2MIPConfig::u32DNS, tstrM2MIPConfig::u32Gateway, tstrM2MIPConfig::u32StaticIP, and tstrM2MIPConfig::u32SubnetMask.

sint8 m2m_wifi_set_stop_scan_on_first ( uint8  u8StopScanOption)

Synchronous API for enabling/disabling the stop scan on first result of the WINC IC's network scanning functions.

Allows for enabling/disabling of stop scan on first result. When enabled, the WINC will stop the scan as soon as
it detects a network and return the results to the host. Setting is persistent and will need to be explicitly
reverted back by the application if it no longer wishes for it to be enabled.
Parameters
[in]u8StopScanOption;Setting for enabling or disabling Stopping Scan on first result. 1 = Enabled, 0 = Disabled (Default)
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tenuM2mScanCh tstrM2MScanOption tstrM2MStopScanOption m2m_wifi_request_scan m2m_wifi_set_scan_options

References hif_send(), M2M_ERR_FAIL, M2M_ERR_INVALID_ARG, M2M_INFO, M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_STOP_SCAN_OPTION, NULL, and tstrM2MStopScanOption::u8StopOnFirstResult.

sint8 m2m_wifi_set_system_time ( uint32  u32UTCSeconds)

Function for setting the system time within the WINC IC.

Asynchronous function for setting the system time within the WINC.

Synchronous function for setting the system time in time/date format (@ref uint32).
The @ref tstrSystemTime structure can be used as a reference to the time values that 
should be set and pass its value as @ref uint32.
Parameters
[in]u32UTCSecondsSeconds elapsed since January 1, 1900 (NTP Timestamp).
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_sntp tstrSystemTime
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_system_time.
Function for setting the system time in time/date format (@ref uint32).
The @ref tstrSystemTime structure can be used as a reference to the time values that
should be set and pass its value as @ref uint32.
Parameters
[in]u32UTCSecondsSeconds elapsed since January 1, 1900 (NTP Timestamp).
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_sntp tstrSystemTime
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_system_time.

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_SET_SYS_TIME, and NULL.

sint8 m2m_wifi_set_tx_power ( uint8  u8TxPwrLevel)

set the TX power

Set the TX power tenuM2mTxPwrLevel.

set the TX power tenuM2mTxPwrLevel

Parameters
[in]u8TxPwrLevelTX power ppa to one of these values: 0dBm, 3dBm, 6dBm, 9dBm, 12dBm, 15dBm, 18dBm. Other values between these steps will be floored to the nearest supported level. A maximum level might be enforced by the firmware to comply to RF regulations
Returns
The function SHALL return M2M_SUCCESE for success and a negative value otherwise.
See Also
Precondition
m2m_wifi_init
Warning
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
Parameters
[in]u8TxPwrLevelChange the TX power based on the enumeration tenuM2mTxPwrLevel.
Precondition
Must be called after the initialization and before any connection request and can't be changed in runtime.
Returns
The function SHALL return M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mTxPwrLevel m2m_wifi_init
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
Parameters
[in]u8TxPwrLevelChange the TX power based on the enumeration tenuM2mTxPwrLevel.
Precondition
Must be called after the initialization and before any connection request and can't be changed in runtime.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
tenuM2mTxPwrLevel m2m_wifi_init

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SET_TX_POWER, NULL, and tstrM2mTxPwrLevel::u8TxPwrLevel.

sint8 m2m_wifi_start_provision_mode ( tstrM2MAPConfig pstrM2MAPConfig,
char *  pcHttpServerDomainName,
uint8  bEnableHttpRedirect 
)

Asynchronous API for control of Wi-Fi provisioning functionality.

Asynchronous Wi-Fi provisioning function, which starts the WINC HTTP PROVISIONING mode.
The function triggers the WINC to activate the Wi-Fi AP (HOTSPOT) mode with the passed
configuration parameters and then starts the HTTP Provision WEB Server.

Provisioning status is returned in an event @ref M2M_WIFI_RESP_PROVISION_INFO.
Parameters
[in]pstrAPConfigAP configuration parameters as defined in tstrM2MAPConfig configuration structure. If a NULL value is passed in, the call 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. The domain name can have one of the following 3 forms:
  • 1. "wincprov.com"
  • 2. "http://wincprov.com"
  • 3. "https://wincprov.com"

Forms 1 and 2 are equivalent, they will both start a plain http server, while form 3 will start a secure HTTP provisioning Session (HTTP over SSL connection).

Parameters
[in]bEnableHttpRedirectA flag to enable/disable the HTTP redirect feature. If Secure provisioning is enabled (i.e. the server domain name uses "https" prefix) this flag is ignored (no meaning for redirect in HTTPS). Possible values are:
  • ZERO value, which means 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 value, means 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.
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
DO NOT use ".local" in the pcHttpServerDomainName.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_PROVISION_INFO m2m_wifi_stop_provision_mode tstrM2MAPConfig

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)
{
tstrNetworkId strNetworkId = {NULL, pstrProvInfo->au8SSID, (uint8)strlen((char*)(pstrProvInfo->au8SSID)), M2M_WIFI_CH_ALL};
tstrAuthPsk strAuthPsk = {NULL, pstrProvInfo->au8Password, (uint8)strlen((char*)(pstrProvInfo->au8Password))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
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[3] = 1;
m2m_wifi_start_provision_mode(&apConfig, "atmelwincconf.com", bEnableRedirect);
while(1)
{
}
}
}
This function allows the application to start the WINC 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 an event @ref M2M_WIFI_RESP_PROVISION_INFO.
Parameters
[in]pstrAPConfigAP configuration parameters as defined in tstrM2MAPConfig configuration structure. If a NULL value is passed in, the call 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. The domain name can have one of the following 3 forms:
  • 1. "wincprov.com"
  • 2. "http://wincprov.com"
  • 3. "https://wincprov.com"

Forms 1 and 2 are equivalent, they will both start a plain http server, while form 3 will start a secure HTTP provisioning Session (HTTP over SSL connection).

Parameters
[in]bEnableHttpRedirectA flag to enable/disable the HTTP redirect feature. If Secure provisioning is enabled (i.e. the server domain name uses "https" prefix) this flag is ignored (no meaning for redirect in HTTPS). 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.
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
Do not use ".local" in the pcHttpServerDomainName.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_PROVISION_INFO m2m_wifi_stop_provision_mode tstrM2MAPConfig

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)
{
tstrNetworkId strNetworkId = {NULL, pstrProvInfo->au8SSID, (uint8)strlen((char*)(pstrProvInfo->au8SSID)), M2M_WIFI_CH_ALL};
tstrAuthPsk strAuthPsk = {NULL, pstrProvInfo->au8Password, (uint8)strlen((char*)(pstrProvInfo->au8Password))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
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[3] = 1;
m2m_wifi_start_provision_mode(&apConfig, "atmelwincconf.com", bEnableRedirect);
while(1)
{
}
}
}

References tstrM2MAPConfigExt::au8DefRouterIP, tstrM2MAPConfig::au8DHCPServerIP, tstrM2MAPConfigExt::au8DNSServerIP, tstrM2MAPConfigExt::au8SubnetMask, m2m_memcpy(), m2m_wifi_start_provision_mode_ext(), tstrM2MAPModeConfig::strApConfig, and tstrM2MAPModeConfig::strApConfigExt.

sint8 m2m_wifi_start_provision_mode_ext ( tstrM2MAPModeConfig pstrAPModeConfig,
char *  pcHttpServerDomainName,
uint8  bEnableHttpRedirect 
)

Asynchronous API for control of Wi-Fi provisioning functionality with extended options.

Asynchronous Wi-Fi provisioning function, which starts the WINC HTTP PROVISIONING mode.
The function triggers the WINC to activate the Wi-Fi AP (HOTSPOT) mode with the passed
configuration parameters and then starts the HTTP Provision WEB Server.

Provisioning status is returned in an event @ref M2M_WIFI_RESP_PROVISION_INFO.
Parameters
[in]pstrAPModeConfigAP configuration parameters as defined in tstrM2MAPModeConfig 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. The domain name can have one of the following 3 forms:
  • 1. "wincprov.com"
  • 2. "http://wincprov.com"
  • 3. "https://wincprov.com"

The forms 1 and 2 are equivalent, they both will start a plain http server, while form 3 will start a secure HTTP provisioning Session (HTTP over SSL connection).

Parameters
[in]bEnableHttpRedirectA flag to enable/disable the HTTP redirect feature. If Secure provisioning is enabled (i.e. the server domain name uses "https" prefix) this flag is ignored (no meaning for redirect in HTTPS). Possible values are:
  • ZERO value, which means 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 value, means 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.
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
DO Not use ".local" in the pcHttpServerDomainName.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_PROVISION_INFO m2m_wifi_stop_provision_mode tstrM2MAPModeConfig
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.

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)
{
tstrNetworkId strNetworkId = {NULL, pstrProvInfo->au8SSID, (uint8)strlen((char*)(pstrProvInfo->au8SSID)), M2M_WIFI_CH_ALL};
tstrAuthPsk strAuthPsk = {NULL, pstrProvInfo->au8Password, (uint8)strlen((char*)(pstrProvInfo->au8Password))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
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))
{
tstrM2MAPModeConfig apModeConfig;
uint8 bEnableRedirect = 1;
strcpy(apModeConfig.strApConfig.au8SSID, "WINC_SSID");
apModeConfig.strApConfig.u8ListenChannel = 1;
apModeConfig.strApConfig.u8SsidHide = 0;
// IP Address
apModeConfig.strApConfig.au8DHCPServerIP[0] = 192;
apModeConfig.strApConfig.au8DHCPServerIP[1] = 168;
apModeConfig.strApConfig.au8DHCPServerIP[2] = 1;
apModeConfig.strApConfig.au8DHCPServerIP[3] = 1;
// Default router IP
// DNS Server IP
// Subnet mask
apModeConfig.strApConfigExt.au8SubnetMask[0] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[1] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[2] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[3] = 0;
m2m_wifi_start_provision_mode_ext(&apModeConfig, "atmelwincconf.com", bEnableRedirect);
while(1)
{
}
}
}
This function allows the application to start the WINC 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 an event @ref M2M_WIFI_RESP_PROVISION_INFO.
Parameters
[in]pstrAPModeConfigAP configuration parameters as defined in tstrM2MAPModeConfig 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. The domain name can have one of the following 3 forms:
  • 1. "wincprov.com"
  • 2. "http://wincprov.com"
  • 3. "https://wincprov.com"

The forms 1 and 2 are equivalent, they both will start a plain http server, while form 3 will start a secure HTTP provisioning Session (HTTP over SSL connection).

Parameters
[in]bEnableHttpRedirectA flag to enable/disable the HTTP redirect feature. If Secure provisioning is enabled (i.e. the server domain name uses "https" prefix) this flag is ignored (no meaning for redirect in HTTPS). 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.
Warning
Do not use ".local" in the pcHttpServerDomainName.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_RESP_PROVISION_INFO m2m_wifi_stop_provision_mode tstrM2MAPModeConfig

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)
{
tstrNetworkId strNetworkId = {NULL, pstrProvInfo->au8SSID, (uint8)strlen((char*)(pstrProvInfo->au8SSID)), M2M_WIFI_CH_ALL};
tstrAuthPsk strAuthPsk = {NULL, pstrProvInfo->au8Password, (uint8)strlen((char*)(pstrProvInfo->au8Password))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
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))
{
tstrM2MAPModeConfig apModeConfig;
uint8 bEnableRedirect = 1;
strcpy(apModeConfig.au8SSID, "WINC_SSID");
apModeConfig.strApConfig.u8ListenChannel = 1;
apModeConfig.strApConfig.u8SsidHide = 0;
// IP Address
apModeConfig.strApConfig.au8DHCPServerIP[0] = 192;
apModeConfig.strApConfig.au8DHCPServerIP[1] = 168;
apModeConfig.strApConfig.au8DHCPServerIP[2] = 1;
apModeConfig.strApConfig.au8DHCPServerIP[3] = 1;
// Default router IP
// DNS Server IP
// Subnet mask
apModeConfig.strApConfigExt.au8SubnetMask[0] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[1] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[2] = 255;
apModeConfig.strApConfigExt.au8SubnetMask[3] = 0;
m2m_wifi_start_provision_mode_ext(&apModeConfig, "atmelwincconf.com", bEnableRedirect);
while(1)
{
}
}
}

References tstrM2MProvisionModeConfig::acHttpServerDomainName, gu8scanInProgress, hif_send(), M2M_ERR, M2M_ERR_FAIL, M2M_ERR_SEND, m2m_memcpy(), M2M_REQ_DATA_PKT, M2M_REQ_GROUP_WIFI, m2m_strlen(), M2M_SUCCESS, m2m_validate_ap_parameters(), M2M_WIFI_REQ_START_PROVISION_MODE, M2M_WIFI_REQ_START_PROVISION_MODE_LEGACY, NULL, tstrM2MAPModeConfig::strApConfig, tstrM2MProvisionModeConfig::strApConfig, tstrM2MAPModeConfig::strApConfigExt, tstrM2MProvisionModeConfig::strApConfigExt, and tstrM2MProvisionModeConfig::u8EnableRedirect.

sint8 m2m_wifi_stop_provision_mode ( void  )

Synchronous API for terminating provisioning mode on the WINC IC.

Synchronous API for terminating provisioning mode on the WINC.

This function will terminate any currently active provisioning mode on the WINC IC, returning the 
IC to idle.
Precondition
An active provisioning session must be active before it is terminated through this function.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_start_provision_mode
This function will terminate any currently active provisioning mode on the WINC, returning the WINC to idle.
Precondition
An active provisioning session must be active before it is terminated through this function.
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_start_provision_mode

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_STOP_PROVISION_MODE, and NULL.

sint8 m2m_wifi_wps ( uint8  u8TriggerType,
const char *  pcPinNumber 
)

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

Asynchronous API to engage the WINC Wi-Fi Protected Setup (enrollee) function.

Parameters
[in]u8TriggerTypeWPS Trigger method. Could be:
[in]pcPinNumberPIN number for WPS PIN method. It is not used if the trigger type is WPS_PBC_TRIGGER. It must follow the rules stated by the WPS Standard.
Warning
This function is not allowed 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 WILC 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
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

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 Timedout\n");
}
}
break;
default:
break;
}
}
int main()
{
param.pfAppWifiCb = wifi_event_cb;
if(!m2m_wifi_init(&param))
{
// Trigger WPS in Push button mode.
while(1)
{
}
}
}
This function is called for the WINC to enter the WPS (Wi-Fi Protected Setup) mode. The result 
is passed to the Wi-Fi notification callback with the event @ref M2M_WIFI_REQ_WPS.
Parameters
[in]u8TriggerTypeWPS Trigger method. This may be:
[in]pcPinNumberPIN number for WPS PIN method. It is not used if the trigger type is WPS_PBC_TRIGGER. It must follow the rules stated by the WPS standard.
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 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 mode is active, the WPS will not be performed.
  • The m2m_wifi_handle_events MUST be called periodically to receive the responses in the callback.
Warning
This function is not allowed in AP mode.
Returns
The function returns M2M_SUCCESS if the command has been successfully queued to the WINC and a negative value otherwise.
See Also
tpfAppWifiCb m2m_wifi_init M2M_WIFI_REQ_WPS tenuWPSTrigger tstrM2MWPSInfo

Example

The code snippet shows an example of how wi-fi 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)
{
// establish Wi-Fi connection
tstrNetworkId strNetworkId = {NULL, pstrWPS->au8SSID, (uint8)strlen((char*)(pstrWPS->au8SSID)), pstrWPS->u8Ch};
if(pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN)
{
}
else
{
tstrAuthPsk strAuthPsk = {NULL, pstrWPS->au8PSK, (uint8)strlen((char*)(pstrWPS->au8PSK))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
}
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);
}
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)
{
}
}
}
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 @ref 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 allowed 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 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 periodically 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 wi-fi 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)
{
// establish Wi-Fi connection
tstrNetworkId strNetworkId = {NULL, pstrWPS->au8SSID, (uint8)strlen((char*)(pstrWPS->au8SSID)), pstrWPS->u8Ch};
if(pstrWPS->u8AuthType == M2M_WIFI_SEC_OPEN)
{
}
else
{
tstrAuthPsk strAuthPsk = {NULL, pstrWPS->au8PSK, (uint8)strlen((char*)(pstrWPS->au8PSK))};
m2m_wifi_connect_psk(WIFI_CRED_SAVE_ENCRYPTED, &strNetworkId, &strAuthPsk);
}
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);
}
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)
{
}
}
}

References tstrM2MWPSConnect::acPinNumber, gu8scanInProgress, hif_send(), m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_WIFI_REQ_START_WPS, M2M_WIFI_REQ_WPS, NULL, tstrM2MWPSConnect::u8TriggerType, and WPS_PIN_TRIGGER.

sint8 m2m_wifi_wps_disable ( void  )

Disable the WILC WPS operation.

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

Stops the ongoing WPS session.

Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.
Precondition
WINC should be already in WPS mode using m2m_wifi_wps.
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_wps

References hif_send(), M2M_REQ_GROUP_WIFI, M2M_REQ_GRP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_DISABLE_WPS, and NULL.

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

References hif_yield().

uint8* gau8ethRcvBuf = NULL
static
tpfAppEthCb gpfAppEthCb = NULL
static

Referenced by m2m_wifi_cb(), and m2m_wifi_init_start().

tpfAppWifiCb gpfAppWifiCb = NULL
static
uint16 gu16ethRcvBufSize
static
volatile uint8 gu8ChNum
static