Microchip® Advanced Software Framework

wifi_prov.c File Reference

This module contains WINC1500 Host MCU Provisioning implementation.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

#include "asf.h"
#include "wifi_prov.h"
#include "http_content.h"
#include "socket/include/socket.h"
#include "driver/include/m2m_wifi.h"
#include <string.h>

Enumerations

enum  prov_app_status {
  APP_PROV_INIT,
  APP_PROV_WINC_CONNECTED,
  APP_PROV_START,
  APP_PROV_END,
  APP_PROV_AP_DISABLE,
  APP_PROV_DEINIT,
  APP_PROV_IDLE
}
 Main app status. More...
 

Functions

static void html_handler (SOCKET sock, uint8_t *p, int16_t p_sz, wifiProvisionParams *provInfo)
 
static void prov_socket_cb (SOCKET sock, uint8_t u8Msg, void *pvMsg)
 Callback to get the Data from socket. More...
 
static void prov_wifi_cb (uint8_t u8MsgType, void *pvMsg)
 Callback to get the Wi-Fi status update. More...
 
void wifi_ap_connect (wifiProvisionParams *provParams)
 Wi-Fi Provisioning ap connect function. More...
 
void wifi_ap_provision (wifiProvisionParams *provParams)
 Wi-Fi Provisioning main application function. More...
 

Variables

static volatile prov_app_status gu8AppStatus = APP_PROV_INIT
 
static SOCKET http_server_socket = -1
 Socket for TCP communication. More...
 
wifiProvisionParamshttpProvInfo
 
static uint8_t rx_buf [RX_BUF_SZ]
 HTTP server globals. More...
 
static SOCKET tcp_client_socket = -1
 
tstr1xAuthTLSCredentials tlsCredentials
 

Main app status.

Enumerator
APP_PROV_INIT 
APP_PROV_WINC_CONNECTED 
APP_PROV_START 
APP_PROV_END 
APP_PROV_AP_DISABLE 
APP_PROV_DEINIT 
APP_PROV_IDLE 

static void html_handler ( SOCKET  sock,
uint8_t *  p,
int16_t  p_sz,
wifiProvisionParams provInfo 
)
static
static void prov_socket_cb ( SOCKET  sock,
uint8_t  u8Msg,
void *  pvMsg 
)
static

Callback to get the Data from socket.

Parameters
[in]socksocFket handler.
[in]u8Msgsocket event type. Possible values are:
  • SOCKET_MSG_BIND
  • SOCKET_MSG_LISTEN
  • SOCKET_MSG_ACCEPT
  • SOCKET_MSG_CONNECT
  • SOCKET_MSG_RECV
  • SOCKET_MSG_SEND
  • SOCKET_MSG_SENDTO
  • SOCKET_MSG_RECVFROM
[in]pvMsgis a pointer to message structure. Existing types are:

References accept(), html_handler(), http_server_socket, listen(), NULL, tstrSocketRecvMsg::pu8Buffer, recv(), rx_buf, tstrSocketRecvMsg::s16BufferSize, tstrSocketAcceptMsg::sock, SOCKET_MSG_ACCEPT, SOCKET_MSG_BIND, SOCKET_MSG_LISTEN, SOCKET_MSG_RECV, SOCKET_MSG_SEND, tstrSocketBindMsg::status, tstrSocketListenMsg::status, and tcp_client_socket.

Referenced by wifi_ap_provision().

static void prov_wifi_cb ( uint8_t  u8MsgType,
void *  pvMsg 
)
static

Callback to get the Wi-Fi status update.

Parameters
[in]u8MsgTypetype of Wi-Fi notification. Possible types are:
[in]pvMsgA pointer to a buffer containing the notification parameters (if any). It should be casted to the correct data type corresponding to the notification type. Existing types are:

References APP_PROV_AP_DISABLE, APP_PROV_DEINIT, APP_PROV_WINC_CONNECTED, gu8AppStatus, M2M_WIFI_CONNECTED, M2M_WIFI_DISCONNECTED, M2M_WIFI_REQ_DHCP_CONF, M2M_WIFI_RESP_CON_STATE_CHANGED, and tstrM2mWifiStateChanged::u8CurrState.

Referenced by wifi_ap_provision().

void wifi_ap_connect ( wifiProvisionParams provParams)

Wi-Fi Provisioning ap connect function.

This is a will connect to the AP with the credentials received in wifiProvisionParams The user is expected to perfom m2m_wifi_init() before calling this api.

References tstr1xAuthCredentials::au8Passwd, tstrM2MProvisionInfo::au8Password, tstrM2MProvisionInfo::au8SSID, tstr1xAuthCredentials::au8UserName, tstrM2mWifiWepParams::au8WepKey, tstrAuth1xMschap2::bPrependDomain, tstrAuth1xTls::bPrependDomain, tstrAuth1xMschap2::bUnencryptedUserName, tstrAuth1xTls::bUnencryptedUserName, tstrNetworkId::enuChannel, wifiProvisionParams::httpMsChapv2Params, wifiProvisionParams::httpProvParams, wifiProvisionParams::httpTLSParams, wifiProvisionParams::httpWepParams, m2m_strlen(), M2M_WIFI_CH_ALL, m2m_wifi_connect(), m2m_wifi_connect_1x_mschap2(), m2m_wifi_connect_1x_tls(), M2M_WIFI_SEC_802_1X, M2M_WIFI_SEC_OPEN, M2M_WIFI_SEC_WEP, M2M_WIFI_SEC_WPA_PSK, MSCHAPV2, NULL, PROV_WEB_PAGE_WEP_KEY_INDEX, tstrNetworkId::pu8Bssid, tstrAuth1xTls::pu8Certificate, tstrAuth1xMschap2::pu8Domain, tstrAuth1xTls::pu8Domain, tstrAuth1xMschap2::pu8Password, tstrAuth1xTls::pu8PrivateKey_Exp, tstrAuth1xTls::pu8PrivateKey_Mod, tstrNetworkId::pu8Ssid, tstrAuth1xMschap2::pu8UserName, tstrAuth1xTls::pu8UserName, wifiProvisionParams::sec_method, TLS, tstrAuth1xTls::u16CertificateLen, tstrAuth1xMschap2::u16PasswordLen, tstrAuth1xTls::u16PrivateKeyLen, tstrAuth1xMschap2::u16UserNameLen, tstrAuth1xTls::u16UserNameLen, tstrM2mWifiWepParams::u8KeyIndx, tstrM2mWifiWepParams::u8KeySz, tstrM2MProvisionInfo::u8SecType, tstrNetworkId::u8SsidLen, and WIFI_CRED_SAVE_ENCRYPTED.

Referenced by main().

volatile prov_app_status gu8AppStatus = APP_PROV_INIT
static
SOCKET http_server_socket = -1
static

Socket for TCP communication.

Referenced by prov_socket_cb(), and wifi_ap_provision().

wifiProvisionParams* httpProvInfo
uint8_t rx_buf[RX_BUF_SZ]
static

HTTP server globals.

SOCKET tcp_client_socket = -1
static
tstr1xAuthTLSCredentials tlsCredentials

Referenced by post_main_page().