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... | |
wifiProvisionParams * | httpProvInfo |
static uint8_t | rx_buf [RX_BUF_SZ] |
HTTP server globals. More... | |
static SOCKET | tcp_client_socket = -1 |
tstr1xAuthTLSCredentials | tlsCredentials |
enum prov_app_status |
|
static |
References APP_PROV_END, construct_http_response(), gu8AppStatus, POST_RESP, send(), and SOCKET_BUFFER_MAX_LENGTH.
Referenced by prov_socket_cb().
|
static |
Callback to get the Data from socket.
[in] | sock | socFket handler. |
[in] | u8Msg | socket event type. Possible values are:
|
[in] | pvMsg | is 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 |
Callback to get the Wi-Fi status update.
[in] | u8MsgType | type of Wi-Fi notification. Possible types are:
|
[in] | pvMsg | A 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().
void wifi_ap_provision | ( | wifiProvisionParams * | provParams | ) |
Wi-Fi Provisioning main application function.
This is a bocking function that wait for the user to connect to the PROV_WLAN_SOFTAP_SSID and provide the credentials in web page https://192.168.1.1/provisioning.html. The user is expected to close all the open socket and perofrm socketDeinit() and m2m_wifi_deinit before this function is called
References _htons, AF_INET, APP_PROV_AP_DISABLE, APP_PROV_DEINIT, APP_PROV_END, APP_PROV_IDLE, APP_PROV_START, APP_PROV_WINC_CONNECTED, tstrM2MAPConfig::au8DHCPServerIP, tstrM2MAPConfig::au8SSID, tstrM2MAPConfig::au8WepKey, bind(), close(), gu8AppStatus, HTTP_PORT, http_server_socket, M2M_SUCCESS, m2m_wifi_deinit(), m2m_wifi_disable_ap(), m2m_wifi_enable_ap(), m2m_wifi_handle_events(), m2m_wifi_init(), NULL, prov_socket_cb(), prov_wifi_cb(), PROV_WLAN_AUTH, PROV_WLAN_CHANNEL, PROV_WLAN_SOFTAP_SSID, registerSocketCallback(), in_addr::s_addr, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, socket(), SOCKET_FLAGS_SSL, socketDeinit(), socketInit(), tcp_client_socket, tstrM2MAPConfig::u8KeyIndx, tstrM2MAPConfig::u8KeySz, tstrM2MAPConfig::u8ListenChannel, and tstrM2MAPConfig::u8SecType.
Referenced by main().
|
static |
Referenced by html_handler(), prov_wifi_cb(), and wifi_ap_provision().
|
static |
Socket for TCP communication.
Referenced by prov_socket_cb(), and wifi_ap_provision().
wifiProvisionParams* httpProvInfo |
|
static |
HTTP server globals.
|
static |
Referenced by prov_socket_cb(), and wifi_ap_provision().
tstr1xAuthTLSCredentials tlsCredentials |
Referenced by post_main_page().