modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of NetworkSocketAPI by NetworkSocketAPI

Committer:
sam_grove
Date:
Wed Jul 15 15:41:11 2015 +0000
Revision:
10:50b0a3f840df
Parent:
7:b147c08301be
Child:
11:47c32687a44c
Spacing update

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
sam_grove 7:b147c08301be 20 #include "stdint.h"
sam_grove 7:b147c08301be 21
bridadan 1:291a9d61e58a 22 /** NetworkInterface class.
sam_grove 7:b147c08301be 23 This is a common interface that is shared between all hardware that connect
sam_grove 7:b147c08301be 24 to a network over IP.
bridadan 1:291a9d61e58a 25 */
sam_grove 3:167dd63981b6 26 class NetworkInterface
sam_grove 3:167dd63981b6 27 {
bridadan 1:291a9d61e58a 28 public:
austin.blackstone@arm.com 4:f09f0932db4a 29
sam_grove 7:b147c08301be 30 /** Initialize the network interface with DHCP.
sam_grove 7:b147c08301be 31 @returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 32 */
sam_grove 7:b147c08301be 33 virtual int32_t init(void) const = 0;
sam_grove 3:167dd63981b6 34
sam_grove 7:b147c08301be 35 /** Initialize the network interface with a static IP address.
sam_grove 7:b147c08301be 36 @param ip The static IP address to use
sam_grove 7:b147c08301be 37 @param mask The IP address mask
sam_grove 7:b147c08301be 38 @param gateway The gateway to use
sam_grove 7:b147c08301be 39 @returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 40 */
sam_grove 7:b147c08301be 41 virtual int32_t init(const char *ip, const char *mask, const char *gateway) const = 0;
sam_grove 7:b147c08301be 42
sam_grove 3:167dd63981b6 43
sam_grove 7:b147c08301be 44 /** Start the interface, using DHCP if needed.
sam_grove 7:b147c08301be 45 @param timeout_ms Time in miliseconds to wait while attempting to connect before timing out
sam_grove 7:b147c08301be 46 @returns 0 on success, a negative number on failure
sam_grove 3:167dd63981b6 47 */
sam_grove 10:50b0a3f840df 48 virtual int32_t connect(uint32_t timeout_ms = 15000) const = 0;
sam_grove 3:167dd63981b6 49
sam_grove 7:b147c08301be 50 /** Stop the interface, bringing down dhcp if necessary.
sam_grove 7:b147c08301be 51 @returns 0 on success, a negative number on failure
bridadan 1:291a9d61e58a 52 */
sam_grove 7:b147c08301be 53 virtual int32_t disconnect(void) const = 0;
sam_grove 3:167dd63981b6 54
sam_grove 7:b147c08301be 55 /** Get the current IP address.
sam_grove 7:b147c08301be 56 @returns a pointer to a string containing the IP address.
bridadan 1:291a9d61e58a 57 */
sam_grove 3:167dd63981b6 58 virtual char *getIPAddress(void) const = 0;
sam_grove 3:167dd63981b6 59
sam_grove 7:b147c08301be 60 /** Get the current gateway address.
sam_grove 7:b147c08301be 61 @returns a pointer to a string containing the gateway address.
bridadan 1:291a9d61e58a 62 */
sam_grove 3:167dd63981b6 63 virtual char *getGateway(void) const = 0;
sam_grove 3:167dd63981b6 64
sam_grove 3:167dd63981b6 65
sam_grove 7:b147c08301be 66 /** Get the current network mask.
sam_grove 7:b147c08301be 67 @returns a pointer to a string containing the network mask.
bridadan 1:291a9d61e58a 68 */
sam_grove 3:167dd63981b6 69 virtual char *getNetworkMask(void) const = 0;
sam_grove 3:167dd63981b6 70
sam_grove 7:b147c08301be 71 /** Get the devices MAC address.
sam_grove 7:b147c08301be 72 @returns a pointer to a string containing the mac address.
sam_grove 3:167dd63981b6 73 */
sam_grove 3:167dd63981b6 74 virtual char *getMACAddress(void) const = 0;
sam_grove 3:167dd63981b6 75
sam_grove 7:b147c08301be 76 /** Get the current status of the interface connection.
sam_grove 7:b147c08301be 77 @returns true if connected, a negative number on failure
bridadan 1:291a9d61e58a 78 */
sam_grove 7:b147c08301be 79 virtual int32_t isConnected(void) const = 0;
bridadan 1:291a9d61e58a 80 };
bridadan 1:291a9d61e58a 81
bridadan 1:291a9d61e58a 82 #endif