Skip to content

Commit 3ad3ebe

Browse files
author
Mika Leppänen
committed
Added new configuration parameters to Wi-SUN interface
1 parent b6370b4 commit 3ad3ebe

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
@@ -172,6 +172,7 @@ class InterfaceNanostack : public virtual NetworkInterface {
172172
char mac_addr_str[24];
173173
mbed::Callback<void(nsapi_event_t, intptr_t)> _connection_status_cb;
174174
bool _blocking;
175+
bool _configured = false;
175176
};
176177

177178
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
@@ -52,6 +52,28 @@ class WisunInterface : public MeshInterfaceNanostack {
5252
* */
5353
mesh_error_t set_network_name(char *network_name);
5454

55+
/**
56+
* \brief Get Wi-SUN network name.
57+
*
58+
* Function reads network name from mbed-mesh-api.
59+
*
60+
* \param network_name Network name as NUL terminated string. Must have space for 33 characters (string and null terminator).
61+
* \return MESH_ERROR_NONE on success.
62+
* \return MESH_ERROR_UNKNOWN in case of failure.
63+
* */
64+
mesh_error_t get_network_name(char *network_name);
65+
66+
/**
67+
* \brief Validate Wi-SUN network name.
68+
*
69+
* Function validates network name. Function can be used to test that values that will be used on set function are valid.
70+
*
71+
* \param network_name Network name as NUL terminated string. Can't exceed 32 characters and can't be NULL.
72+
* \return MESH_ERROR_NONE on success.
73+
* \return MESH_ERROR_UNKNOWN in case of failure.
74+
* */
75+
mesh_error_t validate_network_name(char *network_name);
76+
5577
/**
5678
* \brief Set Wi-SUN network regulatory domain, operating class and operating mode.
5779
*
@@ -69,6 +91,252 @@ class WisunInterface : public MeshInterfaceNanostack {
6991
* */
7092
mesh_error_t set_network_regulatory_domain(uint8_t regulatory_domain = 0xff, uint8_t operating_class = 0xff, uint8_t operating_mode = 0xff);
7193

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

139408
#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
@@ -62,6 +62,43 @@ typedef enum {
6262
MESH_DEVICE_TYPE_THREAD_MINIMAL_END_DEVICE /*<! Thread minimal end device */
6363
} mesh_device_type_t;
6464

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

0 commit comments

Comments
 (0)