NetworkSocketAPI
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Revision 13:f84e69b3fdd3, committed 2015-07-17
- Comitter:
- sarahmarshy
- Date:
- Fri Jul 17 23:14:01 2015 +0000
- Parent:
- 12:ab3679eb4d9d
- Child:
- 14:9e1bd182ef07
- Commit message:
- Removed const identifiers
Changed in this revision
--- a/NetworkInterface.h Thu Jul 16 05:19:17 2015 +0000 +++ b/NetworkInterface.h Fri Jul 17 23:14:01 2015 +0000 @@ -32,7 +32,7 @@ /** Initialize the network interface with DHCP. @returns 0 on success, a negative number on failure */ - virtual int32_t init(void) const = 0; + virtual int32_t init(void) = 0; /** Initialize the network interface with a static IP address. @param ip The static IP address to use @@ -40,14 +40,14 @@ @param gateway The gateway to use @returns 0 on success, a negative number on failure */ - virtual int32_t init(const char *ip, const char *mask, const char *gateway) const = 0; + virtual int32_t init(const char *ip, const char *mask, const char *gateway) = 0; /** Start the interface, using DHCP if needed. @param timeout_ms Time in miliseconds to wait while attempting to connect before timing out @returns 0 on success, a negative number on failure */ - virtual int32_t connect(uint32_t timeout_ms = 15000) const = 0; + virtual int32_t connect(uint32_t timeout_ms = 15000) = 0; /** Stop the interface, bringing down dhcp if necessary. @returns 0 on success, a negative number on failure @@ -57,7 +57,7 @@ /** Get the current IP address. @returns a pointer to a string containing the IP address. */ - virtual char *getIPAddress(void) const = 0; + virtual char *getIPAddress(void) = 0; /** Get the current gateway address. @returns a pointer to a string containing the gateway address. @@ -78,19 +78,19 @@ /** Get the current status of the interface connection. @returns true if connected, a negative number on failure */ - virtual int32_t isConnected(void) const = 0; + virtual int32_t isConnected(void) = 0; /** Allocate space for a socket. @param The type of socket you want to open, SOCK_TCP or SOCK_UDP @returns a pointer to the allocated socket. */ - virtual SocketInterface* allocateSocket(socket_protocol_t socketProtocol) const = 0; + virtual SocketInterface* allocateSocket(socket_protocol_t socketProtocol) = 0; /** Deallocate space for a socket. @param An allocated SocketInterface @returns 0 if object is destroyed, -1 otherwise */ - virtual int deallocateSocket(SocketInterface* socket) const = 0; + virtual int deallocateSocket(SocketInterface* socket) = 0; protected: /** Map used to keep track of all SocketInterface instances */
--- a/SocketInterface.h Thu Jul 16 05:19:17 2015 +0000 +++ b/SocketInterface.h Fri Jul 17 23:14:01 2015 +0000 @@ -58,20 +58,20 @@ @param addr The endpoint address @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ - virtual int32_t setAddress(const char* addr) const = 0; + virtual void setAddress(const char* addr) = 0; /** Set the port of this endpoint @param port The endpoint port @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ - virtual int32_t setPort(uint16_t port) const = 0; + virtual void setPort(uint16_t port) = 0; /** Set the address and port of this endpoint @param addr The endpoint address (supplied as an ip address). @param port The endpoint port @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ - virtual int32_t setAddressPort(const char* addr, uint16_t port) const = 0; + virtual void setAddressPort(const char* addr, uint16_t port) = 0; /** Get the IP address of this endpoint @return The IP address of this endpoint. @@ -82,7 +82,9 @@ @return The port of this socket */ virtual uint16_t getPort(void) const = 0; - +protected: + char* _addr; + uint16_t _port; }; /** SocketInterface class. @@ -113,7 +115,7 @@ @param endpoint The endpoint we want to connect to @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ - virtual int32_t open() const = 0; + virtual int32_t open() = 0; /** In client or server mode send data @param data A buffer of data to send @@ -121,7 +123,7 @@ @param timeout_ms The longest amount of time this send can take @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ - virtual int32_t send(const void *data, uint32_t amount, uint32_t timeout_ms = 15000) const = 0; + virtual int32_t send(const void *data, uint32_t amount, uint32_t timeout_ms = 15000) = 0; /** In client or server mode receive data @param data a buffer to store the data in @@ -129,13 +131,15 @@ @param timeout_ms The longest time to wait for the data @return The amount of data received */ - virtual uint32_t recv(const void *data, uint32_t amount, uint32_t timeout_ms = 15000) const = 0; + virtual uint32_t recv(void *data, uint32_t amount, uint32_t timeout_ms = 15000) = 0; /** In client or server mode, close an open connection @param endpoint The endpoint we want to connect to @return 0 on success, -1 on failure (when an hostname cannot be resolved by DNS). */ virtual int32_t close() const = 0; +protected: + socket_protocol_t _type; };
--- a/WiFiInterface.h Thu Jul 16 05:19:17 2015 +0000 +++ b/WiFiInterface.h Fri Jul 17 23:14:01 2015 +0000 @@ -45,7 +45,7 @@ @param timeout_ms Time in miliseconds to wait while attempting to connect before timing out @returns 0 on success, a negative number on failure */ - virtual int32_t connect(const char *ap, const char *pass_phrase = 0, wifi_security_t security = WI_NONE, uint32_t timeout_ms = 15000) const = 0; + virtual int32_t connect(const char *ap, const char *pass_phrase = 0, wifi_security_t security = WI_NONE, uint32_t timeout_ms = 15000) = 0; };