Microchip® Advanced Software Framework

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

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_RSV5   NBIT5
 
#define WIFI_1X_TLS_HS_FLAGS_RSV7   NBIT7
 
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING   NBIT4
 
#define WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT   NBIT6
 

Functions

static sint8 m2m_validate_ap_parameters (CONST tstrM2MAPModeConfig *pstrM2MAPModeConfig)
 
static sint8 m2m_validate_scan_options (tstrM2MScanOption *ptstrM2MScanOption)
 
static void m2m_wifi_cb (uint8 u8OpCode, uint16 u16DataSize, uint32 u32Addr)
 
static sint8 m2m_wifi_connect_prepare_msg (tenuCredStoreOption enuCredStoreOption, tenuM2mSecType enuAuthType, uint16 u16AuthSize, tstrNetworkId *pstrNetworkId, tstrM2mWifiConnHdr *pstrWifiConn)
 
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...
 
sint8 m2m_wifi_p2p (uint8 u8Channel)
 
sint8 m2m_wifi_p2p_disconnect (void)
 
sint8 m2m_wifi_req_client_ctrl (uint8 u8Cmd)
 Send a command to the PS Client (An WINC board running the ps_firmware), if the PS client send any commands it will be received in wifi_cb M2M_WIFI_RESP_CLIENT_INFO. More...
 
sint8 m2m_wifi_req_server_init (uint8 ch)
 Initialize the PS Server, The WINC support non secure communication with another WINC, (SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup. More...
 
sint8 m2m_wifi_send_crl (tstrTlsCrlInfo *pCRL)
 Asynchronous API that notifies the WINC with the Certificate Revocation List. 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_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)
 Stops the ongoing WPS session. More...
 

Variables

static uint8 gau81xRootSha1 [20] = {0}
 
static tpfAppWifiCb gpfAppWifiCb = NULL
 
static uint32 gu321xTlsHsFlags = WIFI_1X_TLS_HS_FLAGS_DEFAULT
 
static volatile uint8 gu8ChNum
 
static volatile uint8 gu8scanInProgress = 0
 
static volatile uint8 gu8WifiState = WIFI_STATE_DEINIT
 

#define WIFI_1X_TLS_HS_FLAGS_DEFAULT
Value:
( \
)
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING
Definition: m2m_wifi.c:53
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH
Definition: m2m_wifi.c:47
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK
Definition: m2m_wifi.c:49
#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_RSV5   NBIT5
#define WIFI_1X_TLS_HS_FLAGS_RSV7   NBIT7
#define WIFI_1X_TLS_HS_FLAGS_SESSION_CACHING   NBIT4
#define WIFI_1X_TLS_HS_FLAGS_SPECIFY_ROOTCERT   NBIT6

NMI_API sint8 m2m_wifi_enable_firmware_logs ( uint8  u8Enable)

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

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

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

sint8 m2m_wifi_p2p_disconnect ( void  )
NMI_API sint8 m2m_wifi_req_client_ctrl ( uint8  cmd)

Send a command to the PS Client (An WINC board running the ps_firmware), if the PS client send any commands it will be received in wifi_cb M2M_WIFI_RESP_CLIENT_INFO.

Asynchronous command sending function to the PS Client.

Parameters
[in]cmdControl command sent from PS Server to PS Client (command values defined by the application).
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_req_server_init, M2M_WIFI_RESP_CLIENT_INFO
Precondition
m2m_wifi_req_server_init should be called first
Asynchronous command sending function to the PS Client (a WINC board running the ps_firmware)
if the PS client sends any command, it will be received through the @ref M2M_WIFI_RESP_CLIENT_INFO event.
Parameters
[in]cmdControl command sent from PS Server to PS Client (command values defined by the application)
Precondition
m2m_wifi_req_server_init should be called first.
Warning
This mode is not supported in the current release.
See Also
m2m_wifi_req_server_init M2M_WIFI_RESP_CLIENT_INFO
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_ERR, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_CLIENT_CTRL, NULL, and tstrM2Mservercmd::u8cmd.

NMI_API sint8 m2m_wifi_req_server_init ( uint8  ch)

Initialize the PS Server, The WINC support non secure communication with another WINC, (SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup.

Synchronous function to initialize the PS Server.

Parameters
[in]chServer listening channel
Returns
The function returns M2M_SUCCESS for success and a negative value otherwise.
See Also
m2m_wifi_req_client_ctrl
Warning
The server mode can't be used with any other modes (STA/AP).
The WINC supports non secure communication with another WINC,
(SERVER/CLIENT) through one byte command (probe request and probe response) without any connection setup.
The server mode can't be used with any other modes (STA/AP)
Parameters
[in]chServer listening channel
See Also
m2m_wifi_req_client_ctrl
Warning
This mode is not supported in the current release.
Returns
The function returns M2M_SUCCESS for successful operations and a negative value otherwise.

References hif_send(), M2M_ERR, M2M_REQ_GROUP_WIFI, M2M_SUCCESS, M2M_WIFI_REQ_SERVER_INIT, NULL, and tstrM2mServerInit::u8Channel.

sint8 m2m_wifi_send_crl ( tstrTlsCrlInfo pCRL)

Asynchronous API that notifies the WINC with the Certificate Revocation List.

Parameters
[in]pCRLPointer to the structure containing certificate revocation list details.
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_ERR_FAIL, M2M_REQ_DATA_PKT, M2M_REQ_GROUP_SSL, M2M_SSL_IND_CRL, and NULL.

NMI_API sint8 m2m_wifi_set_battery_voltage ( uint16  u16BattVoltx100)

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

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

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

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

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

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

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

NMI_API sint8 m2m_wifi_wps_disable ( void  )

Stops the ongoing WPS session.

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_SUCCESS, M2M_WIFI_REQ_DISABLE_WPS, and NULL.

tpfAppWifiCb gpfAppWifiCb = NULL
static

Referenced by m2m_wifi_cb(), and m2m_wifi_init_start().

volatile uint8 gu8ChNum
static