Skip to content

Commit fcac235

Browse files
author
Mika Leppänen
committed
Added new start methods to Wi-SUN BR with WisunInterface parameter and deprecated the old ones
Previously WisunBorderRouter start() used NetworkInterface type for mesh interface, although only WisunInterface type is possible for the call. Added a new overloads of the start with the WisunInterface as mesh interface type and deprecated the old ones. This makes the calls stricter about the interface type and safer. It also allows to remove the reinterpret_cast that causes compiler warning on ARM compiler.
1 parent 62b57ab commit fcac235

File tree

2 files changed

+57
-4
lines changed

2 files changed

+57
-4
lines changed

features/nanostack/mbed-mesh-api/mbed-mesh-api/WisunBorderRouter.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,21 @@ class WisunBorderRouter {
8686
* \return MESH_ERROR_NONE on success.
8787
* \return MESH_ERROR_UNKNOWN in case of failure.
8888
* */
89+
mesh_error_t start(WisunInterface *mesh_if, NetworkInterface *backbone_if);
90+
91+
/**
92+
* \brief Start Wi-SUN Border Router
93+
*
94+
* Starts Wi-SUN Border Router and routing between the mesh and backbone interfaces. Network interfaces
95+
* must be initialized and connected before calling the start. Backbone interface can be either Ethernet
96+
* (EMAC) or Cellular.
97+
*
98+
* \param mesh_if Wi-SUN mesh network interface
99+
* \param backbone_if Backbone network interface
100+
* \return MESH_ERROR_NONE on success.
101+
* \return MESH_ERROR_UNKNOWN in case of failure.
102+
* */
103+
MBED_DEPRECATED_SINCE("mbed-os-5.15.8", "Using NetworkInterface type for mesh_if is deprecated, use WisunInterface instead")
89104
mesh_error_t start(NetworkInterface *mesh_if, NetworkInterface *backbone_if);
90105

91106
/**
@@ -100,6 +115,21 @@ class WisunBorderRouter {
100115
* \return MESH_ERROR_NONE on success.
101116
* \return MESH_ERROR_UNKNOWN in case of failure.
102117
* */
118+
mesh_error_t start(WisunInterface *mesh_if, OnboardNetworkStack::Interface *backbone_if);
119+
120+
/**
121+
* \brief Start Wi-SUN Border Router
122+
*
123+
* Starts Wi-SUN Border Router and routing between the mesh and backbone interfaces. Mesh network interface
124+
* must be initialized and connected before calling the start. Backbone OnboardNetworkStack::Interface must
125+
* be brought up before calling the start. Backbone interface can be either Ethernet (EMAC) or Cellular (PPP).
126+
*
127+
* \param mesh_if Wi-SUN mesh network interface
128+
* \param backbone_if Backbone OnboardNetworkStack::Interface interface
129+
* \return MESH_ERROR_NONE on success.
130+
* \return MESH_ERROR_UNKNOWN in case of failure.
131+
* */
132+
MBED_DEPRECATED_SINCE("mbed-os-5.15.8", "Using NetworkInterface type for mesh_if is deprecated, use WisunInterface instead")
103133
mesh_error_t start(NetworkInterface *mesh_if, OnboardNetworkStack::Interface *backbone_if);
104134

105135
/**

features/nanostack/mbed-mesh-api/source/WisunBorderRouter.cpp

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,17 @@ mesh_error_t WisunBorderRouter::start(NetworkInterface *mesh_if, NetworkInterfac
4040
return MESH_ERROR_PARAM;
4141
}
4242

43-
InterfaceNanostack *nano_mesh_if = reinterpret_cast<InterfaceNanostack *>(mesh_if);
44-
int8_t mesh_if_id = nano_mesh_if->get_interface_id();
43+
WisunInterface *wisun_mesh_if = reinterpret_cast<WisunInterface *>(mesh_if);
44+
return start(wisun_mesh_if, backbone_if);
45+
}
46+
47+
mesh_error_t WisunBorderRouter::start(WisunInterface *mesh_if, NetworkInterface *backbone_if)
48+
{
49+
if (mesh_if == NULL || backbone_if == NULL) {
50+
return MESH_ERROR_PARAM;
51+
}
52+
53+
int8_t mesh_if_id = mesh_if->get_interface_id();
4554
if (mesh_if_id < 0) {
4655
return MESH_ERROR_UNKNOWN;
4756
}
@@ -71,10 +80,24 @@ mesh_error_t WisunBorderRouter::start(NetworkInterface *mesh_if, NetworkInterfac
7180
return MESH_ERROR_NONE;
7281
}
7382

83+
7484
mesh_error_t WisunBorderRouter::start(NetworkInterface *mesh_if, OnboardNetworkStack::Interface *backbone_if)
7585
{
76-
InterfaceNanostack *nano_mesh_if = reinterpret_cast<InterfaceNanostack *>(mesh_if);
77-
int8_t mesh_if_id = nano_mesh_if->get_interface_id();
86+
if (mesh_if == NULL || backbone_if == NULL) {
87+
return MESH_ERROR_PARAM;
88+
}
89+
90+
WisunInterface *wisun_mesh_if = reinterpret_cast<WisunInterface *>(mesh_if);
91+
return start(wisun_mesh_if, backbone_if);
92+
}
93+
94+
mesh_error_t WisunBorderRouter::start(WisunInterface *mesh_if, OnboardNetworkStack::Interface *backbone_if)
95+
{
96+
if (mesh_if == NULL || backbone_if == NULL) {
97+
return MESH_ERROR_PARAM;
98+
}
99+
100+
int8_t mesh_if_id = mesh_if->get_interface_id();
78101
if (mesh_if_id < 0) {
79102
return MESH_ERROR_UNKNOWN;
80103
}

0 commit comments

Comments
 (0)