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: X_NUCLEO_IDW01M1_AP_Test
Fork of X_NUCLEO_IDW01M1 by
SpwfSADevice.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 /** 00018 ****************************************************************************** 00019 * @file SpwfSADevice.h 00020 * @author STMicroelectronics 00021 * @brief Header File of SpwfSADevice class for Wi-Fi mbed 00022 ****************************************************************************** 00023 * @copy 00024 * 00025 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS 00026 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE 00027 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY 00028 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING 00029 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE 00030 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. 00031 * 00032 * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> 00033 ****************************************************************************** 00034 */ 00035 00036 #ifndef __SPWFSA_DEVICE_H__ 00037 #define __SPWFSA_DEVICE_H__ 00038 00039 00040 #include "mbed.h" 00041 #include "RawSerial.h" 00042 #include "Ticker.h" 00043 #include "Timer.h" 00044 #include "wifi_interface.h" 00045 00046 00047 /** SpwfSADevice class 00048 * Implementation of the SPWF Device 00049 */ 00050 class SpwfSADevice 00051 { 00052 00053 public: 00054 SpwfSADevice(PinName tx, PinName rx, PinName rst, PinName wkup, PinName rts); 00055 ~SpwfSADevice(void); 00056 00057 int init(void); 00058 int connect(char * ssid, char * sec_key, WiFi_Priv_Mode priv_mode); 00059 int start_access_point(char * ssid, char * sec_key, WiFi_Priv_Mode priv_mode, int channel_num, unsigned int data_rates); 00060 int disconnect(void); 00061 const char *getIPAddress(); 00062 const char *getMACAddress(); 00063 void network_scan(wifi_scan *scan_result, uint16_t max_scan_number); 00064 00065 int socket_client_open(uint8_t * hostname, uint32_t port_number, uint8_t * protocol, uint8_t * sock_id); 00066 int socket_client_write(uint8_t sock_id, uint16_t DataLength,char * pData); 00067 int socket_client_recv(uint8_t sock_id, uint16_t RecvLength,char * pData); 00068 int socket_client_close(uint8_t sock_close_id); 00069 void 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); 00070 00071 int socket_server_open(uint32_t port_number, uint8_t * protocol); 00072 int socket_server_write(uint16_t data_length,char * pdata); 00073 int socket_server_close(void); 00074 00075 void http_get(uint8_t * hostname, uint8_t * path, uint32_t port_number); 00076 void http_post(uint8_t * url_path); 00077 00078 char spwf_get(void); 00079 int spwf_send(const char * cmd, uint16_t size); 00080 void spwf_wakeup(int wake); 00081 void spwf_reset(int reset); 00082 void spwf_rts(int rts); 00083 void spwf_attach_irq(wifi_bool attach); 00084 int spwf_read_rts(); 00085 00086 const char *getVersion(void); 00087 void waitForEvent(void); 00088 void signal_data_receive(uint8_t socket_id, uint8_t * data_ptr, uint32_t message_size, uint32_t chunk_size); 00089 void signal_synch_wait(WiFi_Status_t code); 00090 void set_wait_for_incoming_client(bool set); 00091 bool get_wait_for_incoming_client(); 00092 bool getIsInitialized(void); 00093 void setTimeout(int timeout) { 00094 _timeout = timeout; 00095 } 00096 void debug_print(const char * string); 00097 00098 private: 00099 bool isInitialized; 00100 00101 RawSerial uart_; 00102 RawSerial term_; 00103 Ticker wifi_isr; 00104 Ticker wifi_callback; 00105 DigitalInOut wakeup_; 00106 DigitalInOut rst_; 00107 DigitalInOut rts_; 00108 wifi_config config; 00109 bool sync_wait_signal; 00110 bool wait_for_incoming_client; 00111 bool wait_for_socket_data; 00112 uint16_t bytes_read; 00113 uint16_t bytes_to_read; 00114 uint8_t * recv_buff; 00115 int _timeout; 00116 00117 char _ip_buffer[16]; 00118 char _mac_buffer[18]; 00119 }; 00120 00121 #endif
Generated on Tue Jul 12 2022 12:20:21 by
1.7.2
