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)
 
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...
 
uint32 m2m_wifi_get_chipId (void)
 Get the WINC Chip ID. More...
 
sint8 m2m_wifi_handle_events (void *arg)
 Synchronous M2M event handler function. More...
 
sint8 m2m_wifi_p2p (uint8 u8Channel)
 
sint8 m2m_wifi_p2p_disconnect (void)
 
sint8 m2m_wifi_wps (uint8 u8TriggerType, const char *pcPinNumber)
 Asynchronous API to engage the WINC Wi-Fi Protected Setup (enrollee) function. More...
 
sint8 m2m_wifi_wps_disable (void)
 Asynchronous API that disables Wi-Fi Protected Setup mode in the WINC. 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: m2m_wifi.c:49
#define WIFI_1X_TLS_HS_FLAGS_PEER_AUTH
Definition: m2m_wifi.c:46
#define WIFI_1X_TLS_HS_FLAGS_PEER_CERTTIMECHECK
Definition: 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_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 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.

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_handle_events ( void arg)

Synchronous M2M event handler function.

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

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 os_hif_task().

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

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

This function can be called to make the WINC enter WPS (Wi-Fi Protected Setup) mode. The result
is passed to the Wi-Fi notification callback with the event @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, hif_send(), m2m_memcpy(), M2M_REQ_GROUP_WIFI, M2M_WIFI_REQ_WPS, NULL, tstrM2MWPSConnect::u8TriggerType, and WPS_PIN_TRIGGER.

Referenced by os_m2m_wifi_wps_imp().

NMI_API sint8 m2m_wifi_wps_disable ( void  )

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

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.

Referenced by os_m2m_wifi_wps_disable().

uint8* gau8ethRcvBuf = NULL
static
tpfAppEthCb gpfAppEthCb = NULL
static

Referenced by m2m_wifi_cb(), and m2m_wifi_init_start().

tpfAppWifiCb gpfAppWifiCb = NULL
static

Referenced by m2m_wifi_cb(), and m2m_wifi_init_start().

uint16 gu16ethRcvBufSize
static
volatile uint8 gu8ChNum
static