NetworkSocketAPI
Dependents: HelloWizFi250Interface
Fork of NetworkSocketAPI by
Revision 42:49893d13c432, committed 2016-02-23
- Comitter:
- Christopher Haster
- Date:
- Tue Feb 23 05:07:02 2016 -0600
- Branch:
- api-changes
- Parent:
- 41:3ec1c97e9bbf
- Child:
- 43:09ea32f2eb54
- Commit message:
- Standardized some C++ style things
Changed in this revision
--- a/NetworkInterface.cpp Tue Feb 23 04:01:38 2016 -0600 +++ b/NetworkInterface.cpp Tue Feb 23 05:07:02 2016 -0600 @@ -22,16 +22,16 @@ NetworkInterface::NetworkInterface() : _timeout(15000) { - memset(_ip_address, 0, SOCK_IP_SIZE); - memset(_network_mask, 0, SOCK_IP_SIZE); - memset(_gateway, 0, SOCK_IP_SIZE); + memset(_ip_address, 0, NS_IP_SIZE); + memset(_network_mask, 0, NS_IP_SIZE); + memset(_gateway, 0, NS_IP_SIZE); } void NetworkInterface::useDHCP() { - memset(_ip_address, 0, SOCK_IP_SIZE); - memset(_network_mask, 0, SOCK_IP_SIZE); - memset(_gateway, 0, SOCK_IP_SIZE); + memset(_ip_address, 0, NS_IP_SIZE); + memset(_network_mask, 0, NS_IP_SIZE); + memset(_gateway, 0, NS_IP_SIZE); } void NetworkInterface::setIPAddress(const char *ip)
--- a/NetworkInterface.h Tue Feb 23 04:01:38 2016 -0600 +++ b/NetworkInterface.h Tue Feb 23 05:07:02 2016 -0600 @@ -17,10 +17,14 @@ #ifndef NETWORK_INTERFACE_H #define NETWORK_INTERFACE_H +#include "SocketInterface.h" #include "stdint.h" -#include "SocketInterface.h" + -#define SOCK_IP_SIZE 16 +/** Maximum storage needed for IP address and MAC addresses + */ +#define NS_IP_SIZE 16 +#define NS_MAC_SIZE 18 /** NetworkInterface class @@ -85,7 +89,7 @@ /** Get the current status of the interface * @return true if connected */ - virtual bool isConnected(void); + virtual bool isConnected(); /** Looks up the specified host's IP address * @param name URL of host @@ -112,9 +116,9 @@ virtual void destroySocket(SocketInterface *socket) = 0; private: - char _ip_address[SOCK_IP_SIZE]; - char _network_mask[SOCK_IP_SIZE]; - char _gateway[SOCK_IP_SIZE]; + char _ip_address[NS_IP_SIZE]; + char _network_mask[NS_IP_SIZE]; + char _gateway[NS_IP_SIZE]; uint32_t _timeout; };
--- a/Socket.cpp Tue Feb 23 04:01:38 2016 -0600 +++ b/Socket.cpp Tue Feb 23 05:07:02 2016 -0600 @@ -22,7 +22,7 @@ , _proto(proto) , _socket(0) { - memset(_ip_address, 0, SOCK_IP_SIZE); + memset(_ip_address, 0, NS_IP_SIZE); _port = 0; _timeout = iface->getTimeout();
--- a/Socket.h Tue Feb 23 04:01:38 2016 -0600 +++ b/Socket.h Tue Feb 23 05:07:02 2016 -0600 @@ -105,7 +105,7 @@ socket_protocol_t _proto; SocketInterface *_socket; - char _ip_address[SOCK_IP_SIZE]; + char _ip_address[NS_IP_SIZE]; uint16_t _port; uint32_t _timeout; };
--- a/SocketInterface.h Tue Feb 23 04:01:38 2016 -0600 +++ b/SocketInterface.h Tue Feb 23 05:07:02 2016 -0600 @@ -22,10 +22,10 @@ /** Enum of socket protocols */ -typedef enum { +enum socket_protocol_t { SOCK_TCP, /*!< Socket connection over TCP */ SOCK_UDP, /*!< Socket connection over UDP */ -} socket_protocol_t; +}; /** SocketInterface class
--- a/WiFiInterface.h Tue Feb 23 04:01:38 2016 -0600 +++ b/WiFiInterface.h Tue Feb 23 05:07:02 2016 -0600 @@ -21,12 +21,12 @@ /** Enum for WiFi encryption types */ -typedef enum wifi_security_t { +enum wifi_security_t { WI_NONE = 0, /*!< No security for connection */ WI_WEP, /*!< WEP encryption */ WI_WPA, /*!< WPA encryption */ WI_WPA2, /*!< WPA2 encryption */ -} wifi_security_t; +}; /** WiFiInterface class