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: ATParser
Fork of ESP8266 by
Revision 4:844719bff1b1, committed 2015-05-31
- Comitter:
- austin.blackstone@arm.com
- Date:
- Sun May 31 13:07:08 2015 -0500
- Parent:
- 3:cc1177c81dd6
- Child:
- 5:a517950927fe
- Commit message:
- added skeleton to hardware driver .f file
Changed in this revision
| hwnamedriver.cpp | Show annotated file Show diff for this revision Revisions of this file |
| hwnamedriver.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/hwnamedriver.cpp Thu May 28 20:00:55 2015 +0000 +++ b/hwnamedriver.cpp Sun May 31 13:07:08 2015 -0500 @@ -16,4 +16,8 @@ #include "hwnamedriver.h" - \ No newline at end of file + // TODO: User must impliment functions from hwnamedriver.h here. + // These functions can vary widely between devices, additional functions beyond + // what is described in hwnamedriver.h can be added. This layer is used directly + // by the Interface layer and thus should provide whatever functionality is + // required by that layer. \ No newline at end of file
--- a/hwnamedriver.h Thu May 28 20:00:55 2015 +0000
+++ b/hwnamedriver.h Sun May 31 13:07:08 2015 -0500
@@ -18,8 +18,9 @@
#define HWNAME_DRIVER_H
/*
- These functions can vary greatly between networking devices. The only requirement is they provide
- the functionality needed by the Socket and Interface API's.
+ These functions are a reference / sample implimentation.
+ The functions usedcan vary greatly between networking devices.
+ The only requirement is they provide the functionality needed by the Socket and Interface API's.
*/
/*
@@ -32,5 +33,196 @@
- Recieve(dataBuffer, blocking timeout?) // recieve data with a blocking timeout
*/
+
+class HWNameDriver :
+{
+public:
+
+ /**
+ * This enum defines the possible connect types.
+ */
+ enum connectType {
+ TCP,
+ UDP,
+ };
+
+ /**
+ * Initialize the network hardware.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual init (void ) const {
+ return 0;
+ }
+
+ /**
+ * Reset the newtwork hardware
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int reset(void) const {
+ return 0;
+ }
+
+ /**
+ * Start a connection, either TCP or UDP
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int connect(connectType type) const {
+ return 0;
+ }
+
+ /**
+ * Send data over the open connection
+ *
+ * @param data The data to send.
+ * @param dataLen The number of bytes of data to send.
+ * @param timeout The timeout time to wait in ms, default to 1500ms.
+ *
+ * \returns # of bytes sent on success, -1 on failure
+ */
+ virtual int send(uint8_t *data, int dataLen, int timeout = 1500) const {
+ return 0;
+ }
+
+ /**
+ * Receive data over the open connection
+ *
+ * @param data Buffer to put received data into.
+ * @param dataMaxSize The maximum size of the data buffer to put received data into.
+ * @param timeout The timeout time to wait in ms, default to 1500ms.
+ *
+ * \returns # of bytes recieved on success, -1 on failure
+ */
+ virtual int receive(uint8_t *data, int dataMaxSize,int timeout = 1500) const {
+ return 0;
+ }
+
+ /**
+ * Stop the interface, bringing down dhcp if necessary.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int disconnect(void) const {
+ return 0;
+ }
+
+ /**
+ * Put the hardware to sleep / low power mode.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int sleep(void) const {
+ return 0;
+ }
+
+ /**
+ * Wakeup the hardware.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int wakeup(void) const {
+ return 0;
+ }
+
+ /**
+ * Set the current IP address.
+ *
+ * @param ip The IP Address to use.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int setIPAddress(const char *ip) const {
+ return 0;
+ }
+
+ /**
+ * Get the current IP address.
+ *
+ * \returns a pointer to a string containing the IP address on success, 0 on failure.
+ */
+ virtual char *getIPAddress(void) const {
+ return 0;
+ }
+
+ /**
+ * Set the current gateway address.
+ *
+ * @param gateway The Gateway to use.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int setGateway(const char *gateway) const {
+ return 0;
+ }
+
+ /**
+ * Get the current gateway address.
+ *
+ * \returns a pointer to a string containing the gateway address on success, 0 on failure.
+ */
+ virtual char *getGateway(void) const {
+ return 0;
+ }
+
+ /**
+ * Set the Network of the HWDevice
+ *
+ * @param netmask The networkMask to use.
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int setNetworkMask(const char *netmask) const {
+ return 0;
+ };
+
+ /**
+ * Get the current network mask.
+ *
+ * \returns a pointer to a string containing the network mask on success, 0 on failure.
+ */
+ virtual char *getNetworkMask(void) const {
+ return 0;
+ }
+
+ /**
+ * Set the MAC Address of the HWDevice
+ *
+ * @param mac The static IP address to use
+ *
+ * \returns 1 on success, 0 on failure
+ */
+ virtual int setMACAddress(const char *mac) const {
+ return 0;
+ };
+
+ /**
+ * Get the devices MAC address.
+ *
+ * \returns a pointer to a string containing the mac address on success, 0 on failure.
+ */
+ virtual char *getMACAddress(void) const {
+ return 0;
+ }
+
+ /**
+ * Get the current status of the interface connection.
+ *
+ * \returns true if connected, false otherwise.
+ */
+ virtual bool isConnected(void) const {
+ return false;
+ }
+
+private:
+ char IPAddress[15]; // "xxx.xxx.xxx.xxx" IPV4
+ char NetworkMask[15]; // "xxx.xxx.xxx.xxx"
+ char Gateway[15]; // "xxx.xxx.xxx.xxx"
+ char MacAddress[17]; // "xx:xx:xx:xx:xx:xx"
+ bool connected;
+
+};
+
#endif // HWNAME_DRIVER_H
\ No newline at end of file
