iowfehu;gdbjwHJAOPIHO?L
Fork of X_NUCLEO_IDW01M1 by
SPWFInterface.h@18:224f8d3bf6d8, 2016-08-11 (annotated)
- Committer:
- awmiller
- Date:
- Thu Aug 11 23:26:26 2016 +0000
- Revision:
- 18:224f8d3bf6d8
- Parent:
- 17:2c47c2aab4a4
added support for UART
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mridup | 17:2c47c2aab4a4 | 1 | /* mbed Microcontroller Library |
mridup | 17:2c47c2aab4a4 | 2 | * Copyright (c) 20015 ARM Limited |
mridup | 17:2c47c2aab4a4 | 3 | * |
mridup | 17:2c47c2aab4a4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mridup | 17:2c47c2aab4a4 | 5 | * you may not use this file except in compliance with the License. |
mridup | 17:2c47c2aab4a4 | 6 | * You may obtain a copy of the License at |
mridup | 17:2c47c2aab4a4 | 7 | * |
mridup | 17:2c47c2aab4a4 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mridup | 17:2c47c2aab4a4 | 9 | * |
mridup | 17:2c47c2aab4a4 | 10 | * Unless required by applicable law or agreed to in writing, software |
mridup | 17:2c47c2aab4a4 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mridup | 17:2c47c2aab4a4 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mridup | 17:2c47c2aab4a4 | 13 | * See the License for the specific language governing permissions and |
mridup | 17:2c47c2aab4a4 | 14 | * limitations under the License. |
mridup | 17:2c47c2aab4a4 | 15 | */ |
mridup | 13:cdcc13d78252 | 16 | |
mridup | 13:cdcc13d78252 | 17 | /** |
mridup | 13:cdcc13d78252 | 18 | ****************************************************************************** |
mridup | 13:cdcc13d78252 | 19 | * @file SpwfInterface.h |
mridup | 13:cdcc13d78252 | 20 | * @author STMicroelectronics |
mridup | 13:cdcc13d78252 | 21 | * @brief Header file of the NetworkStack for the SPWF Device |
mridup | 13:cdcc13d78252 | 22 | ****************************************************************************** |
mridup | 13:cdcc13d78252 | 23 | * @copy |
mridup | 13:cdcc13d78252 | 24 | * |
mridup | 13:cdcc13d78252 | 25 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
mridup | 13:cdcc13d78252 | 26 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
mridup | 13:cdcc13d78252 | 27 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
mridup | 13:cdcc13d78252 | 28 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
mridup | 13:cdcc13d78252 | 29 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
mridup | 13:cdcc13d78252 | 30 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
mridup | 13:cdcc13d78252 | 31 | * |
mridup | 13:cdcc13d78252 | 32 | * <h2><center>© COPYRIGHT 2016 STMicroelectronics</center></h2> |
mridup | 13:cdcc13d78252 | 33 | ****************************************************************************** |
mridup | 13:cdcc13d78252 | 34 | */ |
mridup | 13:cdcc13d78252 | 35 | |
mridup | 0:dc55f40eb04f | 36 | #ifndef SPWFSA_INTERFACE_H |
mridup | 0:dc55f40eb04f | 37 | #define SPWFSA_INTERFACE_H |
mridup | 0:dc55f40eb04f | 38 | |
mridup | 0:dc55f40eb04f | 39 | #include <vector> |
mridup | 0:dc55f40eb04f | 40 | #include <map> |
mridup | 0:dc55f40eb04f | 41 | #include "WiFiInterface.h" |
mridup | 0:dc55f40eb04f | 42 | #include "SpwfSADevice.h" |
mridup | 0:dc55f40eb04f | 43 | |
mridup | 0:dc55f40eb04f | 44 | #define SPWFSA_SOCKET_COUNT 8 |
mridup | 6:e7a3fca2df10 | 45 | #define SERVER_SOCKET_NO 9 |
mridup | 0:dc55f40eb04f | 46 | |
mridup | 0:dc55f40eb04f | 47 | /** SpwfSAInterface class |
mridup | 5:c83ffd44f40a | 48 | * Implementation of the NetworkStack for the SPWF Device |
mridup | 0:dc55f40eb04f | 49 | */ |
mridup | 5:c83ffd44f40a | 50 | class SpwfSAInterface : public NetworkStack, public WiFiInterface |
mridup | 0:dc55f40eb04f | 51 | { |
mridup | 0:dc55f40eb04f | 52 | public: |
mridup | 0:dc55f40eb04f | 53 | |
mridup | 0:dc55f40eb04f | 54 | SpwfSAInterface(PinName tx, PinName rx, PinName rst, PinName wkup, PinName rts, bool debug = false); |
mridup | 0:dc55f40eb04f | 55 | virtual ~SpwfSAInterface(); |
mridup | 0:dc55f40eb04f | 56 | |
mridup | 0:dc55f40eb04f | 57 | // Implementation of WiFiInterface |
mridup | 5:c83ffd44f40a | 58 | virtual int connect( |
mridup | 0:dc55f40eb04f | 59 | const char *ssid, |
mridup | 0:dc55f40eb04f | 60 | const char *pass, |
mridup | 5:c83ffd44f40a | 61 | nsapi_security_t security = NSAPI_SECURITY_NONE); |
mridup | 0:dc55f40eb04f | 62 | |
mridup | 5:c83ffd44f40a | 63 | virtual int disconnect(); |
mridup | 5:c83ffd44f40a | 64 | virtual const char *get_mac_address(); |
mridup | 0:dc55f40eb04f | 65 | void debug(const char * string); |
mridup | 5:c83ffd44f40a | 66 | |
mridup | 5:c83ffd44f40a | 67 | //Implementation of NetworkStack |
mridup | 5:c83ffd44f40a | 68 | virtual const char *get_ip_address(); |
mridup | 5:c83ffd44f40a | 69 | |
mridup | 5:c83ffd44f40a | 70 | protected: |
mridup | 5:c83ffd44f40a | 71 | //Implementation of NetworkStack |
mridup | 5:c83ffd44f40a | 72 | virtual int socket_open(void **handle, nsapi_protocol_t proto); |
mridup | 5:c83ffd44f40a | 73 | virtual int socket_close(void *handle); |
mridup | 5:c83ffd44f40a | 74 | virtual int socket_bind(void *handle, const SocketAddress &address); //not supported |
mridup | 6:e7a3fca2df10 | 75 | virtual int socket_listen(void *handle, int backlog); |
mridup | 6:e7a3fca2df10 | 76 | virtual int socket_connect(void *handle, const SocketAddress &address); |
mridup | 6:e7a3fca2df10 | 77 | virtual int socket_accept(void **handle, void *server); |
mridup | 5:c83ffd44f40a | 78 | virtual int socket_send(void *handle, const void *data, unsigned size); |
mridup | 5:c83ffd44f40a | 79 | virtual int socket_recv(void *handle, void *data, unsigned size); |
mridup | 5:c83ffd44f40a | 80 | virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); |
mridup | 5:c83ffd44f40a | 81 | virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); |
mridup | 5:c83ffd44f40a | 82 | virtual void socket_attach(void *handle, void (*callback)(void *), void *data); |
mridup | 5:c83ffd44f40a | 83 | |
mridup | 5:c83ffd44f40a | 84 | private: |
mridup | 7:0fdd186a7d90 | 85 | int init(void); |
mridup | 0:dc55f40eb04f | 86 | |
mridup | 0:dc55f40eb04f | 87 | SpwfSADevice _spwf; |
mridup | 0:dc55f40eb04f | 88 | bool _ids[SPWFSA_SOCKET_COUNT]; |
mridup | 6:e7a3fca2df10 | 89 | bool isListening; |
mridup | 3:fd9d20c4d3f0 | 90 | bool isInitialized; |
mridup | 5:c83ffd44f40a | 91 | multimap <char *, vector <uint16_t> > c_table; |
mridup | 0:dc55f40eb04f | 92 | |
mridup | 0:dc55f40eb04f | 93 | }; |
mridup | 0:dc55f40eb04f | 94 | |
mridup | 0:dc55f40eb04f | 95 | |
mridup | 0:dc55f40eb04f | 96 | #endif |