X-NUCLEO-IDW01M1 Wi-Fi expansion board mbed OS 2 ("Classic") library. mbed OS 5 library also available (see below).
Dependencies: SPWF01SA
Dependents: SpwfInterface_NSAPI_Testsv2 Nucleo_read_a0_thingspace Nucleo_read_a0_thingspace_mems Cayenne-X-NUCLEO-IDW01M1 ... more
Fork of X_NUCLEO_IDW01M1v2 by
SpwfInterface.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 20015 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 SpwfInterface.h 00020 * @author STMicroelectronics 00021 * @brief Header file of the NetworkStack for the SPWF Device 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_INTERFACE_H 00037 #define SPWFSA_INTERFACE_H 00038 00039 #include "WiFiInterface.h" 00040 #include "SPWFSA01.h" 00041 00042 #define SPWFSA_SOCKET_COUNT 8 00043 #define SERVER_SOCKET_NO 9 00044 00045 00046 /** SpwfSAInterface class 00047 * Implementation of the NetworkStack for the SPWF Device 00048 */ 00049 class SpwfSAInterface : public NetworkStack, public WiFiInterface 00050 { 00051 public: 00052 SpwfSAInterface(PinName tx, PinName rx, bool debug); 00053 SpwfSAInterface(PinName tx, PinName rx, PinName reset = PC_12, PinName wakeup = PC_8, bool debug = false); 00054 virtual ~SpwfSAInterface(); 00055 00056 // Implementation of WiFiInterface 00057 virtual int connect(const char *ssid, 00058 const char *pass, 00059 nsapi_security_t security = NSAPI_SECURITY_NONE); 00060 virtual int disconnect(); 00061 virtual const char *get_mac_address(); 00062 00063 // implementation of secure sockets 00064 virtual void set_secure_mode(void); // to be called before socket creation if TLS/SSL is required 00065 virtual void set_unsecure_mode(void); // to be called after socket creation to set unsecure mode (deft) 00066 virtual bool isSecure_mode(void); 00067 virtual int set_time(time_t ctTime); // TLS/SSL requires correct system time to check certificates 00068 virtual int get_time(time_t *ctTime); 00069 virtual int set_TLS_certificate(char * cert, unsigned int size, CertType_t type); // root cert in PEM format 00070 virtual int set_TLS_SRV_domain(char * domain, CertType_t type); // secure server domain 00071 virtual int clean_TLS_certificate(CertType_t type); 00072 void debug(const char * string); 00073 00074 //Implementation of NetworkStack 00075 virtual const char *get_ip_address(); 00076 00077 protected: 00078 //Implementation of NetworkStack 00079 virtual int socket_open(void **handle, nsapi_protocol_t proto); 00080 virtual int socket_close(void *handle); 00081 virtual int socket_bind(void *handle, const SocketAddress &address); //not supported 00082 virtual int socket_listen(void *handle, int backlog); 00083 virtual int socket_connect(void *handle, const SocketAddress &address); 00084 virtual int socket_accept(void **handle, void *server); 00085 virtual int socket_send(void *handle, const void *data, unsigned size); 00086 virtual int socket_recv(void *handle, void *data, unsigned size); 00087 virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); 00088 virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); 00089 virtual void socket_attach(void *handle, void (*callback)(void *), void *data); 00090 virtual int setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen); 00091 virtual int getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen); 00092 00093 private: 00094 int init(void); 00095 00096 SPWFSA01 _spwf; 00097 bool _ids[SPWFSA_SOCKET_COUNT]; 00098 bool isListening; 00099 bool isInitialized; 00100 bool isSecure; 00101 }; 00102 00103 00104 #endif
Generated on Tue Jul 12 2022 13:15:48 by
