Skip to content

Commit cfda4a4

Browse files
author
Mika Leppänen
committed
Added new configuration parameters to Wi-SUN interface
1 parent 9a8c9e2 commit cfda4a4

File tree

6 files changed

+594
-165
lines changed

6 files changed

+594
-165
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ class InterfaceNanostack : public virtual NetworkInterface {
163163
char mac_addr_str[24] {};
164164
mbed::Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
165165
bool _blocking = true;
166+
bool _configured = false;
166167
};
167168

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

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

Lines changed: 269 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,28 @@ class WisunInterface final : public MeshInterfaceNanostack {
4343
* */
4444
mesh_error_t set_network_name(char *network_name);
4545

46+
/**
47+
* \brief Get Wi-SUN network name.
48+
*
49+
* Function reads network name from mbed-mesh-api.
50+
*
51+
* \param network_name Network name as NUL terminated string. Must have space for 33 characters (string and null terminator).
52+
* \return MESH_ERROR_NONE on success.
53+
* \return MESH_ERROR_UNKNOWN in case of failure.
54+
* */
55+
mesh_error_t get_network_name(char *network_name);
56+
57+
/**
58+
* \brief Validate Wi-SUN network name.
59+
*
60+
* Function validates network name. Function can be used to test that values that will be used on set function are valid.
61+
*
62+
* \param network_name Network name as NUL terminated string. Can't exceed 32 characters and can't be NULL.
63+
* \return MESH_ERROR_NONE on success.
64+
* \return MESH_ERROR_UNKNOWN in case of failure.
65+
* */
66+
mesh_error_t validate_network_name(char *network_name);
67+
4668
/**
4769
* \brief Set Wi-SUN network regulatory domain, operating class and operating mode.
4870
*
@@ -60,6 +82,252 @@ class WisunInterface final : public MeshInterfaceNanostack {
6082
* */
6183
mesh_error_t set_network_regulatory_domain(uint8_t regulatory_domain = 0xff, uint8_t operating_class = 0xff, uint8_t operating_mode = 0xff);
6284

85+
/**
86+
* \brief Get Wi-SUN network regulatory domain, operating class and operating mode.
87+
*
88+
* Function reads regulatory_domain, operating_class and operating_mode from mbed-mesh-api.
89+
*
90+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
91+
* \param operating_class Values defined in Wi-SUN PHY-specification.
92+
* \param operating_mode Values defined in Wi-SUN PHY-specification.
93+
* \return MESH_ERROR_NONE on success.
94+
* \return MESH_ERROR_UNKNOWN in case of failure.
95+
* */
96+
mesh_error_t get_network_regulatory_domain(uint8_t *regulatory_domain, uint8_t *operating_class, uint8_t *operating_mode);
97+
98+
/**
99+
* \brief Validate Wi-SUN network regulatory domain, operating class and operating mode.
100+
*
101+
* Function validates regulatory_domain, operating_class and operating_mode. Function can be used to test that values that will
102+
* be used on set function are valid.
103+
*
104+
* \param regulatory_domain Values defined in Wi-SUN PHY-specification.
105+
* \param operating_class Values defined in Wi-SUN PHY-specification.
106+
* \param operating_mode Values defined in Wi-SUN PHY-specification.
107+
* \return MESH_ERROR_NONE on success.
108+
* \return MESH_ERROR_UNKNOWN in case of failure.
109+
* */
110+
mesh_error_t validate_network_regulatory_domain(uint8_t regulatory_domain, uint8_t operating_class, uint8_t operating_mode);
111+
112+
/**
113+
* \brief Set Wi-SUN network size.
114+
*
115+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
116+
* If device is already connected to the Wi-SUN network then device will restart network discovery after
117+
* changing the network size.
118+
*
119+
* Default value: medium
120+
* Small network size: less than hundred devices
121+
* Medium network size: hundreds of devices
122+
* Large network size: thousands of devices
123+
* Certificate: used on testing
124+
*
125+
* When network size is changed, it will override all or some of the following configuration values:
126+
* - Timing settings set by set_timing_parameters() of the Wi-SUN interface.
127+
* - RPL settings set by rpl_parameters_set() of the Border Router interface.
128+
*
129+
* When network size is changed, and if timing or RPL values should be other than defaults set by stack for the network size,
130+
* they need to set again using above function calls.
131+
*
132+
* \param network_size Network size in hundreds of devices (e.g. 1200 devices is 12), 0x00 for network size certificate.
133+
* \return MESH_ERROR_NONE on success.
134+
* \return MESH_ERROR_UNKNOWN in case of failure.
135+
* */
136+
mesh_error_t set_network_size(uint8_t network_size);
137+
138+
/**
139+
* \brief Get Wi-SUN network size.
140+
*
141+
* Function reads network size from mbed-mesh-api.
142+
*
143+
* \param network_size Network size in hundreds of devices, 0x00 for network size certificate.
144+
* \return MESH_ERROR_NONE on success.
145+
* \return MESH_ERROR_UNKNOWN in case of failure.
146+
* */
147+
mesh_error_t get_network_size(uint8_t *network_size);
148+
149+
/**
150+
* \brief Validate Wi-SUN network size.
151+
*
152+
* Function validates network size from mbed-mesh-api. Function can be used to test that values that will
153+
* be used on set function are valid.
154+
*
155+
* \param network_size Network size in hundreds of devices, 0x00 for network size certificate.
156+
* \return MESH_ERROR_NONE on success.
157+
* \return MESH_ERROR_UNKNOWN in case of failure.
158+
* */
159+
mesh_error_t validate_network_size(uint8_t network_size);
160+
161+
/**
162+
* \brief Set Wi-SUN FHSS channel mask
163+
*
164+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
165+
* If device is already connected to the Wi-SUN network then settings take effect right away.
166+
*
167+
* \param channel_mask Values defined in Wi-SUN management API. Channel mask bit field.
168+
* \return MESH_ERROR_NONE on success.
169+
* \return MESH_ERROR_UNKNOWN in case of failure.
170+
* */
171+
mesh_error_t set_channel_mask(uint32_t channel_mask[8]);
172+
173+
/**
174+
* \brief Get Wi-SUN FHSS channel mask
175+
*
176+
* Function reads FHSS channel mask from mbed-mesh-api.
177+
*
178+
* \param channel_mask Values defined in Wi-SUN management API. Channel mask bit field.
179+
* \return MESH_ERROR_NONE on success.
180+
* \return MESH_ERROR_UNKNOWN in case of failure.
181+
* */
182+
mesh_error_t get_channel_mask(uint32_t *channel_mask);
183+
184+
/**
185+
* \brief Validate Wi-SUN FHSS channel mask
186+
*
187+
* Function validates FHSS channel mask. Function can be used to test that values that will
188+
* be used on set function are valid.
189+
*
190+
* \param channel_mask Values defined in Wi-SUN management API. Channel mask bit field.
191+
* \return MESH_ERROR_NONE on success.
192+
* \return MESH_ERROR_UNKNOWN in case of failure.
193+
* */
194+
mesh_error_t validate_channel_mask(uint32_t channel_mask[8]);
195+
196+
/**
197+
* \brief Set Wi-SUN FHSS unicast channel function parameters
198+
*
199+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
200+
* If device is already connected to the Wi-SUN network then device will restart network discovery after
201+
* changing the channel function, fixed channel or dwell interval.
202+
*
203+
* Function overwrites parameters defined by Mbed OS configuration.
204+
*
205+
* \param channel_function Channel function. Fixed, TR51CF, DH1CF or vendor defined.
206+
* \param fixed_channel Used channel when channel function is fixed channel. Use 0xffff when fixed channel function not on use.
207+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1. Use 0x00 to use leave parameter unchanged.
208+
* \return MESH_ERROR_NONE on success.
209+
* \return MESH_ERROR_UNKNOWN in case of failure.
210+
* */
211+
mesh_error_t set_unicast_channel_function(mesh_channel_function_t channel_function, uint16_t fixed_channel = 0xffff, uint8_t dwell_interval = 0x00);
212+
213+
/**
214+
* \brief Get Wi-SUN FHSS unicast channel function parameters
215+
*
216+
* Function reads FHSS unicast channel function parameters from mbed-mesh-api.
217+
*
218+
* \param channel_function Channel function. Fixed, TR51CF, DH1CF or vendor defined.
219+
* \param fixed_channel Used channel when channel function is fixed channel.
220+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1.
221+
* \return MESH_ERROR_NONE on success.
222+
* \return MESH_ERROR_UNKNOWN in case of failure.
223+
* */
224+
mesh_error_t get_unicast_channel_function(mesh_channel_function_t *channel_function, uint16_t *fixed_channel, uint8_t *dwell_interval);
225+
226+
/**
227+
* \brief Validate Wi-SUN FHSS unicast channel function parameters
228+
*
229+
* Function validates FHSS unicast channel function parameters. Function can be used to test that values that will
230+
* be used on set function are valid.
231+
*
232+
* \param channel_function Channel function. Fixed, TR51CF, DH1CF or vendor defined.
233+
* \param fixed_channel Used channel when channel function is fixed channel.
234+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1.
235+
* \return MESH_ERROR_NONE on success.
236+
* \return MESH_ERROR_UNKNOWN in case of failure.
237+
* */
238+
mesh_error_t validate_unicast_channel_function(mesh_channel_function_t channel_function, uint16_t fixed_channel, uint8_t dwell_interval);
239+
240+
/**
241+
* \brief Set Wi-SUN FHSS broadcast channel function parameters
242+
*
243+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
244+
* If device is already connected to the Wi-SUN network then device will restart network discovery after
245+
* changing the channel function, fixed channel, dwell interval or broadcast_interval.
246+
*
247+
* Function overwrites parameters defined by Mbed OS configuration.
248+
*
249+
* \param channel_function Channel function. Fixed, TR51CF, DH1CF or vendor defined.
250+
* \param fixed_channel Used channel when channel function is fixed channel. Use 0xffff when fixed channel function not on use.
251+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1. Use 0x00 to use leave parameter unchanged.
252+
* \param broadcast_interval Used broadcast interval. Use 0x00 to use leave parameter unchanged.
253+
* \return MESH_ERROR_NONE on success.
254+
* \return MESH_ERROR_UNKNOWN in case of failure.
255+
* */
256+
mesh_error_t set_broadcast_channel_function(mesh_channel_function_t channel_function, uint16_t fixed_channel = 0xffff, uint8_t dwell_interval = 0x00, uint32_t broadcast_interval = 0x00);
257+
258+
/**
259+
* \brief Get Wi-SUN FHSS broadcast channel function parameters
260+
*
261+
* Function reads FHSS broadcast channel function parameters from mbed-mesh-api.
262+
*
263+
* \param channel_function Channel function. Fixed, TR51CF, DH1CF or vendor defined.
264+
* \param fixed_channel Used channel when channel function is fixed channel.
265+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1.
266+
* \param broadcast_interval Used broadcast interval.
267+
* \return MESH_ERROR_NONE on success.
268+
* \return MESH_ERROR_UNKNOWN in case of failure.
269+
* */
270+
mesh_error_t get_broadcast_channel_function(mesh_channel_function_t *channel_function, uint16_t *fixed_channel, uint8_t *dwell_interval, uint32_t *broadcast_interval);
271+
272+
/**
273+
* \brief Validate Wi-SUN FHSS broadcast channel function parameters
274+
*
275+
* Function validates FHSS broadcast channel function parameters from mbed-mesh-api. Function can be used to test that values that will
276+
* be used on set function are valid.
277+
*
278+
* \param channel_function Channel function. Fixed, TR51CF, DH1CF or vendor defined.
279+
* \param fixed_channel Used channel when channel function is fixed channel.
280+
* \param dwell_interval Used dwell interval when channel function is TR51 or DH1.
281+
* \param broadcast_interval Used broadcast interval.
282+
* \return MESH_ERROR_NONE on success.
283+
* \return MESH_ERROR_UNKNOWN in case of failure.
284+
* */
285+
mesh_error_t validate_broadcast_channel_function(mesh_channel_function_t channel_function, uint16_t fixed_channel, uint8_t dwell_interval, uint32_t broadcast_interval);
286+
287+
/**
288+
* \brief Set Wi-SUN timing parameters
289+
*
290+
* Function stores new parameters to mbed-mesh-api and uses them when connect() is called next time.
291+
* If device is already connected to the Wi-SUN network then settings take effect right away.
292+
*
293+
* \param disc_trickle_imin Discovery trickle Imin. Range 1-255 seconds. Use 0x00 to use leave parameter unchanged.
294+
* \param disc_trickle_imax Discovery trickle Imax. Range (2-2^8)*Imin. Use 0x00 to use leave parameter unchanged.
295+
* \param disc_trickle_k Discovery trickle k. Use 0x00 to use leave parameter unchanged.
296+
* \param pan_timeout PAN timeout; seconds; Range 60-15300 seconds. Use 0x00 to use leave parameter unchanged.
297+
* \return MESH_ERROR_NONE on success.
298+
* \return MESH_ERROR_UNKNOWN in case of failure.
299+
* */
300+
mesh_error_t set_timing_parameters(uint16_t disc_trickle_imin = 0x00, uint16_t disc_trickle_imax = 0x00, uint8_t disc_trickle_k = 0x00, uint16_t pan_timeout = 0x00);
301+
302+
/**
303+
* \brief Get Wi-SUN timing parameters
304+
*
305+
* Function reads timing parameters from mbed-mesh-api.
306+
*
307+
* \param disc_trickle_imin Discovery trickle Imin. Range 1-255 seconds.
308+
* \param disc_trickle_imax Discovery trickle Imax. Range (2-2^8)*Imin.
309+
* \param disc_trickle_k Discovery trickle k.
310+
* \param pan_timeout PAN timeout; seconds; Range 60-15300 seconds.
311+
* \return MESH_ERROR_NONE on success.
312+
* \return MESH_ERROR_UNKNOWN in case of failure.
313+
* */
314+
mesh_error_t get_timing_parameters(uint16_t *disc_trickle_imin, uint16_t *disc_trickle_imax, uint8_t *disc_trickle_k, uint16_t *pan_timeout);
315+
316+
/**
317+
* \brief Validates Wi-SUN timing parameters
318+
*
319+
* Function validates timing parameters. Function can be used to test that values that will be used on set
320+
* function are valid.
321+
*
322+
* \param disc_trickle_imin Discovery trickle Imin. Range 1-255 seconds.
323+
* \param disc_trickle_imax Discovery trickle Imax. Range (2-2^8)*Imin.
324+
* \param disc_trickle_k Discovery trickle k.
325+
* \param pan_timeout PAN timeout; seconds; Range 60-15300 seconds.
326+
* \return MESH_ERROR_NONE on success.
327+
* \return MESH_ERROR_UNKNOWN in case of failure.
328+
* */
329+
mesh_error_t validate_timing_parameters(uint16_t disc_trickle_imin, uint16_t disc_trickle_imax, uint8_t disc_trickle_k, uint16_t pan_timeout);
330+
63331
/**
64332
* \brief Set own certificate and private key reference to the Wi-SUN network.
65333
*
@@ -125,6 +393,7 @@ class WisunInterface final : public MeshInterfaceNanostack {
125393
protected:
126394
Nanostack::WisunInterface *get_interface() const;
127395
nsapi_error_t do_initialize() override;
396+
virtual nsapi_error_t configure();
128397
};
129398

130399
#endif

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,43 @@ typedef enum {
6464
MESH_DEVICE_TYPE_WISUN_BORDER_ROUTER /*<! Wi-SUN border router */
6565
} mesh_device_type_t;
6666

67+
/**
68+
* Mesh channel function
69+
*/
70+
typedef enum {
71+
MESH_CHANNEL_FUNCTION_FIXED = 0x00,
72+
MESH_CHANNEL_FUNCTION_TR51CF,
73+
MESH_CHANNEL_FUNCTION_DH1CF,
74+
MESH_CHANNEL_FUNCTION_VENDOR_DEFINED
75+
} mesh_channel_function_t;
76+
77+
/**
78+
* Mesh network statistics
79+
*/
80+
typedef struct {
81+
uint32_t rpl_total_memory; /*<! RPL current memory usage total. */
82+
uint16_t etx_1st_parent; /*<! Primary parent ETX. */
83+
uint16_t etx_2nd_parent; /*<! Secondary parent ETX. */
84+
uint32_t asynch_tx_count; /*<! Asynch TX counter */
85+
uint32_t asynch_rx_count; /*<! Asynch RX counter */
86+
} mesh_nw_statistics_t;
87+
88+
/**
89+
* Mesh physical layer statistics
90+
*/
91+
typedef struct {
92+
uint32_t mac_rx_count; /*<! MAC RX packet count. */
93+
uint32_t mac_tx_count; /*<! MAC TX packet count. */
94+
uint32_t mac_bc_rx_count; /*<! MAC broadcast RX packet count. */
95+
uint32_t mac_bc_tx_count; /*<! MAC broadcast TX packet count. */
96+
uint32_t mac_tx_bytes; /*<! MAC TX bytes count. */
97+
uint32_t mac_rx_bytes; /*<! MAC RX bytes count. */
98+
uint32_t mac_tx_failed_count; /*<! MAC TX failed count. */
99+
uint32_t mac_retry_count; /*<! MAC TX retry count. */
100+
uint32_t mac_cca_attempts_count; /*<! MAC CCA attempts count. */
101+
uint32_t mac_failed_cca_count; /*<! MAC failed CCA count. */
102+
} mesh_mac_statistics_t;
103+
67104
#ifdef __cplusplus
68105
}
69106
#endif

0 commit comments

Comments
 (0)