modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of NetworkSocketAPI by NetworkSocketAPI

Committer:
austin.blackstone@arm.com
Date:
Mon Jun 01 15:21:48 2015 -0500
Revision:
5:fa54ca1af2cd
Parent:
4:f09f0932db4a
Child:
6:7437289cb2e9
moved technology specific implementation to technology specific interface (ie moved security for wifi and ssid/passphrase connect function to the wifi_interface example instead of in the virtual base class

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 */
sam_grove 3:167dd63981b6 44 int init(const char *ip, const char *mask, const char *gateway) const {
sam_grove 3:167dd63981b6 45 return -1;
sam_grove 3:167dd63981b6 46 }
sam_grove 3:167dd63981b6 47
sam_grove 3:167dd63981b6 48 /**
sam_grove 3:167dd63981b6 49 * Start the interface, using DHCP if needed.
sam_grove 3:167dd63981b6 50 *
sam_grove 3:167dd63981b6 51 * @param timeout_ms Time in miliseconds to wait while attempting to connect before timing out
sam_grove 3:167dd63981b6 52 *
sam_grove 3:167dd63981b6 53 * \returns 0 on success, a negative number on failure
sam_grove 3:167dd63981b6 54 */
sam_grove 3:167dd63981b6 55 virtual int connect(const unsigned int timeout_ms=15000) const {
sam_grove 3:167dd63981b6 56 return -1;
sam_grove 3:167dd63981b6 57 }
sam_grove 3:167dd63981b6 58
bridadan 1:291a9d61e58a 59 /**
bridadan 1:291a9d61e58a 60 * Stop the interface, bringing down dhcp if necessary.
bridadan 1:291a9d61e58a 61 *
bridadan 1:291a9d61e58a 62 * \returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 63 */
sam_grove 3:167dd63981b6 64 virtual int disconnect(void) const = 0;
sam_grove 3:167dd63981b6 65
bridadan 1:291a9d61e58a 66 /**
bridadan 1:291a9d61e58a 67 * Get the current IP address.
bridadan 1:291a9d61e58a 68 *
bridadan 1:291a9d61e58a 69 * \returns a pointer to a string containing the IP address.
bridadan 1:291a9d61e58a 70 */
sam_grove 3:167dd63981b6 71 virtual char *getIPAddress(void) const = 0;
sam_grove 3:167dd63981b6 72
bridadan 1:291a9d61e58a 73 /**
bridadan 1:291a9d61e58a 74 * Get the current gateway address.
bridadan 1:291a9d61e58a 75 *
bridadan 1:291a9d61e58a 76 * \returns a pointer to a string containing the gateway address.
bridadan 1:291a9d61e58a 77 */
sam_grove 3:167dd63981b6 78 virtual char *getGateway(void) const = 0;
sam_grove 3:167dd63981b6 79
sam_grove 3:167dd63981b6 80
bridadan 1:291a9d61e58a 81 /**
bridadan 1:291a9d61e58a 82 * Get the current network mask.
bridadan 1:291a9d61e58a 83 *
bridadan 1:291a9d61e58a 84 * \returns a pointer to a string containing the network mask.
bridadan 1:291a9d61e58a 85 */
sam_grove 3:167dd63981b6 86 virtual char *getNetworkMask(void) const = 0;
sam_grove 3:167dd63981b6 87
sam_grove 3:167dd63981b6 88 /**
sam_grove 3:167dd63981b6 89 * Get the devices MAC address.
sam_grove 3:167dd63981b6 90 *
sam_grove 3:167dd63981b6 91 * \returns a pointer to a string containing the mac address.
sam_grove 3:167dd63981b6 92 */
sam_grove 3:167dd63981b6 93 virtual char *getMACAddress(void) const = 0;
sam_grove 3:167dd63981b6 94
bridadan 1:291a9d61e58a 95 /**
bridadan 1:291a9d61e58a 96 * Get the current status of the interface connection.
bridadan 1:291a9d61e58a 97 *
bridadan 1:291a9d61e58a 98 * \returns true if connected, false otherwise.
bridadan 1:291a9d61e58a 99 */
sam_grove 3:167dd63981b6 100 virtual int isConnected(void) const = 0;
bridadan 1:291a9d61e58a 101 };
bridadan 1:291a9d61e58a 102
bridadan 1:291a9d61e58a 103 #endif