Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SpwfInterface_NSAPI_Tests HelloWorld_IDW01M1
Fork of X_NUCLEO_IDW01M1 by
wifi_interface.h
00001 /** 00002 ****************************************************************************** 00003 * @file wifi_interface.h 00004 * @author Central LAB 00005 * @version V2.0.0 00006 * @date 10-February-2016 00007 * @brief Header file for X-CUBE-WIFI1 API 00008 ****************************************************************************** 00009 * @attention 00010 * 00011 * <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2> 00012 * 00013 * Redistribution and use in source and binary forms, with or without modification, 00014 * are permitted provided that the following conditions are met: 00015 * 1. Redistributions of source code must retain the above copyright notice, 00016 * this list of conditions and the following disclaimer. 00017 * 2. Redistributions in binary form must reproduce the above copyright notice, 00018 * this list of conditions and the following disclaimer in the documentation 00019 * and/or other materials provided with the distribution. 00020 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00021 * may be used to endorse or promote products derived from this software 00022 * without specific prior written permission. 00023 * 00024 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00025 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00026 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00027 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00028 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00029 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00030 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00031 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00032 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00033 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00034 * 00035 ****************************************************************************** 00036 */ 00037 /* Define to prevent recursive inclusion -------------------------------------*/ 00038 #ifndef __WIFI_INTERFACE_H 00039 #define __WIFI_INTERFACE_H 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 /* Includes ------------------------------------------------------------------*/ 00046 #include<stdint.h> 00047 00048 /** @addtogroup MIDDLEWARES 00049 * @{ 00050 */ 00051 00052 00053 /** @addtogroup NUCLEO_WIFI_API 00054 * @brief Wi-Fi_interface API 00055 * @{ 00056 */ 00057 00058 00059 /** @addtogroup NUCLEO_WIFI_API_Private_Macros 00060 * @{ 00061 */ 00062 00063 00064 /** 00065 * @} 00066 */ 00067 00068 00069 /** @addtogroup NUCLEO_WIFI_API_Private_Variables 00070 * @{ 00071 */ 00072 /* Private variables ---------------------------------------------------------*/ 00073 00074 00075 /* Exported macro ------------------------------------------------------------*/ 00076 #define _ARG6(_0, _1, _2, _3, _4, _5, _6, ...) _6 00077 #define NARG6(...) _ARG6(__VA_ARGS__, 6, 5, 4, 3, 2, 1, 0) 00078 #define _FIVE_OR_SIX_ARGS_5(NAME, a, b, c, d, e) a, b, c, d, e, 1453727657 00079 #define _FIVE_OR_SIX_ARGS_6(NAME, a, b, c, d, e, f) a, b, c, d, e, f 00080 #define __FIVE_OR_SIX_ARGS(NAME, N, ...) _FIVE_OR_SIX_ARGS_ ## N (NAME, __VA_ARGS__) 00081 #define _FIVE_OR_SIX_ARGS(NAME, N, ...) __FIVE_OR_SIX_ARGS(NAME, N, __VA_ARGS__) 00082 #define FIVE_OR_SIX_ARGS(NAME, ...) NAME(_FIVE_OR_SIX_ARGS(NAME, NARG6(__VA_ARGS__), __VA_ARGS__)) 00083 00084 #define wifi_socket_client_security(...) FIVE_OR_SIX_ARGS(wifi_socket_client_security, __VA_ARGS__) 00085 00086 /* Exported constants --------------------------------------------------------*/ 00087 #define GPIO_IN "in" 00088 #define GPIO_OUT "out" 00089 00090 #define GPIO_Off '0' 00091 #define GPIO_Rising 'R' 00092 #define GPIO_Falling 'F' 00093 #define GPIO_Both 'B' 00094 00095 typedef enum GpioWriteValue 00096 { 00097 GPIO_OFF = 0, 00098 GPIO_ON, 00099 } GpioWriteValue; 00100 00101 typedef enum GpioPin 00102 { 00103 GPIO_PIN0 = 0, 00104 GPIO_PIN1, 00105 GPIO_PIN2, 00106 GPIO_PIN3, 00107 GPIO_PIN4, 00108 GPIO_PIN5, 00109 GPIO_PIN6, 00110 GPIO_PIN7, 00111 GPIO_PIN8, 00112 GPIO_PIN9, 00113 GPIO_PIN10, 00114 GPIO_PIN11, 00115 GPIO_PIN12, 00116 GPIO_PIN13, 00117 GPIO_PIN14, 00118 GPIO_PIN15 00119 } GpioPin; 00120 00121 typedef enum wifi_bool 00122 { 00123 WIFI_FALSE = 0, 00124 WIFI_TRUE = 1, 00125 Undefine = 0xFF 00126 } wifi_bool; 00127 00128 typedef enum WiFi_Priv_Mode 00129 { 00130 None = 0, 00131 WEP = 1, 00132 WPA_Personal = 2, 00133 } WiFi_Priv_Mode; 00134 00135 /********** Wi-Fi Error *************/ 00136 typedef enum WiFi_Status_t 00137 { 00138 WiFi_MODULE_SUCCESS = 0, 00139 WiFi_TIME_OUT_ERROR = 1, 00140 WiFi_MODULE_ERROR, 00141 WiFi_HAL_OK, 00142 WiFi_NOT_SUPPORTED, 00143 WiFi_NOT_READY, 00144 WiFi_SCAN_FAILED, 00145 WiFi_AT_CMD_BUSY, 00146 WiFi_SSID_ERROR, 00147 WiFi_SecKey_ERROR, 00148 WiFi_CONFIG_ERROR, 00149 WiFi_STA_MODE_ERROR, 00150 WiFi_AP_MODE_ERROR, 00151 WiFi_AT_CMD_RESP_ERROR, 00152 WiFi_AT_FILE_LENGTH_ERROR, 00153 WiFi_HAL_UART_ERROR, 00154 WiFi_IN_LOW_POWER_ERROR, 00155 WiFi_HW_FAILURE_ERROR, 00156 WiFi_HEAP_TOO_SMALL_WARNING, 00157 WiFi_STACK_OVERFLOW_ERROR, 00158 WiFi_HARD_FAULT_ERROR, 00159 WiFi_MALLOC_FAILED_ERROR, 00160 WiFi_INIT_ERROR, 00161 WiFi_POWER_SAVE_WARNING, 00162 WiFi_SIGNAL_LOW_WARNING, 00163 WiFi_JOIN_FAILED, 00164 WiFi_SCAN_BLEWUP, 00165 WiFi_START_FAILED_ERROR, 00166 WiFi_EXCEPTION_ERROR, 00167 WiFi_DE_AUTH, 00168 WiFi_DISASSOCIATION, 00169 WiFi_UNHANDLED_IND_ERROR, 00170 WiFi_RX_MGMT, 00171 WiFi_RX_DATA, 00172 WiFi_RX_UNK 00173 } WiFi_Status_t; 00174 00175 typedef enum power_mode 00176 { 00177 wifi_active = 0, 00178 wifi_reactive = 1, 00179 wifi_sleep = 2, 00180 } power_mode; 00181 00182 typedef enum tx_power_level 00183 { 00184 low = 0, 00185 medium = 1, 00186 high = 2, 00187 max = 3, 00188 } tx_power_level; 00189 00190 typedef enum dhcp_mode 00191 { 00192 off = 0, 00193 on = 1, 00194 custom = 2, 00195 } dhcp_mode; 00196 00197 typedef struct wifi_security 00198 { 00199 wifi_bool wpa; 00200 wifi_bool wpa2; 00201 wifi_bool wps; 00202 } wifi_security; 00203 00204 typedef struct wifi_scan 00205 { 00206 uint8_t channel_num; 00207 int rssi; 00208 char ssid[30]; 00209 wifi_security sec_type; 00210 } wifi_scan; 00211 00212 typedef struct wifi_config 00213 { 00214 wifi_bool ht_mode; 00215 power_mode power; 00216 tx_power_level power_level; 00217 dhcp_mode dhcp; 00218 char* ip_addr; 00219 char* netmask_addr; 00220 char* gateway_addr; 00221 char* dns_addr; 00222 char* host_name; 00223 wifi_bool web_server; 00224 char* ap_domain_name; 00225 char* ap_config_page_name; 00226 uint32_t http_timeout; 00227 uint32_t dhcp_timeout; 00228 uint8_t wifi_region; 00229 uint32_t wifi_baud_rate; 00230 } wifi_config; 00231 00232 /* Exported functions ------------------------------------------------------- */ 00233 00234 #ifdef WIFI_USE_VCOM 00235 void wifi_vcom(void); 00236 #endif 00237 00238 WiFi_Status_t wifi_init(wifi_config* config); 00239 WiFi_Status_t wifi_restore(void); 00240 WiFi_Status_t wifi_enable(wifi_bool enable); 00241 WiFi_Status_t wifi_disconnect(void); 00242 WiFi_Status_t wifi_connect(char * ssid, char * sec_key, WiFi_Priv_Mode priv_mode); 00243 WiFi_Status_t wifi_ap_start(uint8_t * ssid, uint8_t channel_num); 00244 WiFi_Status_t wifi_adhoc_create(uint8_t * ssid, WiFi_Priv_Mode priv_mode); 00245 WiFi_Status_t wifi_network_scan(wifi_scan *scan_result, uint16_t max_scan_number); 00246 void wifi_reset(void); 00247 00248 /******** Wi-Fi Socket Function **********/ 00249 WiFi_Status_t wifi_socket_client_open(uint8_t * hostname, uint32_t port_number, uint8_t * protocol, uint8_t * sock_id); 00250 int wifi_socket_client_write(uint8_t sock_id, uint16_t DataLength,char * pData); 00251 WiFi_Status_t wifi_socket_client_close(uint8_t sock_close_id); 00252 WiFi_Status_t wifi_socket_client_security(uint8_t* tls_mode, uint8_t* root_ca_server, uint8_t* client_cert, uint8_t* client_key, uint8_t* client_domain, uint32_t tls_epoch_time); 00253 00254 /********* Wi-Fi Socket Server ********/ 00255 WiFi_Status_t wifi_socket_server_open(uint32_t port_number, uint8_t * protocol); 00256 int wifi_socket_server_write(uint16_t DataLength,char * pData); 00257 WiFi_Status_t wifi_socket_server_close(void); 00258 00259 /*** FileSystem Request ***********/ 00260 WiFi_Status_t wifi_file_create(char *pFileName,uint16_t alength,char * databuff); 00261 WiFi_Status_t wifi_file_delete(char * pFileName); 00262 WiFi_Status_t wifi_file_list(void); 00263 WiFi_Status_t wifi_file_show(uint8_t * pFileName); 00264 WiFi_Status_t wifi_file_image_create(uint8_t * pHostName,uint8_t * pFileName, uint32_t port_number); 00265 WiFi_Status_t wifi_file_erase_external_flash(void); 00266 00267 /*** HTTP File Request ***********/ 00268 WiFi_Status_t wifi_http_get(uint8_t * hostname, uint8_t * path, uint32_t port_number); 00269 WiFi_Status_t wifi_http_post(uint8_t * url_path); 00270 00271 WiFi_Status_t wifi_fw_update(uint8_t * hostname, uint8_t * filename_path, uint32_t port_number); 00272 00273 /*** Power Configuration **********/ 00274 WiFi_Status_t wifi_standby(uint8_t arg_standby_time); 00275 WiFi_Status_t wifi_wakeup(wifi_bool enable); 00276 00277 /*** GPIO Configuration **********/ 00278 uint8_t wifi_gpio_init(GpioPin pin, char* dir, char irq); 00279 uint8_t wifi_gpio_read(GpioPin pin, uint8_t *val, uint8_t *dir); 00280 uint8_t wifi_gpio_write(GpioPin pin, GpioWriteValue value); 00281 00282 WiFi_Status_t WiFi_Get_IP_Address(uint8_t *ip_addr); 00283 WiFi_Status_t WiFi_Get_MAC_Address(uint8_t *mac_addr); 00284 00285 void UART_Configuration(uint32_t baud_rate); 00286 void GPIO_Configuration(void); 00287 void Timer_Config(void); 00288 void UART_Msg_Gpio_Init(void); 00289 void USART_PRINT_MSG_Configuration(uint32_t baud_rate); 00290 00291 /******** Wi-Fi Indication User Callback: For User to implement *********/ 00292 void ind_wifi_warning(WiFi_Status_t warning_code); 00293 void ind_wifi_error(WiFi_Status_t error_code); 00294 void ind_wifi_connection_error(WiFi_Status_t status_code); 00295 void ind_wifi_connected(void); 00296 void ind_wifi_ap_ready(void); 00297 void ind_wifi_ap_client_joined(uint8_t * client_mac_address); 00298 void ind_wifi_ap_client_left(uint8_t * client_mac_address); 00299 void ind_wifi_on(void); 00300 void ind_wifi_packet_lost(WiFi_Status_t status_code); 00301 void ind_wifi_gpio_changed(void); 00302 void ind_wifi_socket_data_received(uint8_t socket_id, uint8_t * data_ptr, uint32_t message_size, uint32_t chunk_size); 00303 void ind_wifi_socket_client_remote_server_closed(uint8_t * socketID); 00304 void ind_wifi_socket_server_data_lost(void); 00305 void ind_socket_server_client_joined(void); 00306 void ind_socket_server_client_left(void); 00307 void ind_wifi_http_data_available(uint8_t * data_ptr,uint32_t message_size); 00308 void ind_wifi_file_data_available(uint8_t * data_ptr); 00309 void ind_wifi_resuming(void); 00310 00311 00312 /** 00313 * @} 00314 */ 00315 00316 /** 00317 * @} 00318 */ 00319 00320 /** 00321 * @} 00322 */ 00323 00324 /** 00325 * @} 00326 */ 00327 00328 #ifdef __cplusplus 00329 } 00330 #endif 00331 00332 #endif /* __WIFI_INTERFACE_H */
Generated on Tue Jul 12 2022 16:20:36 by
1.7.2

X-NUCLEO-IDW01M1 Wi-Fi expansion board