iowfehu;gdbjwHJAOPIHO?L
Fork of X_NUCLEO_IDW01M1 by
Diff: SPWFInterface.h
- Revision:
- 5:c83ffd44f40a
- Parent:
- 3:fd9d20c4d3f0
- Child:
- 6:e7a3fca2df10
diff -r d7d25616f1f7 -r c83ffd44f40a SPWFInterface.h --- a/SPWFInterface.h Tue Apr 19 07:42:22 2016 +0000 +++ b/SPWFInterface.h Wed May 04 12:16:20 2016 +0000 @@ -25,9 +25,9 @@ #define SPWFSA_SOCKET_COUNT 8 /** SpwfSAInterface class - * Implementation of the NetworkInterface for the SPWF Device + * Implementation of the NetworkStack for the SPWF Device */ -class SpwfSAInterface : public WiFiInterface +class SpwfSAInterface : public NetworkStack, public WiFiInterface { public: @@ -35,62 +35,41 @@ virtual ~SpwfSAInterface(); // Implementation of WiFiInterface - virtual int32_t connect( + virtual int connect( const char *ssid, const char *pass, - ns_security_t security = NS_SECURITY_NONE); - - virtual int32_t disconnect(); - - // Implementation of NetworkInterface - virtual const char *getIPAddress(); - virtual const char *getMACAddress(); + nsapi_security_t security = NSAPI_SECURITY_NONE); - virtual SocketInterface *createSocket(ns_protocol_t proto); - virtual void destroySocket(SocketInterface *socket); - + virtual int disconnect(); + virtual const char *get_mac_address(); void debug(const char * string); - void setid(bool set, int id); + + //Implementation of NetworkStack + virtual const char *get_ip_address(); + +protected: + //Implementation of NetworkStack + virtual int socket_open(void **handle, nsapi_protocol_t proto); + virtual int socket_close(void *handle); + virtual int socket_bind(void *handle, const SocketAddress &address); //not supported + virtual int socket_listen(void *handle, int backlog); //not supported + virtual int socket_connect(void *handle, const SocketAddress &address); + virtual int socket_accept(void **handle, void *server); //not supported + virtual int socket_send(void *handle, const void *data, unsigned size); + virtual int socket_recv(void *handle, void *data, unsigned size); + virtual int socket_sendto(void *handle, const SocketAddress &address, const void *data, unsigned size); + virtual int socket_recvfrom(void *handle, SocketAddress *address, void *buffer, unsigned size); + virtual void socket_attach(void *handle, void (*callback)(void *), void *data); + +private: + int init(void); -private: - SpwfSADevice _spwf; bool _ids[SPWFSA_SOCKET_COUNT]; bool isInitialized; - multimap <char *, vector <uint16_t> > c_table; - - int32_t init(void); - - // Implementation of the SocketInterface for the SpwfSA - class SpwfSASocket : public SocketInterface - { - public: + multimap <char *, vector <uint16_t> > c_table; - // SpwfSA specific details - SpwfSADevice *__spwf; - SpwfSAInterface *_itf; - ns_protocol_t _proto; - int _id; - - SpwfSASocket(SpwfSAInterface *itf, SpwfSADevice *spwf, ns_protocol_t proto) - : __spwf(spwf), _itf(itf), _proto(proto) {} - - virtual ~SpwfSASocket() { - _itf = 0; - __spwf = 0; - } - - // Implementation of SocketInterface - virtual int32_t open(const char *ip, uint16_t port); - virtual int32_t close(); - - virtual int32_t send(const void *data, uint32_t size); - virtual int32_t recv(void *data, uint32_t size); - }; - }; -/*Function to export singleton instance*/ -SpwfSAInterface *createSPWFInstance(void); #endif