Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DnsQuery
Dependents: WizFi310_TCP_Echo_Server_Example
Fork of NetworkSocketAPI by
Diff: NetworkInterface.h
- Revision:
- 1:291a9d61e58a
- Parent:
- 0:d35446f60233
- Child:
- 2:ce08986b18b5
diff -r d35446f60233 -r 291a9d61e58a NetworkInterface.h
--- a/NetworkInterface.h Mon May 11 05:51:41 2015 +0000
+++ b/NetworkInterface.h Thu May 14 01:37:53 2015 +0000
@@ -14,8 +14,90 @@
* limitations under the License.
*/
- #ifndef NETWORKINTERFACE_H
- #define NETWORKINTERFACE_H
+#ifndef NETWORKINTERFACE_H
+#define NETWORKINTERFACE_H
+
+/** NetworkInterface class.
+ * This is a common interface that is shared between all hardware that connect
+ * to a network over IP.
+ */
+class NetworkInterface {
- #endif
-
\ No newline at end of file
+public:
+
+ /**
+ * Initialize the network interface with DHCP.
+ *
+ * \returns 0 on success, a negative number on failure
+ */
+ virtual int init() = 0;
+
+ /**
+ * Initialize the network interface with a static IP address.
+ *
+ * @param ip The static IP address to use
+ * @param mask The IP address mask
+ * @param gateway The gateway to use
+ *
+ * \returns 0 on success, a negative number on failure
+ */
+ virtual int init(char* ip, char* mask, 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 int connect(unsigned int timeout_ms=15000) = 0;
+
+ /**
+ * Start the interface, specifically for wifi based hardware, using DHCP if needed. This only needs to be implemented on wifi hardware.
+ *
+ * @param ssid The SSID of the access point
+ * @param phrase The passphrase, if needed, to connect
+ * @param gateway The security type of the access point
+ *
+ * \returns 0 on success, a negative number on failure
+ */
+ virtual int connect(char* ssid, char* phrase, char* security_type) = 0;
+
+ /**
+ * Stop the interface, bringing down dhcp if necessary.
+ *
+ * \returns 0 on success, a negative number on failure
+ */
+ virtual int disconnect() = 0;
+
+ /**
+ * Get the current IP address.
+ *
+ * \returns a pointer to a string containing the IP address.
+ */
+ virtual char* getIPAddress() = 0;
+
+ /**
+ * Get the current gateway address.
+ *
+ * \returns a pointer to a string containing the gateway address.
+ */
+ virtual char* getGateway() = 0;
+
+
+ /**
+ * Get the current network mask.
+ *
+ * \returns a pointer to a string containing the network mask.
+ */
+ virtual char* getNetworkMask() = 0;
+
+ /**
+ * Get the current status of the interface connection.
+ *
+ * \returns true if connected, false otherwise.
+ */
+ virtual bool isConnected(void) = 0;
+};
+
+#endif
