modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of NetworkSocketAPI by NetworkSocketAPI

Committer:
austin.blackstone@arm.com
Date:
Mon Jun 01 16:21:59 2015 -0500
Revision:
6:7437289cb2e9
Parent:
5:fa54ca1af2cd
Child:
7:b147c08301be
made all functions pure virtual

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:d35446f60233 1 /* NetworkInterface Base Class
sam_grove 0:d35446f60233 2 * Copyright (c) 2015 ARM Limited
sam_grove 0:d35446f60233 3 *
sam_grove 0:d35446f60233 4 * Licensed under the Apache License, Version 2.0 (the "License");
sam_grove 0:d35446f60233 5 * you may not use this file except in compliance with the License.
sam_grove 0:d35446f60233 6 * You may obtain a copy of the License at
sam_grove 0:d35446f60233 7 *
sam_grove 0:d35446f60233 8 * http://www.apache.org/licenses/LICENSE-2.0
sam_grove 0:d35446f60233 9 *
sam_grove 0:d35446f60233 10 * Unless required by applicable law or agreed to in writing, software
sam_grove 0:d35446f60233 11 * distributed under the License is distributed on an "AS IS" BASIS,
sam_grove 0:d35446f60233 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sam_grove 0:d35446f60233 13 * See the License for the specific language governing permissions and
sam_grove 0:d35446f60233 14 * limitations under the License.
sam_grove 0:d35446f60233 15 */
sam_grove 3:167dd63981b6 16
bridadan 1:291a9d61e58a 17 #ifndef NETWORKINTERFACE_H
bridadan 1:291a9d61e58a 18 #define NETWORKINTERFACE_H
bridadan 1:291a9d61e58a 19
bridadan 1:291a9d61e58a 20 /** NetworkInterface class.
bridadan 1:291a9d61e58a 21 * This is a common interface that is shared between all hardware that connect
bridadan 1:291a9d61e58a 22 * to a network over IP.
bridadan 1:291a9d61e58a 23 */
sam_grove 3:167dd63981b6 24 class NetworkInterface
sam_grove 3:167dd63981b6 25 {
bridadan 1:291a9d61e58a 26 public:
austin.blackstone@arm.com 4:f09f0932db4a 27
austin.blackstone@arm.com 4:f09f0932db4a 28 /**
bridadan 1:291a9d61e58a 29 * Initialize the network interface with DHCP.
bridadan 1:291a9d61e58a 30 *
bridadan 1:291a9d61e58a 31 * \returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 32 */
sam_grove 3:167dd63981b6 33 virtual int init(void) const = 0;
sam_grove 3:167dd63981b6 34
bridadan 1:291a9d61e58a 35 /**
bridadan 1:291a9d61e58a 36 * Initialize the network interface with a static IP address.
bridadan 1:291a9d61e58a 37 *
bridadan 1:291a9d61e58a 38 * @param ip The static IP address to use
bridadan 1:291a9d61e58a 39 * @param mask The IP address mask
bridadan 1:291a9d61e58a 40 * @param gateway The gateway to use
bridadan 1:291a9d61e58a 41 *
bridadan 1:291a9d61e58a 42 * \returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 43 */
austin.blackstone@arm.com 6:7437289cb2e9 44 int init(const char *ip, const char *mask, const char *gateway) const = 0;
sam_grove 3:167dd63981b6 45
sam_grove 3:167dd63981b6 46 /**
sam_grove 3:167dd63981b6 47 * Start the interface, using DHCP if needed.
sam_grove 3:167dd63981b6 48 *
sam_grove 3:167dd63981b6 49 * @param timeout_ms Time in miliseconds to wait while attempting to connect before timing out
sam_grove 3:167dd63981b6 50 *
sam_grove 3:167dd63981b6 51 * \returns 0 on success, a negative number on failure
sam_grove 3:167dd63981b6 52 */
austin.blackstone@arm.com 6:7437289cb2e9 53 virtual int connect(const unsigned int timeout_ms=15000) const = 0;
sam_grove 3:167dd63981b6 54
bridadan 1:291a9d61e58a 55 /**
bridadan 1:291a9d61e58a 56 * Stop the interface, bringing down dhcp if necessary.
bridadan 1:291a9d61e58a 57 *
bridadan 1:291a9d61e58a 58 * \returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 59 */
sam_grove 3:167dd63981b6 60 virtual int disconnect(void) const = 0;
sam_grove 3:167dd63981b6 61
bridadan 1:291a9d61e58a 62 /**
bridadan 1:291a9d61e58a 63 * Get the current IP address.
bridadan 1:291a9d61e58a 64 *
bridadan 1:291a9d61e58a 65 * \returns a pointer to a string containing the IP address.
bridadan 1:291a9d61e58a 66 */
sam_grove 3:167dd63981b6 67 virtual char *getIPAddress(void) const = 0;
sam_grove 3:167dd63981b6 68
bridadan 1:291a9d61e58a 69 /**
bridadan 1:291a9d61e58a 70 * Get the current gateway address.
bridadan 1:291a9d61e58a 71 *
bridadan 1:291a9d61e58a 72 * \returns a pointer to a string containing the gateway address.
bridadan 1:291a9d61e58a 73 */
sam_grove 3:167dd63981b6 74 virtual char *getGateway(void) const = 0;
sam_grove 3:167dd63981b6 75
sam_grove 3:167dd63981b6 76
bridadan 1:291a9d61e58a 77 /**
bridadan 1:291a9d61e58a 78 * Get the current network mask.
bridadan 1:291a9d61e58a 79 *
bridadan 1:291a9d61e58a 80 * \returns a pointer to a string containing the network mask.
bridadan 1:291a9d61e58a 81 */
sam_grove 3:167dd63981b6 82 virtual char *getNetworkMask(void) const = 0;
sam_grove 3:167dd63981b6 83
sam_grove 3:167dd63981b6 84 /**
sam_grove 3:167dd63981b6 85 * Get the devices MAC address.
sam_grove 3:167dd63981b6 86 *
sam_grove 3:167dd63981b6 87 * \returns a pointer to a string containing the mac address.
sam_grove 3:167dd63981b6 88 */
sam_grove 3:167dd63981b6 89 virtual char *getMACAddress(void) const = 0;
sam_grove 3:167dd63981b6 90
bridadan 1:291a9d61e58a 91 /**
bridadan 1:291a9d61e58a 92 * Get the current status of the interface connection.
bridadan 1:291a9d61e58a 93 *
bridadan 1:291a9d61e58a 94 * \returns true if connected, false otherwise.
bridadan 1:291a9d61e58a 95 */
sam_grove 3:167dd63981b6 96 virtual int isConnected(void) const = 0;
bridadan 1:291a9d61e58a 97 };
bridadan 1:291a9d61e58a 98
bridadan 1:291a9d61e58a 99 #endif