added function to enable power saving mode for es_wifi driver (Inventek Systems ISM43362-M3G-L44 )
Fork of DISCO_L475VG_IOT01A_wifi by
wifi.h@1:b37920c1ddb9, 2017-12-19 (annotated)
- Committer:
- jaafaryn
- Date:
- Tue Dec 19 19:29:15 2017 +0000
- Revision:
- 1:b37920c1ddb9
- Parent:
- 0:c61a93635433
- Child:
- 2:9bbbcd0eff1c
Added a function to enter power save mode as described in application note: http://www.inventeksys.com/wp-content/uploads/powersave_v1.1_AN20046.pdf
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
adustm | 0:c61a93635433 | 1 | /** |
adustm | 0:c61a93635433 | 2 | ****************************************************************************** |
adustm | 0:c61a93635433 | 3 | * @file wifi.h |
adustm | 0:c61a93635433 | 4 | * @author MCD Application Team |
adustm | 0:c61a93635433 | 5 | * @version V1.8.0 |
adustm | 0:c61a93635433 | 6 | * @date 21-April-2017 |
adustm | 0:c61a93635433 | 7 | * @brief This file contains the diffrent wifi core resources definitions. |
adustm | 0:c61a93635433 | 8 | ****************************************************************************** |
adustm | 0:c61a93635433 | 9 | * @attention |
adustm | 0:c61a93635433 | 10 | * |
adustm | 0:c61a93635433 | 11 | * <h2><center>© Copyright (c) 2017 STMicroelectronics International N.V. |
adustm | 0:c61a93635433 | 12 | * All rights reserved.</center></h2> |
adustm | 0:c61a93635433 | 13 | * |
adustm | 0:c61a93635433 | 14 | * Redistribution and use in source and binary forms, with or without |
adustm | 0:c61a93635433 | 15 | * modification, are permitted, provided that the following conditions are met: |
adustm | 0:c61a93635433 | 16 | * |
adustm | 0:c61a93635433 | 17 | * 1. Redistribution of source code must retain the above copyright notice, |
adustm | 0:c61a93635433 | 18 | * this list of conditions and the following disclaimer. |
adustm | 0:c61a93635433 | 19 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
adustm | 0:c61a93635433 | 20 | * this list of conditions and the following disclaimer in the documentation |
adustm | 0:c61a93635433 | 21 | * and/or other materials provided with the distribution. |
adustm | 0:c61a93635433 | 22 | * 3. Neither the name of STMicroelectronics nor the names of other |
adustm | 0:c61a93635433 | 23 | * contributors to this software may be used to endorse or promote products |
adustm | 0:c61a93635433 | 24 | * derived from this software without specific written permission. |
adustm | 0:c61a93635433 | 25 | * 4. This software, including modifications and/or derivative works of this |
adustm | 0:c61a93635433 | 26 | * software, must execute solely and exclusively on microcontroller or |
adustm | 0:c61a93635433 | 27 | * microprocessor devices manufactured by or for STMicroelectronics. |
adustm | 0:c61a93635433 | 28 | * 5. Redistribution and use of this software other than as permitted under |
adustm | 0:c61a93635433 | 29 | * this license is void and will automatically terminate your rights under |
adustm | 0:c61a93635433 | 30 | * this license. |
adustm | 0:c61a93635433 | 31 | * |
adustm | 0:c61a93635433 | 32 | * THIS SOFTWARE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" |
adustm | 0:c61a93635433 | 33 | * AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT |
adustm | 0:c61a93635433 | 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
adustm | 0:c61a93635433 | 35 | * PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY |
adustm | 0:c61a93635433 | 36 | * RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT |
adustm | 0:c61a93635433 | 37 | * SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
adustm | 0:c61a93635433 | 38 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
adustm | 0:c61a93635433 | 39 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, |
adustm | 0:c61a93635433 | 40 | * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
adustm | 0:c61a93635433 | 41 | * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
adustm | 0:c61a93635433 | 42 | * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
adustm | 0:c61a93635433 | 43 | * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
adustm | 0:c61a93635433 | 44 | * |
adustm | 0:c61a93635433 | 45 | ****************************************************************************** |
adustm | 0:c61a93635433 | 46 | */ |
adustm | 0:c61a93635433 | 47 | #ifndef __WIFI_H_ |
adustm | 0:c61a93635433 | 48 | #define __WIFI_H_ |
adustm | 0:c61a93635433 | 49 | |
adustm | 0:c61a93635433 | 50 | #ifdef __cplusplus |
adustm | 0:c61a93635433 | 51 | extern "C" { |
adustm | 0:c61a93635433 | 52 | #endif |
adustm | 0:c61a93635433 | 53 | |
adustm | 0:c61a93635433 | 54 | /* Includes ------------------------------------------------------------------*/ |
adustm | 0:c61a93635433 | 55 | #include "es_wifi.h" |
adustm | 0:c61a93635433 | 56 | #include "es_wifi_io.h" |
adustm | 0:c61a93635433 | 57 | |
adustm | 0:c61a93635433 | 58 | /* Exported constants --------------------------------------------------------*/ |
adustm | 0:c61a93635433 | 59 | #define WIFI_MAX_SSID_NAME 100 |
adustm | 0:c61a93635433 | 60 | #define WIFI_MAX_PSWD_NAME 100 |
adustm | 0:c61a93635433 | 61 | #define WIFI_MAX_APS 100 |
adustm | 0:c61a93635433 | 62 | #define WIFI_MAX_CONNECTIONS 4 |
adustm | 0:c61a93635433 | 63 | #define WIFI_MAX_MODULE_NAME 100 |
adustm | 0:c61a93635433 | 64 | #define WIFI_MAX_CONNECTED_STATIONS 2 |
adustm | 0:c61a93635433 | 65 | #define WIFI_MSG_JOINED 1 |
adustm | 0:c61a93635433 | 66 | #define WIFI_MSG_ASSIGNED 2 |
adustm | 0:c61a93635433 | 67 | |
adustm | 0:c61a93635433 | 68 | |
adustm | 0:c61a93635433 | 69 | /* Exported types ------------------------------------------------------------*/ |
adustm | 0:c61a93635433 | 70 | typedef enum { |
adustm | 0:c61a93635433 | 71 | WIFI_ECN_OPEN = 0x00, |
adustm | 0:c61a93635433 | 72 | WIFI_ECN_WEP = 0x01, |
adustm | 0:c61a93635433 | 73 | WIFI_ECN_WPA_PSK = 0x02, |
adustm | 0:c61a93635433 | 74 | WIFI_ECN_WPA2_PSK = 0x03, |
adustm | 0:c61a93635433 | 75 | WIFI_ECN_WPA_WPA2_PSK = 0x04, |
adustm | 0:c61a93635433 | 76 | }WIFI_Ecn_t; |
adustm | 0:c61a93635433 | 77 | |
adustm | 0:c61a93635433 | 78 | typedef enum { |
adustm | 0:c61a93635433 | 79 | WIFI_TCP_PROTOCOL = 0, |
adustm | 0:c61a93635433 | 80 | WIFI_UDP_PROTOCOL = 1, |
adustm | 0:c61a93635433 | 81 | }WIFI_Protocol_t; |
adustm | 0:c61a93635433 | 82 | |
adustm | 0:c61a93635433 | 83 | typedef enum { |
adustm | 0:c61a93635433 | 84 | WIFI_SERVER = 0, |
adustm | 0:c61a93635433 | 85 | WIFI_CLIENT = 1, |
adustm | 0:c61a93635433 | 86 | }WIFI_Type_t; |
adustm | 0:c61a93635433 | 87 | |
adustm | 0:c61a93635433 | 88 | typedef enum { |
adustm | 0:c61a93635433 | 89 | WIFI_STATUS_OK = 0, |
adustm | 0:c61a93635433 | 90 | WIFI_STATUS_ERROR = 1, |
adustm | 0:c61a93635433 | 91 | WIFI_STATUS_NOT_SUPPORTED = 2, |
adustm | 0:c61a93635433 | 92 | WIFI_STATUS_JOINED = 3, |
adustm | 0:c61a93635433 | 93 | WIFI_STATUS_ASSIGNED = 4, |
adustm | 0:c61a93635433 | 94 | }WIFI_Status_t; |
adustm | 0:c61a93635433 | 95 | |
adustm | 0:c61a93635433 | 96 | typedef struct { |
adustm | 0:c61a93635433 | 97 | WIFI_Ecn_t Ecn; /*!< Security of Wi-Fi spot. This parameter has a value of \ref WIFI_Ecn_t enumeration */ |
adustm | 0:c61a93635433 | 98 | char SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Service Set Identifier value. Wi-Fi spot name */ |
adustm | 0:c61a93635433 | 99 | int16_t RSSI; /*!< Signal strength of Wi-Fi spot */ |
adustm | 0:c61a93635433 | 100 | uint8_t MAC[6]; /*!< MAC address of spot */ |
adustm | 0:c61a93635433 | 101 | uint8_t Channel; /*!< Wi-Fi channel */ |
adustm | 0:c61a93635433 | 102 | uint8_t Offset; /*!< Frequency offset from base 2.4GHz in kHz */ |
adustm | 0:c61a93635433 | 103 | uint8_t Calibration; /*!< Frequency offset calibration */ |
adustm | 0:c61a93635433 | 104 | }WIFI_AP_t; |
adustm | 0:c61a93635433 | 105 | |
adustm | 0:c61a93635433 | 106 | typedef struct { |
adustm | 0:c61a93635433 | 107 | WIFI_AP_t ap[WIFI_MAX_APS]; |
adustm | 0:c61a93635433 | 108 | uint8_t count; |
adustm | 0:c61a93635433 | 109 | } WIFI_APs_t; |
adustm | 0:c61a93635433 | 110 | |
adustm | 0:c61a93635433 | 111 | |
adustm | 0:c61a93635433 | 112 | typedef struct { |
adustm | 0:c61a93635433 | 113 | uint8_t Number; /*!< Connection number */ |
adustm | 0:c61a93635433 | 114 | uint16_t RemotePort; /*!< Remote PORT number */ |
adustm | 0:c61a93635433 | 115 | uint16_t LocalPort; |
adustm | 0:c61a93635433 | 116 | uint8_t RemoteIP[4]; /*!< IP address of device */ |
adustm | 0:c61a93635433 | 117 | WIFI_Protocol_t Protocol; /*!< Connection type. Parameter is valid only if connection is made as client */ |
adustm | 0:c61a93635433 | 118 | uint32_t TotalBytesReceived; /*!< Number of bytes received in entire connection lifecycle */ |
adustm | 0:c61a93635433 | 119 | uint32_t TotalBytesSent; /*!< Number of bytes sent in entire connection lifecycle */ |
adustm | 0:c61a93635433 | 120 | uint8_t Active; /*!< Status if connection is active */ |
adustm | 0:c61a93635433 | 121 | uint8_t Client; /*!< Set to 1 if connection was made as client */ |
adustm | 0:c61a93635433 | 122 | } WIFI_Socket_t; |
adustm | 0:c61a93635433 | 123 | |
adustm | 0:c61a93635433 | 124 | |
adustm | 0:c61a93635433 | 125 | typedef struct { |
adustm | 0:c61a93635433 | 126 | |
adustm | 0:c61a93635433 | 127 | uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; |
adustm | 0:c61a93635433 | 128 | uint8_t PSWD[WIFI_MAX_PSWD_NAME + 1]; |
adustm | 0:c61a93635433 | 129 | uint8_t channel; |
adustm | 0:c61a93635433 | 130 | WIFI_Ecn_t Ecn; |
adustm | 0:c61a93635433 | 131 | } WIFI_APConfig_t; |
adustm | 0:c61a93635433 | 132 | |
adustm | 0:c61a93635433 | 133 | typedef struct { |
adustm | 0:c61a93635433 | 134 | uint8_t SSID[WIFI_MAX_SSID_NAME + 1]; /*!< Network public name for ESP AP mode */ |
adustm | 0:c61a93635433 | 135 | uint8_t IP_Addr[4]; /*!< IP Address */ |
adustm | 0:c61a93635433 | 136 | uint8_t MAC_Addr[6]; /*!< MAC address */ |
adustm | 0:c61a93635433 | 137 | } WIFI_APSettings_t; |
adustm | 0:c61a93635433 | 138 | |
adustm | 0:c61a93635433 | 139 | typedef struct { |
adustm | 0:c61a93635433 | 140 | uint8_t IsConnected; |
adustm | 0:c61a93635433 | 141 | uint8_t IP_Addr[4]; |
adustm | 0:c61a93635433 | 142 | uint8_t IP_Mask[4]; |
adustm | 0:c61a93635433 | 143 | uint8_t Gateway_Addr[4]; |
adustm | 0:c61a93635433 | 144 | } WIFI_Conn_t; |
adustm | 0:c61a93635433 | 145 | |
adustm | 0:c61a93635433 | 146 | /* Exported macro ------------------------------------------------------------*/ |
adustm | 0:c61a93635433 | 147 | /* Exported functions ------------------------------------------------------- */ |
adustm | 0:c61a93635433 | 148 | WIFI_Status_t WIFI_Init(void); |
adustm | 0:c61a93635433 | 149 | WIFI_Status_t WIFI_ListAccessPoints(WIFI_APs_t *APs, uint8_t AP_MaxNbr); |
adustm | 0:c61a93635433 | 150 | WIFI_Status_t WIFI_Connect( |
adustm | 0:c61a93635433 | 151 | const char* SSID, |
adustm | 0:c61a93635433 | 152 | const char* Password, |
adustm | 0:c61a93635433 | 153 | WIFI_Ecn_t ecn); |
adustm | 0:c61a93635433 | 154 | WIFI_Status_t WIFI_GetIP_Address(uint8_t *ipaddr); |
adustm | 0:c61a93635433 | 155 | WIFI_Status_t WIFI_GetMAC_Address(uint8_t *mac); |
adustm | 0:c61a93635433 | 156 | |
adustm | 0:c61a93635433 | 157 | WIFI_Status_t WIFI_Disconnect(void); |
adustm | 0:c61a93635433 | 158 | WIFI_Status_t WIFI_ConfigureAP( |
adustm | 0:c61a93635433 | 159 | uint8_t *ssid, |
adustm | 0:c61a93635433 | 160 | uint8_t *pass, |
adustm | 0:c61a93635433 | 161 | WIFI_Ecn_t ecn, |
adustm | 0:c61a93635433 | 162 | uint8_t channel, |
adustm | 0:c61a93635433 | 163 | uint8_t max_conn); |
adustm | 0:c61a93635433 | 164 | |
adustm | 0:c61a93635433 | 165 | WIFI_Status_t WIFI_HandleAPEvents(WIFI_APSettings_t *setting); |
adustm | 0:c61a93635433 | 166 | WIFI_Status_t WIFI_Ping(uint8_t* ipaddr, uint16_t count, uint16_t interval_ms); |
adustm | 0:c61a93635433 | 167 | WIFI_Status_t WIFI_GetHostAddress( char* location, uint8_t* ipaddr); |
adustm | 0:c61a93635433 | 168 | 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); |
adustm | 0:c61a93635433 | 169 | WIFI_Status_t WIFI_CloseClientConnection(uint32_t socket); |
adustm | 0:c61a93635433 | 170 | |
adustm | 0:c61a93635433 | 171 | WIFI_Status_t WIFI_StartServer(uint32_t socket, WIFI_Protocol_t type, const char* name, uint16_t port); |
adustm | 0:c61a93635433 | 172 | WIFI_Status_t WIFI_StopServer(uint32_t socket); |
adustm | 0:c61a93635433 | 173 | |
adustm | 0:c61a93635433 | 174 | WIFI_Status_t WIFI_SendData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *SentDatalen, uint32_t Timeout); |
adustm | 0:c61a93635433 | 175 | WIFI_Status_t WIFI_ReceiveData(uint8_t socket, uint8_t *pdata, uint16_t Reqlen, uint16_t *RcvDatalen, uint32_t Timeout); |
adustm | 0:c61a93635433 | 176 | WIFI_Status_t WIFI_StartClient(void); |
adustm | 0:c61a93635433 | 177 | WIFI_Status_t WIFI_StopClient(void); |
adustm | 0:c61a93635433 | 178 | |
adustm | 0:c61a93635433 | 179 | WIFI_Status_t WIFI_SetOEMProperties(const char *name, uint8_t *Mac); |
adustm | 0:c61a93635433 | 180 | WIFI_Status_t WIFI_ResetModule(void); |
adustm | 0:c61a93635433 | 181 | WIFI_Status_t WIFI_SetModuleDefault(void); |
adustm | 0:c61a93635433 | 182 | WIFI_Status_t WIFI_ModuleFirmwareUpdate(const char *url); |
adustm | 0:c61a93635433 | 183 | WIFI_Status_t WIFI_GetModuleID(char *Id); |
adustm | 0:c61a93635433 | 184 | WIFI_Status_t WIFI_GetModuleFwRevision(char *rev); |
adustm | 0:c61a93635433 | 185 | WIFI_Status_t WIFI_GetModuleName(char *ModuleName); |
jaafaryn | 1:b37920c1ddb9 | 186 | WIFI_Status_t WIFI_SetPowerSaveMode(uint8_t beacon_int, uint16_t sleep_ms); |
adustm | 0:c61a93635433 | 187 | #ifdef __cplusplus |
adustm | 0:c61a93635433 | 188 | } |
adustm | 0:c61a93635433 | 189 | #endif |
adustm | 0:c61a93635433 | 190 | |
adustm | 0:c61a93635433 | 191 | #endif /* __WIFI_H_ */ |
adustm | 0:c61a93635433 | 192 | |
adustm | 0:c61a93635433 | 193 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |