Skip to content

Commit 35d28d4

Browse files
author
Arto Kinnunen
authored
Merge pull request #12657 from mikaleppanen/new_wisun_conf_param
Added new configuration parameters to Wi-SUN network interface and Border Router class
2 parents 3d03b7f + 7709193 commit 35d28d4

13 files changed

+908
-165
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class Nanostack::Interface : public OnboardNetworkStack::Interface, private mbed
8282
};
8383

8484
class Nanostack::MeshInterface : public Nanostack::Interface {
85+
public:
86+
char *get_interface_name(char *buf);
8587
protected:
8688
MeshInterface(NanostackRfPhy &phy) : Interface(phy) { }
8789
NanostackRfPhy &get_phy() const
@@ -172,6 +174,7 @@ class InterfaceNanostack : public virtual NetworkInterface {
172174
char mac_addr_str[24];
173175
mbed::Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
174176
bool _blocking;
177+
bool _configured = false;
175178
};
176179

177180
class MeshInterfaceNanostack : public InterfaceNanostack, public MeshInterface, private mbed::NonCopyable<MeshInterfaceNanostack> {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class Nanostack::EthernetInterface : public Nanostack::Interface {
2929
bool blocking = true);
3030
virtual nsapi_error_t bringdown();
3131

32+
char *get_interface_name(char *buf);
3233
private:
3334
friend class Nanostack;
3435
friend class NanostackEthernetInterface;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class Nanostack::PPPInterface : public Nanostack::Interface {
3232
typedef mbed::Callback<void (uint8_t up, int8_t device_id)> link_state_cb_t;
3333
virtual void set_link_state_changed_callback(link_state_cb_t link_state_cb);
3434

35+
char *get_interface_name(char *buf);
3536
private:
3637
friend class Nanostack;
3738
PPPInterface(NanostackPhy &phy) : Interface(phy), link_state_up(false), enet_tasklet_connected(false) {}
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
/*
2+
* Copyright (c) 2020 ARM Limited. All rights reserved.
3+
* SPDX-License-Identifier: Apache-2.0
4+
* Licensed under the Apache License, Version 2.0 (the License); you may
5+
* 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, WITHOUT
12+
* 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 WISUNBORDERROUTER_H
18+
#define WISUNBORDERROUTER_H
19+
20+
/** Wi-SUN Border Router class
21+
*
22+
* Class can be used to start, stop and configure Wi-SUN Border Router.
23+
*/
24+
class WisunBorderRouter {
25+
public:
26+
27+
/** Create WisunBorderRouter
28+
*
29+
* */
30+
WisunBorderRouter() { }
31+
32+
/**
33+
* \brief Start Wi-SUN Border Router
34+
*
35+
* Starts Wi-SUN Border Router and routing between the mesh and backbone interfaces. Network interfaces
36+
* must be initialized and connected before calling the start. Backbone interface can be either Ethernet
37+
* (EMAC) or Cellular.
38+
*
39+
* \param mesh_if Wi-SUN mesh network interface
40+
* \param backbone_if Backbone network interface
41+
* \return MESH_ERROR_NONE on success.
42+
* \return MESH_ERROR_UNKNOWN in case of failure.
43+
* */
44+
mesh_error_t start(NetworkInterface *mesh_if, NetworkInterface *backbone_if);
45+
46+
/**
47+
* \brief Start Wi-SUN Border Router
48+
*
49+
* Starts Wi-SUN Border Router and routing between the mesh and backbone interfaces. Mesh network interface
50+
* must be initialized and connected before calling the start. Backbone OnboardNetworkStack::Interface must
51+
* be brought up before calling the start. Backbone interface can be either Ethernet (EMAC) or Cellular (PPP).
52+
*
53+
* \param mesh_if Wi-SUN mesh network interface
54+
* \param backbone_if Backbone OnboardNetworkStack::Interface interface
55+
* \return MESH_ERROR_NONE on success.
56+
* \return MESH_ERROR_UNKNOWN in case of failure.
57+
* */
58+
mesh_error_t start(NetworkInterface *mesh_if, OnboardNetworkStack::Interface *backbone_if);
59+
60+
/**
61+
* \brief Stop Wi-SUN Border Router
62+
*
63+
* Stops Wi-SUN Border Router.
64+
*
65+
* */
66+
void stop();
67+
68+
/**
69+
* \brief Set Wi-SUN RPL DIO trickle parameters.
70+
*
71+
* Function stores new parameters to Border Router and uses them when mesh interface connect() is called
72+
* next time. If device is already connected to the Wi-SUN network then device will restart Wi-SUN network after
73+
* changing the RPL DIO trickle parameters. Mesh interface must be initialized before calling this
74+
* function.
75+
*
76+
* \param dio_interval_min DIO trickle timer Imin parameter. Use 0x00 to use leave parameter unchanged.
77+
* \param dio_interval_doublings DIO trickle timer Imax parameter as doublings of Imin. Use 0x00 to use leave parameter unchanged.
78+
* \param dio_redundancy_constant DIO trickle timer redundancy constant. Use 0xff to use leave parameter unchanged.
79+
* \return MESH_ERROR_NONE on success.
80+
* \return MESH_ERROR_UNKNOWN in case of failure.
81+
* */
82+
mesh_error_t set_rpl_parameters(uint8_t dio_interval_min, uint8_t dio_interval_doublings, uint8_t dio_redundancy_constant);
83+
84+
/**
85+
* \brief Get Wi-SUN RPL DIO trickle parameters.
86+
*
87+
* Function reads DIO trickle timer Imin, DIO trickle timer Imax and DIO trickle timer redundancy
88+
* constant from Border Router. Mesh interface must be initialized before calling this function.
89+
*
90+
* \param dio_interval_min DIO trickle timer Imin parameter.
91+
* \param dio_interval_doublings DIO trickle timer Imax parameter as doublings of Imin.
92+
* \param dio_redundancy_constant DIO trickle timer redundancy constant.
93+
* \return MESH_ERROR_NONE on success.
94+
* \return MESH_ERROR_UNKNOWN in case of failure.
95+
* */
96+
mesh_error_t get_rpl_parameters(uint8_t *dio_interval_min, uint8_t *dio_interval_doublings, uint8_t *dio_redundancy_constant);
97+
98+
/**
99+
* \brief Validate Wi-SUN RPL DIO trickle parameters.
100+
*
101+
* Function validates DIO trickle timer Imin, DIO trickle timer Imax and DIO trickle timer redundancy
102+
* constant. Function can be used to test that values that will be used on set function are valid.
103+
* Mesh interface must be initialized before the calling this function.
104+
*
105+
* \param dio_interval_min DIO trickle timer Imin parameter.
106+
* \param dio_interval_doublings DIO trickle timer Imax parameter as doublings of Imin.
107+
* \param dio_redundancy_constant DIO trickle timer redundancy constant.
108+
* \return MESH_ERROR_NONE on success.
109+
* \return MESH_ERROR_UNKNOWN in case of failure.
110+
* */
111+
mesh_error_t validate_rpl_parameters(uint8_t dio_interval_min, uint8_t dio_interval_doublings, uint8_t dio_redundancy_constant);
112+
113+
/**
114+
* \brief Set Wi-SUN PAN configuration parameters.
115+
*
116+
* Function stores new parameters to Border Router and uses them when mesh interface connect() is called
117+
* next time. If device is already connected to the Wi-SUN network then device will restart Wi-SUN network after
118+
* changing the PAN configuration parameters. Mesh interface must be initialized before calling this
119+
* function.
120+
*
121+
* \param pan_id PAN ID. 0xffff will generate the PAN ID on the mesh interface connect() call if not already generated.
122+
* \return MESH_ERROR_NONE on success.
123+
* \return MESH_ERROR_UNKNOWN in case of failure.
124+
* */
125+
mesh_error_t set_pan_configuration(uint16_t pan_id);
126+
127+
/**
128+
* \brief Get Wi-SUN PAN configuration parameters.
129+
*
130+
* Function reads PAN ID from Border Router. Mesh interface must be initialized before calling this function.
131+
*
132+
* \param pan_id PAN ID.
133+
* \return MESH_ERROR_NONE on success.
134+
* \return MESH_ERROR_UNKNOWN in case of failure.
135+
* */
136+
mesh_error_t get_pan_configuration(uint16_t *pan_id);
137+
138+
/**
139+
* \brief Validate Wi-SUN PAN configuration parameters.
140+
*
141+
* Function validates PAN ID. Function can be used to test that values that will be used on set function are valid.
142+
* Mesh interface must be initialized before calling this function.
143+
*
144+
* \param pan_id PAN ID.
145+
* \return MESH_ERROR_NONE on success.
146+
* \return MESH_ERROR_UNKNOWN in case of failure.
147+
* */
148+
mesh_error_t validate_pan_configuration(uint16_t pan_id);
149+
150+
private:
151+
int8_t _mesh_if_id = -1;
152+
153+
};
154+
155+
#endif

0 commit comments

Comments
 (0)