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-iks01a1-test x-nucleo-iks01a1-test
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 /** SpwfSAInterface class 00046 * Implementation of the NetworkStack for the SPWF Device 00047 */ 00048 class SpwfSAInterface : public NetworkStack, public WiFiInterface 00049 { 00050 public: 00051 00052 SpwfSAInterface(PinName tx, PinName rx, bool debug = false); 00053 virtual ~SpwfSAInterface(); 00054 00055 // Implementation of WiFiInterface 00056 virtual nsapi_error_t set_credentials(const char *ssid, const char *pass, 00057 nsapi_security_t security = NSAPI_SECURITY_NONE); 00058 virtual nsapi_error_t connect(const char *ssid, 00059 const char *pass, 00060 nsapi_security_t security = NSAPI_SECURITY_NONE, 00061 uint8_t channel = 0); 00062 virtual nsapi_error_t connect() { 00063 if (_ssid == 0 || _pass == 0) return NSAPI_ERROR_PARAMETER; 00064 return connect(_ssid, _pass, _security, _channel); 00065 } 00066 virtual nsapi_error_t set_channel(uint8_t channel) { 00067 _channel = channel; 00068 return NSAPI_ERROR_OK; 00069 } 00070 virtual int8_t get_rssi(); 00071 virtual int disconnect(); 00072 virtual nsapi_size_or_error_t scan(WiFiAccessPoint *res, nsapi_size_t count) { 00073 return NSAPI_ERROR_UNSUPPORTED; // TODO! Add scan support 00074 } 00075 00076 virtual const char *get_mac_address(); 00077 void debug(const char * string); 00078 00079 //Implementation of NetworkStack 00080 virtual const char *get_ip_address(); 00081 00082 protected: 00083 //Implementation of NetworkStack 00084 virtual int socket_open(void **handle, nsapi_protocol_t proto); 00085 virtual int socket_close(void *handle); 00086 virtual int socket_bind(void *handle, const SocketAddress &address); //not supported 00087 virtual int socket_listen(void *handle, int backlog); 00088 virtual int socket_connect(void *handle, const SocketAddress &address); 00089 virtual nsapi_error_t socket_accept(nsapi_socket_t server, 00090 nsapi_socket_t *handle, SocketAddress *address=0); 00091 virtual int socket_send(void *handle, const void *data, unsigned size); 00092 virtual int socket_recv(void *handle, void *data, unsigned size); 00093 virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); 00094 virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); 00095 virtual void socket_attach(void *handle, void (*callback)(void *), void *data); 00096 virtual NetworkStack* get_stack() {return this;} 00097 private: 00098 int init(void); 00099 00100 SPWFSA01 _spwf; 00101 bool _ids[SPWFSA_SOCKET_COUNT]; 00102 bool isListening; 00103 bool isInitialized; 00104 const char *_ssid; 00105 const char *_pass; 00106 nsapi_security_t _security; 00107 uint8_t _channel; 00108 }; 00109 00110 00111 #endif
Generated on Wed Jul 13 2022 01:04:28 by
1.7.2
