Skip to content

Commit d36a0b6

Browse files
committed
Revised documentation for Interface classes
1 parent aa2357a commit d36a0b6

File tree

9 files changed

+134
-48
lines changed

9 files changed

+134
-48
lines changed

CellularInterface.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/* CellularInterface
2+
* Copyright (c) 2015 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef CELLULAR_INTERFACE_H
18+
#define CELLULAR_INTERFACE_H
19+
20+
#include "NetworkInterface.h"
21+
22+
/** CellularInterface class
23+
*
24+
* Common interface that is shared between ethernet hardware
25+
*/
26+
class CellularInterface : public NetworkInterface
27+
{
28+
public:
29+
/** Start the interface
30+
*
31+
* @param apn Optional name of the network to connect to
32+
* @param username Optional username for your APN
33+
* @param password Optional password for your APN
34+
* @return 0 on success, negative error code on failure
35+
*/
36+
virtual int connect(const char *apn = 0, const char *username = 0, const char *password = 0) = 0;
37+
38+
/** Stop the interface
39+
*
40+
* @return 0 on success, negative error code on failure
41+
*/
42+
virtual int disconnect() = 0;
43+
};
44+
45+
#endif

EthernetInterface.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* EthernetInterface
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,18 +20,21 @@
2020
#include "NetworkInterface.h"
2121

2222
/** EthernetInterface class
23-
* Common interface that is shared between ethernet hardware
23+
*
24+
* Common interface that is shared between ethernet hardware.
2425
*/
2526
class EthernetInterface : public NetworkInterface
2627
{
2728
public:
2829
/** Start the interface
29-
* @return 0 on success, negative on failure
30+
*
31+
* @return 0 on success, negative error code on failure
3032
*/
3133
virtual int connect() = 0;
3234

3335
/** Stop the interface
34-
* @return 0 on success, negative on failure
36+
*
37+
* @return 0 on success, negative error code on failure
3538
*/
3639
virtual int disconnect() = 0;
3740
};

MeshInterface.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* MeshInterface
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,17 +20,20 @@
2020
#include "NetworkInterface.h"
2121

