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:
- 3:167dd63981b6
- Parent:
- 2:ce08986b18b5
- Child:
- 4:f09f0932db4a
diff -r ce08986b18b5 -r 167dd63981b6 NetworkInterface.h
--- a/NetworkInterface.h Tue May 19 17:40:28 2015 +0000
+++ b/NetworkInterface.h Thu May 28 20:00:36 2015 +0000
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#ifndef NETWORKINTERFACE_H
#define NETWORKINTERFACE_H
@@ -21,17 +21,21 @@
* This is a common interface that is shared between all hardware that connect
* to a network over IP.
*/
-class NetworkInterface {
-
+class NetworkInterface
+{
public:
+ typedef enum {
+ NI_NONE = 0,
+ NI_WPA2,
+ } ni_security_t;
/**
* Initialize the network interface with DHCP.
*
* \returns 0 on success, a negative number on failure
*/
- virtual int init() = 0;
-
+ virtual int init(void) const = 0;
+
/**
* Initialize the network interface with a static IP address.
*
@@ -41,8 +45,21 @@
*
* \returns 0 on success, a negative number on failure
*/
- virtual int init(char *ip, char *mask, char *gateway) = 0;
-
+ int init(const char *ip, const char *mask, const char *gateway) const {
+ return -1;
+ }
+
+ /**
+ * 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(const unsigned int timeout_ms=15000) const {
+ return -1;
+ }
+
/**
* Start the interface, using DHCP if needed.
*
@@ -50,43 +67,52 @@
*
* \returns 0 on success, a negative number on failure
*/
- virtual int connect(unsigned int timeout_ms=15000) = 0;
-
+ virtual int connect(const char *ap, const char *pass_phrase = 0, const ni_security_t security = NI_NONE, const unsigned int timeout_ms=15000) const {
+ return -1;
+ }
+
/**
* Stop the interface, bringing down dhcp if necessary.
*
* \returns 0 on success, a negative number on failure
*/
- virtual int disconnect() = 0;
-
+ virtual int disconnect(void) const = 0;
+
/**
* Get the current IP address.
*
* \returns a pointer to a string containing the IP address.
*/
- virtual char* getIPAddress() = 0;
-
+ virtual char *getIPAddress(void) const = 0;
+
/**
* Get the current gateway address.
*
* \returns a pointer to a string containing the gateway address.
*/
- virtual char* getGateway() = 0;
-
-
+ virtual char *getGateway(void) const = 0;
+
+
/**
* Get the current network mask.
*
* \returns a pointer to a string containing the network mask.
*/
- virtual char* getNetworkMask() = 0;
-
+ virtual char *getNetworkMask(void) const = 0;
+
+ /**
+ * Get the devices MAC address.
+ *
+ * \returns a pointer to a string containing the mac address.
+ */
+ virtual char *getMACAddress(void) const = 0;
+
/**
* Get the current status of the interface connection.
*
* \returns true if connected, false otherwise.
*/
- virtual bool isConnected(void) = 0;
+ virtual int isConnected(void) const = 0;
};
#endif
