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
hwnamedriver.h@7:a91e1e139a6a, 2015-07-21 (annotated)
- Committer:
- sarahmarshy
- Date:
- Tue Jul 21 19:54:23 2015 +0000
- Revision:
- 7:a91e1e139a6a
- Parent:
- 5:a517950927fe
Changed to be compatible with new AtParser. Functioning recieve command.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| mbedAustin | 1:7fcb6d791d62 | 1 | /* NetworkInterface Base Class |
| mbedAustin | 1:7fcb6d791d62 | 2 | * Copyright (c) 2015 ARM Limited |
| mbedAustin | 1:7fcb6d791d62 | 3 | * |
| mbedAustin | 1:7fcb6d791d62 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| mbedAustin | 1:7fcb6d791d62 | 5 | * you may not use this file except in compliance with the License. |
| mbedAustin | 1:7fcb6d791d62 | 6 | * You may obtain a copy of the License at |
| mbedAustin | 1:7fcb6d791d62 | 7 | * |
| mbedAustin | 1:7fcb6d791d62 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| mbedAustin | 1:7fcb6d791d62 | 9 | * |
| mbedAustin | 1:7fcb6d791d62 | 10 | * Unless required by applicable law or agreed to in writing, software |
| mbedAustin | 1:7fcb6d791d62 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| mbedAustin | 1:7fcb6d791d62 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| mbedAustin | 1:7fcb6d791d62 | 13 | * See the License for the specific language governing permissions and |
| mbedAustin | 1:7fcb6d791d62 | 14 | * limitations under the License. |
| mbedAustin | 1:7fcb6d791d62 | 15 | */ |
| mbedAustin | 1:7fcb6d791d62 | 16 | |
| mbedAustin | 1:7fcb6d791d62 | 17 | #ifndef HWNAME_DRIVER_H |
| mbedAustin | 1:7fcb6d791d62 | 18 | #define HWNAME_DRIVER_H |
| mbedAustin | 1:7fcb6d791d62 | 19 | |
| mbedAustin | 2:3a8e1a6c0524 | 20 | /* |
| austin.blackstone@arm.com | 4:844719bff1b1 | 21 | These functions are a reference / sample implimentation. |
| austin.blackstone@arm.com | 4:844719bff1b1 | 22 | The functions usedcan vary greatly between networking devices. |
| austin.blackstone@arm.com | 4:844719bff1b1 | 23 | The only requirement is they provide the functionality needed by the Socket and Interface API's. |
| mbedAustin | 2:3a8e1a6c0524 | 24 | */ |
| mbedAustin | 2:3a8e1a6c0524 | 25 | |
| mbedAustin | 2:3a8e1a6c0524 | 26 | /* |
| mbedAustin | 2:3a8e1a6c0524 | 27 | Functions to impliment |
| mbedAustin | 2:3a8e1a6c0524 | 28 | - Initialize(SingleConnection/MultiConnection) // return object to track current endpoint? |
| mbedAustin | 2:3a8e1a6c0524 | 29 | - Reset() // its initialize but as a handy human readable implimentation |
| mbedAustin | 2:3a8e1a6c0524 | 30 | - OpenConnection(Type TCP/UDP, IPV4/6, blocking/non-blocking) |
| mbedAustin | 2:3a8e1a6c0524 | 31 | - CloseConnection() // empty if single mode, provide return from initialize if in multi mode |
| mbedAustin | 2:3a8e1a6c0524 | 32 | - Send(data) // make a vector to have implicit size? |
| mbedAustin | 2:3a8e1a6c0524 | 33 | - Recieve(dataBuffer, blocking timeout?) // recieve data with a blocking timeout |
| mbedAustin | 2:3a8e1a6c0524 | 34 | |
| mbedAustin | 2:3a8e1a6c0524 | 35 | */ |
| austin.blackstone@arm.com | 4:844719bff1b1 | 36 | |
| sam_grove | 5:a517950927fe | 37 | //class HWNameDriver : |
| sam_grove | 5:a517950927fe | 38 | //{ |
| sam_grove | 5:a517950927fe | 39 | //public: |
| sam_grove | 5:a517950927fe | 40 | // |
| sam_grove | 5:a517950927fe | 41 | // /** |
| sam_grove | 5:a517950927fe | 42 | // * This enum defines the possible connect types. |
| sam_grove | 5:a517950927fe | 43 | // */ |
| sam_grove | 5:a517950927fe | 44 | // enum connectType { |
| sam_grove | 5:a517950927fe | 45 | // TCP, |
| sam_grove | 5:a517950927fe | 46 | // UDP, |
| sam_grove | 5:a517950927fe | 47 | // }; |
| sam_grove | 5:a517950927fe | 48 | // |
| sam_grove | 5:a517950927fe | 49 | // /** |
| sam_grove | 5:a517950927fe | 50 | // * Initialize the network hardware. |
| sam_grove | 5:a517950927fe | 51 | // * |
| sam_grove | 5:a517950927fe | 52 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 53 | // */ |
| sam_grove | 5:a517950927fe | 54 | // virtual init (void ) const { |
| sam_grove | 5:a517950927fe | 55 | // return 0; |
| sam_grove | 5:a517950927fe | 56 | // } |
| sam_grove | 5:a517950927fe | 57 | // |
| sam_grove | 5:a517950927fe | 58 | // /** |
| sam_grove | 5:a517950927fe | 59 | // * Reset the newtwork hardware |
| sam_grove | 5:a517950927fe | 60 | // * |
| sam_grove | 5:a517950927fe | 61 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 62 | // */ |
| sam_grove | 5:a517950927fe | 63 | // virtual int reset(void) const { |
| sam_grove | 5:a517950927fe | 64 | // return 0; |
| sam_grove | 5:a517950927fe | 65 | // } |
| sam_grove | 5:a517950927fe | 66 | // |
| sam_grove | 5:a517950927fe | 67 | // /** |
| sam_grove | 5:a517950927fe | 68 | // * Start a connection, either TCP or UDP |
| sam_grove | 5:a517950927fe | 69 | // * |
| sam_grove | 5:a517950927fe | 70 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 71 | // */ |
| sam_grove | 5:a517950927fe | 72 | // virtual int connect(connectType type) const { |
| sam_grove | 5:a517950927fe | 73 | // return 0; |
| sam_grove | 5:a517950927fe | 74 | // } |
| sam_grove | 5:a517950927fe | 75 | // |
| sam_grove | 5:a517950927fe | 76 | // /** |
| sam_grove | 5:a517950927fe | 77 | // * Send data over the open connection |
| sam_grove | 5:a517950927fe | 78 | // * |
| sam_grove | 5:a517950927fe | 79 | // * @param data The data to send. |
| sam_grove | 5:a517950927fe | 80 | // * @param dataLen The number of bytes of data to send. |
| sam_grove | 5:a517950927fe | 81 | // * @param timeout The timeout time to wait in ms, default to 1500ms. |
| sam_grove | 5:a517950927fe | 82 | // * |
| sam_grove | 5:a517950927fe | 83 | // * \returns # of bytes sent on success, -1 on failure |
| sam_grove | 5:a517950927fe | 84 | // */ |
| sam_grove | 5:a517950927fe | 85 | // virtual int send(uint8_t *data, int dataLen, int timeout = 1500) const { |
| sam_grove | 5:a517950927fe | 86 | // return 0; |
| sam_grove | 5:a517950927fe | 87 | // } |
| sam_grove | 5:a517950927fe | 88 | // |
| sam_grove | 5:a517950927fe | 89 | // /** |
| sam_grove | 5:a517950927fe | 90 | // * Receive data over the open connection |
| sam_grove | 5:a517950927fe | 91 | // * |
| sam_grove | 5:a517950927fe | 92 | // * @param data Buffer to put received data into. |
| sam_grove | 5:a517950927fe | 93 | // * @param dataMaxSize The maximum size of the data buffer to put received data into. |
| sam_grove | 5:a517950927fe | 94 | // * @param timeout The timeout time to wait in ms, default to 1500ms. |
| sam_grove | 5:a517950927fe | 95 | // * |
| sam_grove | 5:a517950927fe | 96 | // * \returns # of bytes recieved on success, -1 on failure |
| sam_grove | 5:a517950927fe | 97 | // */ |
| sam_grove | 5:a517950927fe | 98 | // virtual int receive(uint8_t *data, int dataMaxSize,int timeout = 1500) const { |
| sam_grove | 5:a517950927fe | 99 | // return 0; |
| sam_grove | 5:a517950927fe | 100 | // } |
| sam_grove | 5:a517950927fe | 101 | // |
| sam_grove | 5:a517950927fe | 102 | // /** |
| sam_grove | 5:a517950927fe | 103 | // * Stop the interface, bringing down dhcp if necessary. |
| sam_grove | 5:a517950927fe | 104 | // * |
| sam_grove | 5:a517950927fe | 105 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 106 | // */ |
| sam_grove | 5:a517950927fe | 107 | // virtual int disconnect(void) const { |
| sam_grove | 5:a517950927fe | 108 | // return 0; |
| sam_grove | 5:a517950927fe | 109 | // } |
| sam_grove | 5:a517950927fe | 110 | // |
| sam_grove | 5:a517950927fe | 111 | // /** |
| sam_grove | 5:a517950927fe | 112 | // * Put the hardware to sleep / low power mode. |
| sam_grove | 5:a517950927fe | 113 | // * |
| sam_grove | 5:a517950927fe | 114 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 115 | // */ |
| sam_grove | 5:a517950927fe | 116 | // virtual int sleep(void) const { |
| sam_grove | 5:a517950927fe | 117 | // return 0; |
| sam_grove | 5:a517950927fe | 118 | // } |
| sam_grove | 5:a517950927fe | 119 | // |
| sam_grove | 5:a517950927fe | 120 | // /** |
| sam_grove | 5:a517950927fe | 121 | // * Wakeup the hardware. |
| sam_grove | 5:a517950927fe | 122 | // * |
| sam_grove | 5:a517950927fe | 123 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 124 | // */ |
| sam_grove | 5:a517950927fe | 125 | // virtual int wakeup(void) const { |
| sam_grove | 5:a517950927fe | 126 | // return 0; |
| sam_grove | 5:a517950927fe | 127 | // } |
| sam_grove | 5:a517950927fe | 128 | // |
| sam_grove | 5:a517950927fe | 129 | // /** |
| sam_grove | 5:a517950927fe | 130 | // * Set the current IP address. |
| sam_grove | 5:a517950927fe | 131 | // * |
| sam_grove | 5:a517950927fe | 132 | // * @param ip The IP Address to use. |
| sam_grove | 5:a517950927fe | 133 | // * |
| sam_grove | 5:a517950927fe | 134 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 135 | // */ |
| sam_grove | 5:a517950927fe | 136 | // virtual int setIPAddress(const char *ip) const { |
| sam_grove | 5:a517950927fe | 137 | // return 0; |
| sam_grove | 5:a517950927fe | 138 | // } |
| sam_grove | 5:a517950927fe | 139 | // |
| sam_grove | 5:a517950927fe | 140 | // /** |
| sam_grove | 5:a517950927fe | 141 | // * Get the current IP address. |
| sam_grove | 5:a517950927fe | 142 | // * |
| sam_grove | 5:a517950927fe | 143 | // * \returns a pointer to a string containing the IP address on success, 0 on failure. |
| sam_grove | 5:a517950927fe | 144 | // */ |
| sam_grove | 5:a517950927fe | 145 | // virtual char *getIPAddress(void) const { |
| sam_grove | 5:a517950927fe | 146 | // return 0; |
| sam_grove | 5:a517950927fe | 147 | // } |
| sam_grove | 5:a517950927fe | 148 | // |
| sam_grove | 5:a517950927fe | 149 | // /** |
| sam_grove | 5:a517950927fe | 150 | // * Set the current gateway address. |
| sam_grove | 5:a517950927fe | 151 | // * |
| sam_grove | 5:a517950927fe | 152 | // * @param gateway The Gateway to use. |
| sam_grove | 5:a517950927fe | 153 | // * |
| sam_grove | 5:a517950927fe | 154 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 155 | // */ |
| sam_grove | 5:a517950927fe | 156 | // virtual int setGateway(const char *gateway) const { |
| sam_grove | 5:a517950927fe | 157 | // return 0; |
| sam_grove | 5:a517950927fe | 158 | // } |
| sam_grove | 5:a517950927fe | 159 | // |
| sam_grove | 5:a517950927fe | 160 | // /** |
| sam_grove | 5:a517950927fe | 161 | // * Get the current gateway address. |
| sam_grove | 5:a517950927fe | 162 | // * |
| sam_grove | 5:a517950927fe | 163 | // * \returns a pointer to a string containing the gateway address on success, 0 on failure. |
| sam_grove | 5:a517950927fe | 164 | // */ |
| sam_grove | 5:a517950927fe | 165 | // virtual char *getGateway(void) const { |
| sam_grove | 5:a517950927fe | 166 | // return 0; |
| sam_grove | 5:a517950927fe | 167 | // } |
| sam_grove | 5:a517950927fe | 168 | // |
| sam_grove | 5:a517950927fe | 169 | // /** |
| sam_grove | 5:a517950927fe | 170 | // * Set the Network of the HWDevice |
| sam_grove | 5:a517950927fe | 171 | // * |
| sam_grove | 5:a517950927fe | 172 | // * @param netmask The networkMask to use. |
| sam_grove | 5:a517950927fe | 173 | // * |
| sam_grove | 5:a517950927fe | 174 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 175 | // */ |
| sam_grove | 5:a517950927fe | 176 | // virtual int setNetworkMask(const char *netmask) const { |
| sam_grove | 5:a517950927fe | 177 | // return 0; |
| sam_grove | 5:a517950927fe | 178 | // }; |
| sam_grove | 5:a517950927fe | 179 | // |
| sam_grove | 5:a517950927fe | 180 | // /** |
| sam_grove | 5:a517950927fe | 181 | // * Get the current network mask. |
| sam_grove | 5:a517950927fe | 182 | // * |
| sam_grove | 5:a517950927fe | 183 | // * \returns a pointer to a string containing the network mask on success, 0 on failure. |
| sam_grove | 5:a517950927fe | 184 | // */ |
| sam_grove | 5:a517950927fe | 185 | // virtual char *getNetworkMask(void) const { |
| sam_grove | 5:a517950927fe | 186 | // return 0; |
| sam_grove | 5:a517950927fe | 187 | // } |
| sam_grove | 5:a517950927fe | 188 | // |
| sam_grove | 5:a517950927fe | 189 | // /** |
| sam_grove | 5:a517950927fe | 190 | // * Set the MAC Address of the HWDevice |
| sam_grove | 5:a517950927fe | 191 | // * |
| sam_grove | 5:a517950927fe | 192 | // * @param mac The static IP address to use |
| sam_grove | 5:a517950927fe | 193 | // * |
| sam_grove | 5:a517950927fe | 194 | // * \returns 1 on success, 0 on failure |
| sam_grove | 5:a517950927fe | 195 | // */ |
| sam_grove | 5:a517950927fe | 196 | // virtual int setMACAddress(const char *mac) const { |
| sam_grove | 5:a517950927fe | 197 | // return 0; |
| sam_grove | 5:a517950927fe | 198 | // }; |
| sam_grove | 5:a517950927fe | 199 | // |
| sam_grove | 5:a517950927fe | 200 | // /** |
| sam_grove | 5:a517950927fe | 201 | // * Get the devices MAC address. |
| sam_grove | 5:a517950927fe | 202 | // * |
| sam_grove | 5:a517950927fe | 203 | // * \returns a pointer to a string containing the mac address on success, 0 on failure. |
| sam_grove | 5:a517950927fe | 204 | // */ |
| sam_grove | 5:a517950927fe | 205 | // virtual char *getMACAddress(void) const { |
| sam_grove | 5:a517950927fe | 206 | // return 0; |
| sam_grove | 5:a517950927fe | 207 | // } |
| sam_grove | 5:a517950927fe | 208 | // |
| sam_grove | 5:a517950927fe | 209 | // /** |
| sam_grove | 5:a517950927fe | 210 | // * Get the current status of the interface connection. |
| sam_grove | 5:a517950927fe | 211 | // * |
| sam_grove | 5:a517950927fe | 212 | // * \returns true if connected, false otherwise. |
| sam_grove | 5:a517950927fe | 213 | // */ |
| sam_grove | 5:a517950927fe | 214 | // virtual bool isConnected(void) const { |
| sam_grove | 5:a517950927fe | 215 | // return false; |
| sam_grove | 5:a517950927fe | 216 | // } |
| sam_grove | 5:a517950927fe | 217 | // |
| sam_grove | 5:a517950927fe | 218 | //private: |
| sam_grove | 5:a517950927fe | 219 | // char IPAddress[15]; // "xxx.xxx.xxx.xxx" IPV4 |
| sam_grove | 5:a517950927fe | 220 | // char NetworkMask[15]; // "xxx.xxx.xxx.xxx" |
| sam_grove | 5:a517950927fe | 221 | // char Gateway[15]; // "xxx.xxx.xxx.xxx" |
| sam_grove | 5:a517950927fe | 222 | // char MacAddress[17]; // "xx:xx:xx:xx:xx:xx" |
| sam_grove | 5:a517950927fe | 223 | // bool connected; |
| sam_grove | 5:a517950927fe | 224 | // |
| sam_grove | 5:a517950927fe | 225 | //}; |
| austin.blackstone@arm.com | 4:844719bff1b1 | 226 | |
| mbedAustin | 2:3a8e1a6c0524 | 227 | |
| mbedAustin | 2:3a8e1a6c0524 | 228 | #endif // HWNAME_DRIVER_H |
