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.
Fork of X_NUCLEO_IDW01M1 by
SPWFInterface.h@5:c83ffd44f40a, 2016-05-04 (annotated)
- Committer:
- mridup
- Date:
- Wed May 04 12:16:20 2016 +0000
- Revision:
- 5:c83ffd44f40a
- Parent:
- 3:fd9d20c4d3f0
- Child:
- 6:e7a3fca2df10
changes adapting to NetworkStack v119
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mridup | 0:dc55f40eb04f | 1 | /* SpwfSAInterface implementation of NetworkInterfaceAPI |
mridup | 0:dc55f40eb04f | 2 | * Copyright (c) 2015 ARM Limited |
mridup | 0:dc55f40eb04f | 3 | * |
mridup | 0:dc55f40eb04f | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
mridup | 0:dc55f40eb04f | 5 | * you may not use this file except in compliance with the License. |
mridup | 0:dc55f40eb04f | 6 | * You may obtain a copy of the License at |
mridup | 0:dc55f40eb04f | 7 | * |
mridup | 0:dc55f40eb04f | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
mridup | 0:dc55f40eb04f | 9 | * |
mridup | 0:dc55f40eb04f | 10 | * Unless required by applicable law or agreed to in writing, software |
mridup | 0:dc55f40eb04f | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
mridup | 0:dc55f40eb04f | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
mridup | 0:dc55f40eb04f | 13 | * See the License for the specific language governing permissions and |
mridup | 0:dc55f40eb04f | 14 | * limitations under the License. |
mridup | 0:dc55f40eb04f | 15 | */ |
mridup | 0:dc55f40eb04f | 16 | |
mridup | 0:dc55f40eb04f | 17 | #ifndef SPWFSA_INTERFACE_H |
mridup | 0:dc55f40eb04f | 18 | #define SPWFSA_INTERFACE_H |
mridup | 0:dc55f40eb04f | 19 | |
mridup | 0:dc55f40eb04f | 20 | #include <vector> |
mridup | 0:dc55f40eb04f | 21 | #include <map> |
mridup | 0:dc55f40eb04f | 22 | #include "WiFiInterface.h" |
mridup | 0:dc55f40eb04f | 23 | #include "SpwfSADevice.h" |
mridup | 0:dc55f40eb04f | 24 | |
mridup | 0:dc55f40eb04f | 25 | #define SPWFSA_SOCKET_COUNT 8 |
mridup | 0:dc55f40eb04f | 26 | |
mridup | 0:dc55f40eb04f | 27 | /** SpwfSAInterface class |
mridup | 5:c83ffd44f40a | 28 | * Implementation of the NetworkStack for the SPWF Device |
mridup | 0:dc55f40eb04f | 29 | */ |
mridup | 5:c83ffd44f40a | 30 | class SpwfSAInterface : public NetworkStack, public WiFiInterface |
mridup | 0:dc55f40eb04f | 31 | { |
mridup | 0:dc55f40eb04f | 32 | public: |
mridup | 0:dc55f40eb04f | 33 | |
mridup | 0:dc55f40eb04f | 34 | SpwfSAInterface(PinName tx, PinName rx, PinName rst, PinName wkup, PinName rts, bool debug = false); |
mridup | 0:dc55f40eb04f | 35 | virtual ~SpwfSAInterface(); |
mridup | 0:dc55f40eb04f | 36 | |
mridup | 0:dc55f40eb04f | 37 | // Implementation of WiFiInterface |
mridup | 5:c83ffd44f40a | 38 | virtual int connect( |
mridup | 0:dc55f40eb04f | 39 | const char *ssid, |
mridup | 0:dc55f40eb04f | 40 | const char *pass, |
mridup | 5:c83ffd44f40a | 41 | nsapi_security_t security = NSAPI_SECURITY_NONE); |
mridup | 0:dc55f40eb04f | 42 | |
mridup | 5:c83ffd44f40a | 43 | virtual int disconnect(); |
mridup | 5:c83ffd44f40a | 44 | virtual const char *get_mac_address(); |
mridup | 0:dc55f40eb04f | 45 | void debug(const char * string); |
mridup | 5:c83ffd44f40a | 46 | |
mridup | 5:c83ffd44f40a | 47 | //Implementation of NetworkStack |
mridup | 5:c83ffd44f40a | 48 | virtual const char *get_ip_address(); |
mridup | 5:c83ffd44f40a | 49 | |
mridup | 5:c83ffd44f40a | 50 | protected: |
mridup | 5:c83ffd44f40a | 51 | //Implementation of NetworkStack |
mridup | 5:c83ffd44f40a | 52 | virtual int socket_open(void **handle, nsapi_protocol_t proto); |
mridup | 5:c83ffd44f40a | 53 | virtual int socket_close(void *handle); |
mridup | 5:c83ffd44f40a | 54 | virtual int socket_bind(void *handle, const SocketAddress &address); //not supported |
mridup | 5:c83ffd44f40a | 55 | virtual int socket_listen(void *handle, int backlog); //not supported |
mridup | 5:c83ffd44f40a | 56 | virtual int socket_connect(void *handle, const SocketAddress &address); |
mridup | 5:c83ffd44f40a | 57 | virtual int socket_accept(void **handle, void *server); //not supported |
mridup | 5:c83ffd44f40a | 58 | virtual int socket_send(void *handle, const void *data, unsigned size); |
mridup | 5:c83ffd44f40a | 59 | virtual int socket_recv(void *handle, void *data, unsigned size); |
mridup | 5:c83ffd44f40a | 60 | virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); |
mridup | 5:c83ffd44f40a | 61 | virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); |
mridup | 5:c83ffd44f40a | 62 | virtual void socket_attach(void *handle, void (*callback)(void *), void *data); |
mridup | 5:c83ffd44f40a | 63 | |
mridup | 5:c83ffd44f40a | 64 | private: |
mridup | 5:c83ffd44f40a | 65 | int init(void); |
mridup | 0:dc55f40eb04f | 66 | |
mridup | 0:dc55f40eb04f | 67 | SpwfSADevice _spwf; |
mridup | 0:dc55f40eb04f | 68 | bool _ids[SPWFSA_SOCKET_COUNT]; |
mridup | 3:fd9d20c4d3f0 | 69 | bool isInitialized; |
mridup | 5:c83ffd44f40a | 70 | multimap <char *, vector <uint16_t> > c_table; |
mridup | 0:dc55f40eb04f | 71 | |
mridup | 0:dc55f40eb04f | 72 | }; |
mridup | 0:dc55f40eb04f | 73 | |
mridup | 0:dc55f40eb04f | 74 | |
mridup | 0:dc55f40eb04f | 75 | #endif |