iowfehu;gdbjwHJAOPIHO?L
Fork of X_NUCLEO_IDW01M1 by
SPWFInterface.h@0:dc55f40eb04f, 2016-04-13 (annotated)
- Committer:
- mridup
- Date:
- Wed Apr 13 11:34:07 2016 +0000
- Revision:
- 0:dc55f40eb04f
- Child:
- 3:fd9d20c4d3f0
First Version of mbed X_NUCLEO_IDW01M1 library
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 | 0:dc55f40eb04f | 28 | * Implementation of the NetworkInterface for the SPWF Device |
mridup | 0:dc55f40eb04f | 29 | */ |
mridup | 0:dc55f40eb04f | 30 | class SpwfSAInterface : 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 | 0:dc55f40eb04f | 38 | virtual int32_t connect( |
mridup | 0:dc55f40eb04f | 39 | const char *ssid, |
mridup | 0:dc55f40eb04f | 40 | const char *pass, |
mridup | 0:dc55f40eb04f | 41 | ns_security_t security = NS_SECURITY_NONE); |
mridup | 0:dc55f40eb04f | 42 | |
mridup | 0:dc55f40eb04f | 43 | virtual int32_t disconnect(); |
mridup | 0:dc55f40eb04f | 44 | |
mridup | 0:dc55f40eb04f | 45 | // Implementation of NetworkInterface |
mridup | 0:dc55f40eb04f | 46 | virtual const char *getIPAddress(); |
mridup | 0:dc55f40eb04f | 47 | virtual const char *getMACAddress(); |
mridup | 0:dc55f40eb04f | 48 | |
mridup | 0:dc55f40eb04f | 49 | virtual SocketInterface *createSocket(ns_protocol_t proto); |
mridup | 0:dc55f40eb04f | 50 | virtual void destroySocket(SocketInterface *socket); |
mridup | 0:dc55f40eb04f | 51 | |
mridup | 0:dc55f40eb04f | 52 | int32_t init(void); |
mridup | 0:dc55f40eb04f | 53 | void debug(const char * string); |
mridup | 0:dc55f40eb04f | 54 | void setid(bool set, int id); |
mridup | 0:dc55f40eb04f | 55 | |
mridup | 0:dc55f40eb04f | 56 | private: |
mridup | 0:dc55f40eb04f | 57 | |
mridup | 0:dc55f40eb04f | 58 | SpwfSADevice _spwf; |
mridup | 0:dc55f40eb04f | 59 | bool _ids[SPWFSA_SOCKET_COUNT]; |
mridup | 0:dc55f40eb04f | 60 | multimap <char *, vector <uint16_t> > c_table; |
mridup | 0:dc55f40eb04f | 61 | |
mridup | 0:dc55f40eb04f | 62 | // Implementation of the SocketInterface for the SpwfSA |
mridup | 0:dc55f40eb04f | 63 | class SpwfSASocket : public SocketInterface |
mridup | 0:dc55f40eb04f | 64 | { |
mridup | 0:dc55f40eb04f | 65 | public: |
mridup | 0:dc55f40eb04f | 66 | |
mridup | 0:dc55f40eb04f | 67 | // SpwfSA specific details |
mridup | 0:dc55f40eb04f | 68 | SpwfSADevice *__spwf; |
mridup | 0:dc55f40eb04f | 69 | SpwfSAInterface *_itf; |
mridup | 0:dc55f40eb04f | 70 | ns_protocol_t _proto; |
mridup | 0:dc55f40eb04f | 71 | int _id; |
mridup | 0:dc55f40eb04f | 72 | |
mridup | 0:dc55f40eb04f | 73 | SpwfSASocket(SpwfSAInterface *itf, SpwfSADevice *spwf, ns_protocol_t proto) |
mridup | 0:dc55f40eb04f | 74 | : __spwf(spwf), _itf(itf), _proto(proto) {} |
mridup | 0:dc55f40eb04f | 75 | |
mridup | 0:dc55f40eb04f | 76 | virtual ~SpwfSASocket() { |
mridup | 0:dc55f40eb04f | 77 | _itf = 0; |
mridup | 0:dc55f40eb04f | 78 | __spwf = 0; |
mridup | 0:dc55f40eb04f | 79 | } |
mridup | 0:dc55f40eb04f | 80 | |
mridup | 0:dc55f40eb04f | 81 | // Implementation of SocketInterface |
mridup | 0:dc55f40eb04f | 82 | virtual int32_t open(const char *ip, uint16_t port); |
mridup | 0:dc55f40eb04f | 83 | virtual int32_t close(); |
mridup | 0:dc55f40eb04f | 84 | |
mridup | 0:dc55f40eb04f | 85 | virtual int32_t send(const void *data, uint32_t size); |
mridup | 0:dc55f40eb04f | 86 | virtual int32_t recv(void *data, uint32_t size); |
mridup | 0:dc55f40eb04f | 87 | }; |
mridup | 0:dc55f40eb04f | 88 | |
mridup | 0:dc55f40eb04f | 89 | }; |
mridup | 0:dc55f40eb04f | 90 | |
mridup | 0:dc55f40eb04f | 91 | /*Function to export singleton instance*/ |
mridup | 0:dc55f40eb04f | 92 | SpwfSAInterface *createSPWFInstance(void); |
mridup | 0:dc55f40eb04f | 93 | |
mridup | 0:dc55f40eb04f | 94 | #endif |