Klika Tech / Mbed 2 deprecated Nucleo-AWS-IoT-mbed

Dependencies:   X_NUCLEO_IKS01A1 mbed FP MQTTPacket DnsQuery ATParser

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SpwfInterface.h Source File

SpwfInterface.h

Go to the documentation of this file.
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>&copy; 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 /** SpwfSAInterface class
00046  *  Implementation of the NetworkStack for the SPWF Device
00047  */
00048 class SpwfSAInterface : public NetworkStack, public WiFiInterface
00049 {
00050 public:
00051     SpwfSAInterface(PinName tx, PinName rx, bool debug);
00052     SpwfSAInterface(PinName tx, PinName rx, PinName reset = PC_12, PinName wakeup = PC_8, bool debug = false);    
00053     virtual     ~SpwfSAInterface();
00054  
00055     // Implementation of WiFiInterface
00056     virtual     int connect(const char *ssid,
00057                             const char *pass,
00058                             nsapi_security_t security = NSAPI_SECURITY_NONE);
00059 
00060     inline int setSocketClientSecurity(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)
00061     {
00062         return _spwf.setSocketClientSecurity(tls_mode, root_ca_server, client_cert, client_key, client_domain, tls_epoch_time);
00063     }
00064  
00065     virtual     int disconnect();    
00066     virtual     const char *get_mac_address();    
00067     void        debug(const char * string);
00068     inline bool     reset_chip() {return _spwf.hw_reset();};
00069     inline void     set_debug(bool state) {_spwf.set_debug(state); };
00070     
00071     //Implementation of NetworkStack
00072     virtual     const char *get_ip_address();
00073     
00074 protected:
00075     //Implementation of NetworkStack
00076     virtual     int socket_open(void **handle, nsapi_protocol_t proto);    
00077     virtual     int socket_close(void *handle);    
00078     virtual     int socket_bind(void *handle, const SocketAddress &address);  //not supported  
00079     virtual     int socket_listen(void *handle, int backlog);
00080     virtual     int socket_connect(void *handle, const SocketAddress &address);
00081     virtual     int socket_accept(void **handle, void *server);
00082     virtual     int socket_send(void *handle, const void *data, unsigned size);  
00083     virtual     int socket_recv(void *handle, void *data, unsigned size);    
00084     virtual     int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size);    
00085     virtual     int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size);    
00086     virtual     void socket_attach(void *handle, void (*callback)(void *), void *data);
00087     virtual     int setsockopt(void *handle, int level, int optname, const void *optval, unsigned optlen);    
00088     virtual     int getsockopt(void *handle, int level, int optname, void *optval, unsigned *optlen);    
00089            
00090 private:
00091     int         init(void);
00092         
00093     SPWFSA01 _spwf;
00094     bool _ids[SPWFSA_SOCKET_COUNT];
00095     bool isListening;
00096     bool isInitialized;
00097 };
00098 
00099 
00100 #endif