2222
/** MeshInterface class
23-
* Common interface that is shared between ethernet hardware
23+
*
24+
* Common interface that is shared between mesh hardware
2425
*/
2526
class MeshInterface : public NetworkInterface
2627
{
2728
public:
2829
/** Start the interface
30+
*
2931
* @return 0 on success, negative on failure
3032
*/
3133
virtual int connect() = 0;
3234

3335
/** Stop the interface
36+
*
3437
* @return 0 on success, negative on failure
3538
*/
3639
virtual int disconnect() = 0;

NetworkInterface.h

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ enum nsapi_error_t {
4646
* The socket protocol specifies a particular protocol to
4747
* be used with a newly created socket.
4848
*
49-
* @enum protocol_t
49+
* @enum nsapi_protocol_t
5050
*/
5151
enum nsapi_protocol_t {
5252
NSAPI_TCP, /*!< Socket is of TCP type */
@@ -74,26 +74,29 @@ class NetworkInterface
7474
public:
7575
virtual ~NetworkInterface() {};
7676

77-
/** Get the internally stored IP address
77+
/** Get the local IP address
7878
*
79-
* @return IP address of the interface or null if not yet connected
79+
* @return Null-terminated representation of the local IP address
80+
* or null if not yet connected
8081
*/
8182
virtual const char *get_ip_address() = 0;
8283

83-
/** Get the internally stored MAC address
84+
/** Get the local MAC address
8485
*
85-
* @return MAC address of the interface
86+
* @return Null-terminated representation of the local MAC address
8687
*/
8788
virtual const char *get_mac_address() = 0;
8889

89-
/** Translates a host name to an IP address
90+
/** Translates a hostname to an IP address
9091
*
91-
* The host name may be either a domain name or an IP address.
92-
* If no stack-specific DNS resolution is provided, the host name
92+
* The hostname may be either a domain name or an IP address. If the
93+
* hostname is an IP address, no network transactions will be performed.
94+
*
95+
* If no stack-specific DNS resolution is provided, the hostname
9396
* will be resolve using a UDP socket on the stack.
9497
*
9598
* @param address Destination for the host SocketAddress
96-
* @param host Host name to lookup
99+
* @param host Hostname to resolve
97100
* @return 0 on success, negative error code on failure
98101
*/
99102
virtual int gethostbyname(SocketAddress *address, const char *host);

SocketAddress.h

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* SocketAddress
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,8 +28,11 @@
2828
*/
2929
#define NSAPI_IP_BYTES NSAPI_IPv6_BYTES
3030

31-
/** Enum of address families
32-
* @enum nsapi_family_t
31+
/** Enum of IP address versions
32+
*
33+
* The IP version specifies the type of an IP address.
34+
*
35+
* @enum nsapi_version_t
3336
*/
3437
enum nsapi_version_t {
3538
NSAPI_IPv4, /*!< Address is IPv4 */
@@ -56,74 +59,92 @@ enum nsapi_version_t {
5659
class NetworkInterface;
5760

5861

59-
/** A general address class composed of the IP address and optional port
62+
/** SocketAddress class
63+
*
64+
* Representation of an IP address and port pair.
6065
*/
6166
class SocketAddress {
6267
public:
63-
/** SocketAddress construction using DNS resolution
64-
* @param iface NetworkInterface to use for DNS resolution
65-
* @param addr Null-terminated hostname that will be resolved
68+
/** Create a SocketAddress from a hostname and port
69+
*
70+
* The hostname may be either a domain name or an IP address. If the
71+
* hostname is an IP address, no network transactions will be performed.
72+
*
73+
* On failure, the IP address and port will be set to zero
74+
*
75+
* @param iface Network stack to use for DNS resolution
76+
* @param host Hostname to resolve
6677
* @param port Optional 16-bit port
67-
* @note on failure, IP address and port will be set to zero
6878
*/
69-
SocketAddress(NetworkInterface *iface, const char *addr, uint16_t port = 0);
79+
SocketAddress(NetworkInterface *iface, const char *host, uint16_t port = 0);
7080

71-
/** SocketAddress construction
72-
* @param addr Null-terminated IP address
81+
/** Create a SocketAddress from an IP address and port
82+
*
83+
* @param host Null-terminated representation of the IP address
7384
* @param port Optional 16-bit port
7485
*/
7586
SocketAddress(const char *addr = 0, uint16_t port = 0);
7687

77-
/** SocketAddress construction
78-
* @param bytes Bytes to assign to address in big-endian order
88+
/** Create a SocketAddress from a raw IP address and port
89+
*
90+
* @param bytes Raw IP address in big-endian order
7991
* @param version IP address version, NSAPI_IPv4 or NSAPI_IPv6
8092
* @param port Optional 16-bit port
8193
*/
8294
SocketAddress(const void *bytes, nsapi_version_t version, uint16_t port = 0);
8395

84-
/** SocketAddress construction
85-
* @param addr SocketAddress to copy
96+
/** Create a SocketAddress from another SocketAddress
97+
*
98+
* @param address SocketAddress to copy
8699
*/
87100
SocketAddress(const SocketAddress &addr);
88101

89102
/** Set the IP address
90-
* @param addr Null-terminated string representing the IP address
103+
*
104+
* @param addr Null-terminated represention of the IP address
91105
*/
92106
void set_ip_address(const char *addr);
93107

94-
/** Set the IP address bytes directly
95-
* @param bytes Bytes to assign to address in big-endian order
108+
/** Set the raw IP address
109+
*
110+
* @param bytes Raw IP address in big-endian order
96111
* @param version IP address version, NSAPI_IPv4 or NSAPI_IPv6
97112
*/
98113
void set_ip_bytes(const void *bytes, nsapi_version_t version);
99114

100115
/** Set the port
116+
*
101117
* @param port 16-bit port
102118
*/
103119
void set_port(uint16_t port);
104120

105121
/** Get the IP address
106-
* @return The string representation of the IP Address
122+
*
123+
* @return Null-terminated representation of the IP Address
107124
*/
108125
const char *get_ip_address() const;
109126

110-
/** Get the IP address bytes directly
111-
* @return IP address bytes
127+
/** Get the raw IP address
128+
*
129+
* @return Raw IP address in big-endian order
112130
*/
113131
const void *get_ip_bytes() const;
114132

115-
/** Get the type of the IP address
133+
/** Get the IP address version
134+
*
116135
* @return IP address version, NSAPI_IPv4 or NSAPI_IPv6
117136
*/
118137
nsapi_version_t get_ip_version() const;
119138

120139
/** Get the port
140+
*
121141
* @return The 16-bit port
122142
*/
123143
uint16_t get_port() const;
124144

125-
/** Determine if address is all zeros
126-
* @return True if address is not zero address
145+
/** Test if address is zero
146+
*
147+
* @return True if address is not zero
127148
*/
128149
operator bool() const;
129150

TCPServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* TCPServer
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");

TCPSocket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* TCPSocket
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -53,7 +53,7 @@ class TCPSocket : public Socket {
5353
* Initiates a connection to a remote server specified by either
5454
* a domain name or an IP address and a port.
5555
*
56-
* @param host Host name of the remote host
56+
* @param host Hostname of the remote host
5757
* @param port Port of the remote host
5858
* @return 0 on success, negative error code on failure
5959
*/

UDPSocket.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* UDPSocket
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -58,7 +58,7 @@ class UDPSocket : public Socket {
5858
* non-blocking or times out, NSAPI_ERROR_WOULD_BLOCK is returned
5959
* immediately.
6060
*
61-
* @param host Host name of the remote host
61+
* @param host Hostname of the remote host
6262
* @param port Port of the remote host
6363
* @param data Buffer of data to send to the host
6464
* @param size Size of the buffer in bytes

WiFiInterface.h

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Socket
1+
/* WiFiInterface
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,7 +19,12 @@
1919

2020
#include "NetworkInterface.h"
2121

22-
/** Enum for WiFi encryption types
22+
/** Enum of WiFi encryption types
23+
*
24+
* The security type specifies a particular security to use when
25+
* connected to a WiFi network
26+
*
27+
* @enum nsapi_protocol_t
2328
*/
2429
enum nsapi_security_t {
2530
NSAPI_SECURITY_NONE = 0, /*!< open access point */
@@ -29,21 +34,27 @@ enum nsapi_security_t {
2934
};
3035

3136
/** WiFiInterface class
37+
*
3238
* Common interface that is shared between WiFi devices
3339
*/
3440
class WiFiInterface : public NetworkInterface
3541
{
3642
public:
3743
/** Start the interface
44+
*
45+
* Attempts to connect to a WiFi network. If passphrase is invalid,
46+
* NSAPI_ERROR_AUTH_ERROR is returned.
47+
*
3848
* @param ssid Name of the network to connect to
3949
* @param pass Security passphrase to connect to the network
4050
* @param security Type of encryption for connection
41-
* @return 0 on success, negative on failure
51+
* @return 0 on success, negative error code on failure
4252
*/
4353
virtual int connect(const char *ssid, const char *pass, nsapi_security_t security = NSAPI_SECURITY_NONE) = 0;
4454

4555
/** Stop the interface
46-
* @return 0 on success, negative on failure
56+
*
57+
* @return 0 on success, negative error code on failure
4758
*/
4859
virtual int disconnect() = 0;
4960
};

0 commit comments

Comments
 (0)