Changes on the code
Dependencies: BSP_B-L475E-IOT01
wifi.h
00001 /** 00002 ****************************************************************************** 00003 * @file wifi.h 00004 * @author MCD Application Team 00005 * @version V1.8.0 00006 * @date 21-April-2017 00007 * @brief This file contains the diffrent wifi core resources definitions. 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V. 00012 * All rights reserved.</center></h2> 00013 * 00014 * Redistribution and use in source and binary forms, with or without 00015 * modification, are permitted, provided that the following conditions are met: 00016 * 00017 * 1. Redistribution of source code must retain the above copyright notice, 00018 * this list of conditions and the following disclaimer. 00019 * 2. Redistributions in binary form must reproduce the above copyright notice, 00020 * this list of conditions and the following disclaimer in the documentation 00021 * and/or other materials provided with the distribution. 00022 * 3. Neither the name of STMicroelectronics nor the names of other 00023 * contributors to this software may be used to endorse or promote products 00024 * derived from this software without specific written permission. 00025 * 4. This software, including modifications and/or derivative works of this 00026 * software, must execute solely and exclusively on microcontroller or 00027 * microprocessor devices manufactured by or for STMicroelectronics. 00028 * 5. Redistribution and use of this software other than as permitted under 00029 * this license is void and will automatically terminate your rights under 00030 * this license. 00031 * 00032 * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" 00033 * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT 00034 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 00035 * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY 00036 * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT 00037 * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00038 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00039 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 00040 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 00041 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 00042 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00043 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00044 * 00045 ****************************************************************************** 00046 */ 00047 #ifndef __WIFI_H_ 00048 #define __WIFI_H_ 00049 00050 #ifdef __cplusplus 00051 extern "C" { 00052 #endif 00053 00054 /* Includes ------------------------------------------------------------------*/ 00055 #include "es_wifi.h" 00056 #include "es_wifi_io.h" 00057 00058 /* Exported constants --------------------------------------------------------*/ 00059 #define WIFI_MAX_SSID_NAME 100 00060 #define WIFI_MAX_PSWD_NAME 100 00061 #define WIFI_MAX_APS 100 00062 #define WIFI_MAX_CONNECTIONS 4 00063 #define WIFI_MAX_MODULE_NAME 100 00064 #define WIFI_MAX_CONNECTED_STATIONS 2 00065 #define WIFI_MSG_JOINED 1 00066 #define WIFI_MSG_ASSIGNED 2 00067 00068 00069 /* Exported types ------------------------------------------------------------*/ 00070 typedef enum { 00071 WIFI_ECN_OPEN = 0x00, 00072 WIFI_ECN_WEP = 0x01, 00073 WIFI_ECN_WPA_PSK = 0x02, 00074 WIFI_ECN_WPA2_PSK = 0x03, 00075 WIFI_ECN_WPA_WPA2_PSK = 0x04, 00076 }WIFI_Ecn_t; 00077 00078 typedef enum { 00079 WIFI_TCP_PROTOCOL = 0, 00080 WIFI_UDP_PROTOCOL = 1, 00081 }WIFI_Protocol_t; 00082 00083 typedef enum { 00084 WIFI_SERVER = 0, 00085 WIFI_CLIENT = 1, 00086 }WIFI_Type_t; 00087 00088 typedef enum { 00089 WIFI_STATUS_OK = 0, 00090 WIFI_STATUS_ERROR = 1, 00091 WIFI_STATUS_NOT_SUPPORTED = 2, 00092 WIFI_STATUS_JOINED = 3, 00093 WIFI_STATUS_ASSIGNED = 4, 00094 }WIFI_Status_t; 00095 00096 typedef struct { 00097 WIFI_Ecn_t Ecn; /*!< Security of Wi-Fi spot. This parameter has a value of \ref WIFI_Ecn_t enumeration */ 00098 char SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Service Set Identifier value. Wi-Fi spot name */ 00099 int16_t RSSI; /*!< Signal strength of Wi-Fi spot */ 00100 uint8_t MAC[6]; /*!< MAC address of spot */ 00101 uint8_t Channel; /*!< Wi-Fi channel */ 00102 uint8_t Offset; /*!< Frequency offset from base 2.4GHz in kHz */ 00103 uint8_t Calibration; /*!< Frequency offset calibration */ 00104 }WIFI_AP_t; 00105 00106 typedef struct { 00107 WIFI_AP_t ap[WIFI_MAX_APS]; 00108 uint8_t count; 00109 } WIFI_APs_t; 00110 00111 00112 typedef struct { 00113 uint8_t Number; /*!< Connection number */ 00114 uint16_t RemotePort; /*!< Remote PORT number */ 00115 uint16_t LocalPort; 00116 uint8_t RemoteIP[4]; /*!< IP address of device */ 00117 WIFI_Protocol_t Protocol; /*!< Connection type. Parameter is valid only if connection is made as client */ 00118 uint32_t TotalBytesReceived; /*!< Number of bytes received in entire connection lifecycle */ 00119 uint32_t TotalBytesSent; /*!< Number of bytes sent in entire connection lifecycle */ 00120 uint8_t Active; /*!< Status if connection is active */ 00121 uint8_t Client; /*!< Set to 1 if connection was made as client */ 00122 } WIFI_Socket_t; 00123 00124 00125 typedef struct { 00126 00127 uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; 00128 uint8_t PSWD[WIFI_MAX_PSWD_NAME + 1]; 00129 uint8_t channel; 00130 WIFI_Ecn_t Ecn; 00131 } WIFI_APConfig_t; 00132 00133 typedef struct { 00134 uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Network public name for ESP AP mode */ 00135 uint8_t IP_Addr[4]; /*!< IP Address */ 00136 uint8_t MAC_Addr[6]; /*!< MAC address */ 00137 } WIFI_APSettings_t; 00138 00139 typedef struct { 00140 uint8_t IsConnected; 00141 uint8_t IP_Addr[4]; 00142 uint8_t IP_Mask[4]; 00143 uint8_t Gateway_Addr[4]; 00144 } WIFI_Conn_t; 00145 00146 /* Exported macro ------------------------------------------------------------*/ 00147 /* Exported functions ------------------------------------------------------- */ 00148 WIFI_Status_t WIFI_Init(void); 00149 WIFI_Status_t WIFI_ListAccessPoints(WIFI_APs_t *APs, uint8_t AP_MaxNbr); 00150 WIFI_Status_t WIFI_Connect( 00151 const char* SSID, 00152 const char* Password, 00153 WIFI_Ecn_t ecn); 00154 WIFI_Status_t WIFI_GetIP_Address(uint8_t *ipaddr); 00155 WIFI_Status_t WIFI_GetMAC_Address(uint8_t *mac); 00156 00157 WIFI_Status_t WIFI_Disconnect(void); 00158 WIFI_Status_t WIFI_ConfigureAP( 00159 uint8_t *ssid, 00160 uint8_t *pass, 00161 WIFI_Ecn_t ecn, 00162 uint8_t channel, 00163 uint8_t max_conn); 00164 00165 WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting); 00166 WIFI_Status_t WIFI_Ping(uint8_t* ipaddr, uint16_t count, uint16_t interval_ms); 00167 WIFI_Status_t WIFI_GetHostAddress( char* location, uint8_t* ipaddr); 00168 WIFI_Status_t WIFI_OpenClientConnection(uint32_t socket, WIFI_Protocol_t type, const char* name, uint8_t* ipaddr, uint16_t port, uint16_t local_port); 00169 WIFI_Status_t WIFI_CloseClientConnection(uint32_t socket); 00170 00171 WIFI_Status_t WIFI_StartServer(uint32_t socket, WIFI_Protocol_t type, const char* name, uint16_t port); 00172 WIFI_Status_t WIFI_StopServer(uint32_t socket); 00173 00174 WIFI_Status_t WIFI_SendData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *SentDatalen, uint32_t Timeout); 00175 WIFI_Status_t WIFI_ReceiveData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *RcvDatalen, uint32_t Timeout); 00176 WIFI_Status_t WIFI_StartClient(void); 00177 WIFI_Status_t WIFI_StopClient(void); 00178 00179 WIFI_Status_t WIFI_SetOEMProperties(const char *name, uint8_t *Mac); 00180 WIFI_Status_t WIFI_ResetModule(void); 00181 WIFI_Status_t WIFI_SetModuleDefault(void); 00182 WIFI_Status_t WIFI_ModuleFirmwareUpdate(const char *url); 00183 WIFI_Status_t WIFI_GetModuleID(char *Id); 00184 WIFI_Status_t WIFI_GetModuleFwRevision(char *rev); 00185 WIFI_Status_t WIFI_GetModuleName(char *ModuleName); 00186 #ifdef __cplusplus 00187 } 00188 #endif 00189 00190 #endif /* __WIFI_H_ */ 00191 00192 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Fri Jul 29 2022 17:05:21 by
1.7.2