iowfehu;gdbjwHJAOPIHO?L

Fork of X_NUCLEO_IDW01M1 by ST

Committer:
mridup
Date:
Tue Apr 19 07:19:10 2016 +0000
Revision:
3:fd9d20c4d3f0
Parent:
0:dc55f40eb04f
Child:
5:c83ffd44f40a
init() implicit in connect(). Check isConnected() in most APIs.

Who changed what in which revision?

UserRevisionLine numberNew 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 void debug(const char * string);
mridup 0:dc55f40eb04f 53 void setid(bool set, int id);
mridup 0:dc55f40eb04f 54
mridup 0:dc55f40eb04f 55 private:
mridup 0:dc55f40eb04f 56
mridup 0:dc55f40eb04f 57 SpwfSADevice _spwf;
mridup 0:dc55f40eb04f 58 bool _ids[SPWFSA_SOCKET_COUNT];
mridup 3:fd9d20c4d3f0 59 bool isInitialized;
mridup 0:dc55f40eb04f 60 multimap <char *, vector <uint16_t> > c_table;
mridup 0:dc55f40eb04f 61
mridup 3:fd9d20c4d3f0 62 int32_t init(void);
mridup 3:fd9d20c4d3f0 63
mridup 0:dc55f40eb04f 64 // Implementation of the SocketInterface for the SpwfSA
mridup 0:dc55f40eb04f 65 class SpwfSASocket : public SocketInterface
mridup 0:dc55f40eb04f 66 {
mridup 0:dc55f40eb04f 67 public:
mridup 0:dc55f40eb04f 68
mridup 0:dc55f40eb04f 69 // SpwfSA specific details
mridup 0:dc55f40eb04f 70 SpwfSADevice *__spwf;
mridup 0:dc55f40eb04f 71 SpwfSAInterface *_itf;
mridup 0:dc55f40eb04f 72 ns_protocol_t _proto;
mridup 0:dc55f40eb04f 73 int _id;
mridup 0:dc55f40eb04f 74
mridup 0:dc55f40eb04f 75 SpwfSASocket(SpwfSAInterface *itf, SpwfSADevice *spwf, ns_protocol_t proto)
mridup 0:dc55f40eb04f 76 : __spwf(spwf), _itf(itf), _proto(proto) {}
mridup 0:dc55f40eb04f 77
mridup 0:dc55f40eb04f 78 virtual ~SpwfSASocket() {
mridup 0:dc55f40eb04f 79 _itf = 0;
mridup 0:dc55f40eb04f 80 __spwf = 0;
mridup 0:dc55f40eb04f 81 }
mridup 0:dc55f40eb04f 82
mridup 0:dc55f40eb04f 83 // Implementation of SocketInterface
mridup 0:dc55f40eb04f 84 virtual int32_t open(const char *ip, uint16_t port);
mridup 0:dc55f40eb04f 85 virtual int32_t close();
mridup 0:dc55f40eb04f 86
mridup 0:dc55f40eb04f 87 virtual int32_t send(const void *data, uint32_t size);
mridup 0:dc55f40eb04f 88 virtual int32_t recv(void *data, uint32_t size);
mridup 0:dc55f40eb04f 89 };
mridup 0:dc55f40eb04f 90
mridup 0:dc55f40eb04f 91 };
mridup 0:dc55f40eb04f 92
mridup 0:dc55f40eb04f 93 /*Function to export singleton instance*/
mridup 0:dc55f40eb04f 94 SpwfSAInterface *createSPWFInstance(void);
mridup 0:dc55f40eb04f 95
mridup 0:dc55f40eb04f 96 #endif