Microchip® Advanced Software Framework

winc3400/wifi_drv/driver/source/m2m_wifi.c File Reference

This module contains M2M Wi-Fi APIs implementation.

Copyright (c) 2017-2021 Microchip Technology Inc. and its subsidiaries.

#include "driver/include/m2m_wifi.h"
#include "driver/source/m2m_hif.h"
#include "driver/source/nmasic.h"
#include "driver/source/nmdrv.h"

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...
 
NMI_API sint8 m2m_wifi_ble_api_send (uint8 *msg, uint32 len)
 Asynchronous API to send an encapsulated Atmel BLE message over the Wifi Host Interface. More...
 
NMI_API sint8 m2m_wifi_ble_set_gain_table (uint8 table_idx)
 Asynchronous API that notifies the WINC with the Gain Table index from Flash that should use to configure the WiFi and BLE gains. More...
 
static void m2m_wifi_cb (uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
 
sint8 m2m_wifi_check_ota_rb (void)
 Synchronous API to check presence and compatibility 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. More...
 
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_restrict_ble (void)
 Asynchronous API to request restricting of BLE functionality by placing the BLE processor in a low power state. It is recommended to do this if it is known that BLE functionality will not be used for any significant length of time. 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_req_unrestrict_ble (void)
 Asynchronous API to request un-restricting of BLE functionality by reverting the BLE processor to full power mode. 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_passive (uint8 ch)
 Similar to m2m_wifi_request_scan but performs passive scanning instead of active scanning. 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