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_module.h
00001 /** 00002 ****************************************************************************** 00003 * @file wifi_module.h 00004 * @author Central LAB 00005 * @version V2.0.0 00006 * @date 10-February-2016 00007 * @brief Header file for Wi-Fi module 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_MODULE_H 00039 #define __WIFI_MODULE_H 00040 00041 #ifdef __cplusplus 00042 extern "C" { 00043 #endif 00044 00045 /* Includes ------------------------------------------------------------------*/ 00046 //#include "stm32_spwf_wifi.h" 00047 #include "wifi_const.h" 00048 #include "wifi_interface.h" 00049 #include "event_buffer.h" 00050 00051 /** @addtogroup MIDDLEWARES 00052 * @{ 00053 */ 00054 00055 00056 /** @addtogroup NUCLEO_WIFI_MODULE 00057 * @brief Wi-Fi_driver modules 00058 * @{ 00059 */ 00060 00061 00062 /** @addtogroup NUCLEO_WIFI_MODULE_Private_Macros 00063 * @{ 00064 */ 00065 00066 //#define USART3_INT_MODE 00067 #define USART3_POLLING_MODE 00068 /** 00069 * @} 00070 */ 00071 00072 00073 /** @addtogroup NUCLEO_WIFI_MODULE_Private_Variables 00074 * @{ 00075 */ 00076 /* Private variables ---------------------------------------------------------*/ 00077 00078 /* Exported macro ------------------------------------------------------------*/ 00079 00080 /* Exported constants --------------------------------------------------------*/ 00081 00082 typedef struct Wifi_Status_Var 00083 { 00084 wifi_bool Single_Digit_Indication; 00085 wifi_bool WiFi_Enabled; 00086 wifi_bool http_req_pending; 00087 wifi_bool WiFi_Configuration_Done; 00088 wifi_bool Timer_Running; 00089 wifi_bool resume_receive_data; 00090 wifi_bool enable_dequeue; 00091 wifi_bool stop_event_dequeue; 00092 wifi_bool Standby_Timer_Running; 00093 wifi_bool trigger_wakeup_callback; 00094 wifi_bool Deep_Sleep_Enabled; 00095 wifi_bool Standby_Enabled; 00096 wifi_bool Low_Power_Enabled; 00097 wifi_bool command_mode; 00098 wifi_bool data_mode; 00099 wifi_bool Scan_Ongoing; 00100 wifi_bool AT_Cmd_Ongoing; 00101 wifi_bool AT_Cmd_Processing; 00102 wifi_bool Uartx_Rx_Processing; 00103 wifi_bool Client_Connected; 00104 wifi_bool Client_Disconnected; 00105 wifi_bool switch_by_default_to_command_mode; 00106 wifi_bool start_sock_read; 00107 wifi_bool enable_receive_data_chunk; 00108 wifi_bool data_pending_sockD; 00109 wifi_bool enable_sock_read; 00110 wifi_bool enable_sock_data; 00111 wifi_bool enable_query; 00112 wifi_bool Set_AT_Cmd_Response_False; 00113 wifi_bool enable_fw_update_read; 00114 wifi_bool Q_Contains_Message; 00115 wifi_bool Q_Contains_Data; 00116 wifi_bool enable_receive_http_response; 00117 wifi_bool enable_receive_file_response; 00118 wifi_bool enable_receive_wifi_scan_response; 00119 wifi_bool prevent_push_OK_event; 00120 wifi_bool client_socket_close_ongoing; 00121 wifi_bool prevent_push_WIFI_event; 00122 wifi_bool sock_read_ongoing; 00123 wifi_bool enable_client_socket_write; 00124 wifi_bool event_deQ_x_wind64; 00125 wifi_bool do_not_reset_push_WIFI_event; 00126 wifi_bool message_pending; 00127 wifi_bool Pending_SockON_Callback; 00128 wifi_bool Pending_SockD_Callback; 00129 wifi_bool SockON_Server_Closed_Callback; 00130 wifi_bool Client_Socket_Close_Cmd; 00131 wifi_bool standby_resume_callback; 00132 wifi_bool HTTP_Data_available; 00133 wifi_bool FILE_Data_available; 00134 wifi_bool AT_Response_Received; 00135 wifi_bool Deep_Sleep_Timer; 00136 wifi_bool Timeout_Timer; 00137 wifi_bool Deep_Sleep_Callback; 00138 } Wifi_Status_Var; 00139 00140 /******* Wi-Fi Configuration Setting Parameters *****************/ 00141 00142 typedef enum WiFi_Mode_TypeDef { 00143 WiFi_IDLE_MODE =0, 00144 WiFi_STA_MODE, 00145 WiFi_IBSS_MODE, 00146 WiFi_MiniAP_MODE 00147 } WiFi_Mode_TypeDef; 00148 00149 00150 /********** Wi-Fi Indications*************/ 00151 00152 #pragma pack(1) 00153 typedef struct WiFi_WIND_State_TypeDef 00154 { 00155 wifi_bool ConsoleActive; 00156 wifi_bool WiFiPowerON; 00157 wifi_bool WiFiReset; 00158 wifi_bool WiFiHWFailure; 00159 wifi_bool HardFault; 00160 wifi_bool StackOverflow; 00161 wifi_bool MallocFailed; 00162 wifi_bool InitFailure; 00163 wifi_bool StartFailed; 00164 wifi_bool PS_Mode_Failure; 00165 wifi_bool HeapTooSmall; 00166 wifi_bool WiFiSignalLOW; 00167 wifi_bool WiFiJoin; 00168 wifi_bool WiFiScanning; 00169 wifi_bool WiFiUp; 00170 wifi_bool WiFiAssociation; 00171 wifi_bool WiFiStarted_MiniAPMode; 00172 wifi_bool WiFiAPClientJoined; 00173 wifi_bool WiFiAPClientLeft; 00174 wifi_bool WiFiException; 00175 wifi_bool WiFiHWStarted; 00176 wifi_bool WiFiScanComplete; 00177 wifi_bool WiFiPowerDown; 00178 wifi_bool WiFiMiniAPMode; 00179 wifi_bool WiFiDeauthentication; 00180 00181 /*Wifi Connection Errors*/ 00182 wifi_bool WiFiJoinFailed; 00183 wifi_bool WiFiScanBlewUp; 00184 wifi_bool WiFiScanFailed; 00185 wifi_bool WiFiDeAuth; 00186 wifi_bool WiFiDisAssociation; 00187 00188 /*Wifi packet lost INDs*/ 00189 wifi_bool WiFiUnHandledInd; 00190 wifi_bool WiFiRXMgmt; 00191 wifi_bool WiFiRXData; 00192 wifi_bool WiFiRxUnk; 00193 wifi_bool WiFiSockdDataLost; 00194 00195 } WiFi_WIND_State_TypeDef; 00196 #pragma pack() 00197 00198 typedef enum { 00199 Console_Active = 0, 00200 Poweron = 1, 00201 WiFi_Reset, 00202 Watchdog_Running, 00203 Heap_Too_Small, 00204 WiFi_Hardware_Dead = 5, 00205 Watchdog_Terminating, 00206 SysTickConfigure, 00207 Hard_Fault =8, 00208 StackOverflow, 00209 MallocFailed, 00210 Error, 00211 WiFi_PS_Mode_Failure = 12, 00212 CopyrightInfo, 00213 WiFi_BSS_Regained = 14, 00214 WiFi_Signal_LOW = 15, 00215 WiFi_Signal_OK = 16, 00216 FW_update = 17, 00217 Encryption_key_Not_Recognized, 00218 WiFi_Join = 19, 00219 JOINFAILED = 20, 00220 WiFi_Scanning = 21, 00221 SCANBLEWUP, 00222 SCANFAILED, 00223 WiFi_Up = 24, 00224 WiFi_Association_Successful = 25, 00225 WiFi_Started_MiniAP_Mode = 26, 00226 Start_Failed = 27, 00227 WiFi__MiniAP_Associated = 28, 00228 WiFi_EXCEPTION = 31, 00229 WiFi_Hardware_Started = 32, 00230 WiFi_BSS_LOST, 00231 WiFi_Unhandled_Event, 00232 Scan_Complete = 35, 00233 WiFi_UNHANDLED_IND, 00234 WiFi_UNHANDLED, 00235 WiFi_Powered_Down, 00236 WiFi_MiniAP_Mode = 39, 00237 WiFi_Deauthentication = 40, 00238 WiFi_Disassociation, 00239 RX_MGMT, 00240 RX_DATA, 00241 RX_UNK, 00242 DOT11_AUTHILLEGAL, 00243 Creating_PSK = 46, 00244 WPA_Terminated = 49, 00245 WPA_Supplicant_Failed, 00246 WPA_Handshake_Complete = 51, 00247 GPIO_line, 00248 Wakeup, 00249 Factory_debug, 00250 SockON_Data_Pending = 55, 00251 Remote_Configuration = 57, 00252 SockON_Server_Socket_Closed = 58, 00253 In_Command_Mode = 59, 00254 In_Data_Mode = 60, 00255 Incoming_socket_client = 61, 00256 Outgoing_socket_client = 62, 00257 SockD_Dropping_Data = 63, 00258 SockD_Pending_Data = 64, 00259 Low_Power_Mode_Enabled = 66, 00260 Going_Into_Standby = 67, 00261 Resuming_From_Standby = 68, 00262 Going_Into_DeepSleep = 69, 00263 Resuming_From_DeepSleep = 70, 00264 WiFi_MiniAP_Disassociated = 72, 00265 Undefine_Indication = 0xFF 00266 } WiFi_Indication_t; 00267 00268 typedef enum WiFi_Indication_t WiFi_Indication; 00269 00270 typedef enum WiFi_Power_State_t 00271 { 00272 Active_State, 00273 PowerSave_State, 00274 Sleep_State=3, 00275 StandBy_State=4 00276 } WiFi_Power_State_t; 00277 00278 typedef enum WiFi_AT_CMD_Response_t { 00279 Process_Event =0, 00280 } WiFi_AT_CMD_Response_t; 00281 00282 #ifdef WIFI_USE_VCOM 00283 void console_input(void); 00284 #endif 00285 00286 void PowerUp_WiFi_Module(void); 00287 void WiFi_Module_Init(void); 00288 void WiFi_Application(void); 00289 /******* Wi-Fi AT CMD SET ****************/ 00290 WiFi_Status_t Attention_Cmd(void); 00291 WiFi_Status_t USART_Transmit_AT_Cmd(uint16_t size); 00292 WiFi_Status_t USART_Receive_AT_Resp(WiFi_AT_CMD_Response_t); 00293 WiFi_Status_t Save_Current_Setting(void); 00294 WiFi_Status_t Restore_Default_Setting(void); 00295 WiFi_Status_t SET_SSID(char* ssid); 00296 WiFi_Status_t GET_SSID(void); 00297 WiFi_Status_t SET_Configuration_Value(char* sVar_name,uint32_t aValue); 00298 WiFi_Status_t GET_Configuration_Value(char* sVar_name,uint32_t *aValue); 00299 WiFi_Status_t SET_Configuration_Addr(char* sVar_name,char* addr); 00300 WiFi_Status_t Display_Help_Text(void); 00301 WiFi_Status_t SET_Power_State(WiFi_Power_State_t state); 00302 void Process_Wind_Indication(uint8_t *process_buff_ptr); 00303 void Process_WiFi_Indication_Cmd(event_s_TypeDef * event_pop_s1); 00304 //void USART2_SendBuffer(USART_TypeDef* USARTx, uint8_t *pData, uint8_t length); 00305 WiFi_Status_t Read_WiFi_SSID(char *string); 00306 void Reset_AT_CMD_Buffer(void); 00307 WiFi_Status_t Open_Serial_Port(void); 00308 WiFi_Status_t WaitForResponse(uint16_t alength); 00309 WiFi_Status_t config_init_value(char* sVar_name,uint8_t aValue); 00310 WiFi_Status_t config_init_addr(char* sVar_name,char* addr); 00311 00312 char* Delete_Colon(char* ); 00313 WiFi_Status_t Read_WiFi_Mode(char *string); 00314 WiFi_Status_t Read_WiFi_SecKey(char *string); 00315 00316 WiFi_Status_t Write_WiFi_SSID(char *string); 00317 WiFi_Status_t Write_WiFi_SecKey(char *string); 00318 void PrintErrorMsg (void); 00319 void Print_Msg(char * msgBuff,uint8_t length); 00320 char *search_buffer(char *pSourceBuff, uint16_t sourceBuffLen, char *pSearchStringBuff, uint16_t seartchStringLen); 00321 void Error_Handler(void); 00322 WiFi_Status_t SET_WiFi_SecKey(char* seckey); 00323 void WiFi_Receive_Indication_Msg(void); 00324 00325 void ResetBuffer(void); 00326 void Start_Timer(void); 00327 void Stop_Timer(void); 00328 void Request_Time_Out(void); 00329 void Start_DeepSleep_Timer(void); 00330 void Stop_DeepSleep_Timer(void); 00331 00332 void HTTP_Read_Data(void); 00333 WiFi_Status_t Socket_Read(uint16_t DataLength); 00334 void Read_Socket_Data(void); 00335 void Socket_Pending_Data(void); 00336 void WiFi_switch_to_command_mode(void); 00337 void WiFi_switch_to_data_mode(void); 00338 void WiFi_Configuration(void); 00339 00340 void Receive_Data(void); 00341 void Process_Buffer(uint8_t * ptr); 00342 void Process_WiFi(void); 00343 #if 0 00344 void configure_to_exti(void); 00345 #endif 00346 void Stop_Dequeue(void); 00347 void Resume_Dequeue(void); 00348 void wait_for_command_mode(void); 00349 void Wifi_SysTick_Isr(void); 00350 void RX_EXTI_Isr(uint16_t GPIO_Pin); 00351 //void Wifi_TIM_Handler(TIM_HandleTypeDef *htim); 00352 void Queue_Http_Event(uint8_t * hostname, uint8_t * path, uint32_t port_number,uint8_t * pURL_path); 00353 void Queue_Client_Write_Event(uint8_t sock_id, uint16_t DataLength, char * pData); 00354 void Queue_Wifi_FW_Update_Event(uint8_t * hostname, uint8_t * filename_path, uint32_t port_number); 00355 void Queue_Wifi_File_Event(uint8_t * pHostName, uint8_t * pFileName, uint32_t port_number); 00356 void Queue_Client_Open_Event(uint8_t * hostname, uint32_t port_number, uint8_t * protocol); 00357 void Queue_Client_Close_Event(uint8_t sock_id); 00358 void Wait_For_Sock_Read_To_Complete(void); 00359 void initialize_status_flags(void); 00360 00361 /** 00362 * @} 00363 */ 00364 00365 /** 00366 * @} 00367 */ 00368 00369 /** 00370 * @} 00371 */ 00372 00373 /** 00374 * @} 00375 */ 00376 00377 #ifdef __cplusplus 00378 } 00379 #endif 00380 #endif /* __WIFI_MODULE_H */
Generated on Tue Jul 12 2022 16:20:36 by
1.7.2

X-NUCLEO-IDW01M1 Wi-Fi expansion board