Skip to content

Commit bd5e913

Browse files
committed
Separate Stack/Interface concept into two distinct classes
1 parent a4f1071 commit bd5e913

File tree

7 files changed

+46
-28
lines changed

7 files changed

+46
-28
lines changed

CellularStack.h renamed to CellularInterface.h

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

2020
#include "NetworkStack.h"
2121

22-
/** CellularStack class
22+
/** CellularInterface class
2323
*
2424
* Common interface that is shared between ethernet hardware
2525
*/
26-
class CellularStack : public NetworkStack
26+
class CellularInterface
2727
{
2828
public:
2929
/** Start the interface
@@ -40,6 +40,12 @@ class CellularStack : public NetworkStack
4040
* @return 0 on success, negative error code on failure
4141
*/
4242
virtual int disconnect() = 0;
43+
44+
/** Get the local MAC address
45+
*
46+
* @return Null-terminated representation of the local MAC address
47+
*/
48+
virtual const char *get_mac_address() = 0;
4349
};
4450

4551
#endif

EthernetStack.h renamed to EthernetInterface.h

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

2020
#include "NetworkStack.h"
2121

22-
/** EthernetStack class
22+
/** EthernetInterface class
2323
*
2424
* Common interface that is shared between ethernet hardware.
2525
*/
26-
class EthernetStack : public NetworkStack
26+
class EthernetInterface
2727
{
2828
public:
2929
/** Start the interface
@@ -37,6 +37,12 @@ class EthernetStack : public NetworkStack
3737
* @return 0 on success, negative error code on failure
3838
*/
3939
virtual int disconnect() = 0;
40+
41+
/** Get the local MAC address
42+
*
43+
* @return Null-terminated representation of the local MAC address
44+
*/
45+
virtual const char *get_mac_address() = 0;
4046
};
4147

4248
#endif

MeshStack.h renamed to MeshInterface.h

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

2020
#include "NetworkStack.h"
2121

22-
/** MeshStack class
22+
/** MeshInterface class
2323
*
2424
* Common interface that is shared between mesh hardware
2525
*/
26-
class MeshStack : public NetworkStack
26+
class MeshInterface
2727
{
2828
public:
2929
/** Start the interface
@@ -37,6 +37,12 @@ class MeshStack : public NetworkStack
3737
* @return 0 on success, negative on failure
3838
*/
3939
virtual int disconnect() = 0;
40+
41+
/** Get the local MAC address
42+
*
43+
* @return Null-terminated representation of the local MAC address
44+
*/
45+
virtual const char *get_mac_address() = 0;
4046
};
4147

4248
#endif

NetworkStack.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,6 @@ enum nsapi_option_t {
7777
NSAPI_RCVBUF, /*!< Sets recv buffer size */
7878
};
7979

80-
/** Maximum size of MAC address representation
81-
*/
82-
#define NSAPI_MAC_SIZE 18
83-
84-
/** Maximum number of bytes for MAC address
85-
*/
86-
#define NSAPI_MAC_BYTES 6
87-
8880

8981
/** NetworkStack class
9082
*
@@ -105,12 +97,6 @@ class NetworkStack
10597
*/
10698
virtual const char *get_ip_address() = 0;
10799

108-
/** Get the local MAC address
109-
*
110-
* @return Null-terminated representation of the local MAC address
111-
*/
112-
virtual const char *get_mac_address() = 0;
113-
114100
/** Translates a hostname to an IP address
115101
*
116102
* The hostname may be either a domain name or an IP address. If the

Socket.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ int Socket::close()
5252
if (!_socket) {
5353
return 0;
5454
}
55-
55+
5656
_iface->socket_attach(_socket, 0, 0);
57-
57+
5858
void *volatile socket = _socket;
5959
_socket = 0;
6060
return _iface->socket_close(socket);

SocketAddress.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828
*/
2929
#define NSAPI_IP_BYTES NSAPI_IPv6_BYTES
3030

31+
/** Maximum size of MAC address representation
32+
*/
33+
#define NSAPI_MAC_SIZE 18
34+
35+
/** Maximum number of bytes for MAC address
36+
*/
37+
#define NSAPI_MAC_BYTES 6
38+
3139
/** Enum of IP address versions
3240
*
3341
* The IP version specifies the type of an IP address.

WiFiStack.h renamed to WiFiInterface.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* WiFiStack
1+
/* WiFiInterface
22
* Copyright (c) 2015 ARM Limited
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,11 +33,11 @@ enum nsapi_security_t {
3333
NSAPI_SECURITY_WPA2, /*!< phrase conforms to WPA2 */
3434
};
3535

36-
/** WiFiStack class
36+
/** WiFiInterface class
3737
*
3838
* Common interface that is shared between WiFi devices
3939
*/
40-
class WiFiStack : public NetworkStack
40+
class WiFiInterface
4141
{
4242
public:
4343
/** Start the interface
@@ -57,6 +57,12 @@ class WiFiStack : public NetworkStack
5757
* @return 0 on success, negative error code on failure
5858
*/
5959
virtual int disconnect() = 0;
60+
61+
/** Get the local MAC address
62+
*
63+
* @return Null-terminated representation of the local MAC address
64+
*/
65+
virtual const char *get_mac_address() = 0;
6066
};
6167

6268
#endif

0 commit comments

Comments
 (0)