Skip to content

Commit 071911b

Browse files
author
Mika Leppänen
committed
Changed nanostack API network size to be a range of values
1 parent 4756be4 commit 071911b

File tree

5 files changed

+32
-60
lines changed

5 files changed

+32
-60
lines changed

nanostack/ws_management_api.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ int ws_management_regulatory_domain_validate(
229229
*
230230
* timing parameters follows the specification example from Wi-SUN specification
231231
*
232-
* Default value: automatic
232+
* Default value: medium
233233
* small network size: hundreds of devices
234234
* Large network size: thousands of devices
235235
* automatic: when discovering the network network size is learned
@@ -243,7 +243,8 @@ int ws_management_regulatory_domain_validate(
243243
* above function calls after network size change.
244244
*
245245
* \param interface_id Network interface ID.
246-
* \param network_size define from NETWORK_SIZE_*.
246+
* \param network_size Network size in hundreds of devices, certificate or automatic.
247+
* See NETWORK_SIZE_ definition.
247248
*
248249
* \return 0, Init OK.
249250
* \return <0 Init fail.
@@ -256,7 +257,8 @@ int ws_management_network_size_set(
256257
* Get timing parameters related to network size.
257258
*
258259
* \param interface_id Network interface ID.
259-
* \param network_size define from NETWORK_SIZE_*.
260+
* \param network_size Network size in hundreds of devices, certificate or automatic.
261+
* See NETWORK_SIZE_ definition.
260262
*
261263
* \return 0, OK.
262264
* \return <0 Fail.
@@ -269,7 +271,8 @@ int ws_management_network_size_get(
269271
* Validate timing parameters related to network size.
270272
*
271273
* \param interface_id Network interface ID.
272-
* \param network_size define from NETWORK_SIZE_*.
274+
* \param network_size Network size in hundreds of devices, certificate or automatic.
275+
* See NETWORK_SIZE_ definition.
273276
*
274277
* \return 0, OK.
275278
* \return <0 Fail.

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2660,7 +2660,7 @@ static void ws_bootstrap_rpl_scan_start(protocol_interface_info_entry_t *cur)
26602660
// routers wait until RPL root is contacted
26612661
ws_bootstrap_state_change(cur, ER_RPL_SCAN);
26622662
//For Large network and medium shuold do passive scan
2663-
if (cur->ws_info->cfg->gen.network_size == NETWORK_SIZE_LARGE || cur->ws_info->cfg->gen.network_size == NETWORK_SIZE_MEDIUM) {
2663+
if (cur->ws_info->cfg->gen.network_size > NETWORK_SIZE_SMALL) {
26642664
// Set timeout for check to 30 -60 seconds
26652665
cur->bootsrap_state_machine_cnt = randLIB_get_random_in_range(WS_RPL_DIS_INITIAL_TIMEOUT / 2, WS_RPL_DIS_INITIAL_TIMEOUT);
26662666
}

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -219,14 +219,6 @@ int8_t ws_cfg_network_size_validate(ws_gen_cfg_t *cfg, ws_gen_cfg_t *new_cfg)
219219
ws_cfg_to_get((ws_cfgs_t **) &cfg, (ws_cfgs_t *) new_cfg, NULL, (ws_cfgs_t *) &ws_cfg.gen, 0, 0);
220220

221221
if (cfg->network_size != new_cfg->network_size) {
222-
if (new_cfg->network_size != NETWORK_SIZE_LARGE &&
223-
new_cfg->network_size != NETWORK_SIZE_MEDIUM &&
224-
new_cfg->network_size != NETWORK_SIZE_SMALL &&
225-
new_cfg->network_size != NETWORK_SIZE_CERTIFICATE &&
226-
new_cfg->network_size != NETWORK_SIZE_AUTOMATIC) {
227-
return CFG_SETTINGS_ERROR_NW_SIZE_CONF;
228-
}
229-
230222
return CFG_SETTINGS_CHANGED;
231223
}
232224

@@ -259,27 +251,14 @@ int8_t ws_cfg_network_size_set(protocol_interface_info_entry_t *cur, ws_gen_cfg_
259251

260252
ws_cfg_network_size_config_set_size set_function = NULL;
261253

262-
switch (cfg->network_size) {
263-
case NETWORK_SIZE_SMALL:
264-
/* fall through */
265-
case NETWORK_SIZE_AUTOMATIC:
266-
set_function = ws_cfg_network_size_config_set_small;
267-
break;
268-
269-
case NETWORK_SIZE_MEDIUM:
270-
set_function = ws_cfg_network_size_config_set_medium;
271-
break;
272-
273-
case NETWORK_SIZE_LARGE:
274-
set_function = ws_cfg_network_size_config_set_large;
275-
break;
276-
277-
case NETWORK_SIZE_CERTIFICATE:
278-
set_function = ws_cfg_network_size_config_set_certificate;
279-
break;
280-
281-
default:
282-
break;
254+
if (cfg->network_size == NETWORK_SIZE_CERTIFICATE) {
255+
set_function = ws_cfg_network_size_config_set_certificate;
256+
} else if (cfg->network_size <= NETWORK_SIZE_SMALL || cfg->network_size == NETWORK_SIZE_AUTOMATIC) {
257+
set_function = ws_cfg_network_size_config_set_small;
258+
} else if (cfg->network_size <= NETWORK_SIZE_MEDIUM) {
259+
set_function = ws_cfg_network_size_config_set_medium;
260+
} else {
261+
set_function = ws_cfg_network_size_config_set_large;
283262
}
284263

285264
// Overrides the values on the new configuration

source/6LoWPAN/ws/ws_common.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -396,21 +396,19 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
396396
uint32_t ws_common_latency_estimate_get(protocol_interface_info_entry_t *cur)
397397
{
398398
uint32_t latency = 0;
399+
uint8_t network_size = cur->ws_info->cfg->gen.network_size;
399400

400-
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
401+
if (network_size == NETWORK_SIZE_AUTOMATIC) {
402+
network_size = cur->ws_info->pan_information.pan_size / 100;
403+
}
404+
405+
if (network_size <= NETWORK_SIZE_SMALL) {
401406
// handles also NETWORK_SIZE_CERTIFICATE
402407
latency = 8000;
403-
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_MEDIUM) {
408+
} else if (network_size <= NETWORK_SIZE_MEDIUM) {
404409
latency = 16000;
405-
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_LARGE) {
410+
} else {
406411
latency = 32000;
407-
} else { /* <= NETWORK_SIZE_AUTOMATIC */
408-
// Make assumption based on current pan size
409-
if (cur->ws_info->pan_information.pan_size < 50) {
410-
latency = 8000;
411-
} else {
412-
latency = 32000;
413-
}
414412
}
415413

416414
return latency;
@@ -424,23 +422,21 @@ uint32_t ws_common_datarate_get(protocol_interface_info_entry_t *cur)
424422
uint32_t ws_common_network_size_estimate_get(protocol_interface_info_entry_t *cur)
425423
{
426424
uint32_t network_size_estimate = 0;
425+
uint8_t network_size = cur->ws_info->cfg->gen.network_size;
427426

428-
if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_SMALL) {
427+
if (network_size == NETWORK_SIZE_AUTOMATIC) {
428+
network_size = cur->ws_info->pan_information.pan_size / 100;
429+
}
430+
431+
if (network_size <= NETWORK_SIZE_SMALL) {
429432
// tens of devices (now 30), handles also NETWORK_SIZE_CERTIFICATE
430433
network_size_estimate = 30;
431-
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_MEDIUM) {
434+
} else if (network_size <= NETWORK_SIZE_MEDIUM) {
432435
// hundreds of devices (now 300)
433436
network_size_estimate = 300;
434-
} else if (cur->ws_info->cfg->gen.network_size <= NETWORK_SIZE_LARGE) {
437+
} else {
435438
// huge amount of devices (now 1000)
436439
network_size_estimate = 1000;
437-
} else { /* <= NETWORK_SIZE_AUTOMATIC */
438-
// Make assumption based on current pan size
439-
if (cur->ws_info->pan_information.pan_size < 50) {
440-
network_size_estimate = 50;
441-
} else {
442-
network_size_estimate = 1000;
443-
}
444440
}
445441

446442
return network_size_estimate;

test/nanostack/unittest/6LoWPAN/ws_cfg_settings/test_ws_cfg_settings.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,6 @@ bool test_ws_cfg_network_size_functions_1()
511511
return false;
512512
}
513513

514-
// Invalid setting
515-
cfg.network_size = 0xEE;
516-
if (ws_cfg_network_size_validate(NULL, &cfg) != -10) {
517-
return false;
518-
}
519-
520514
// Modified setting
521515
cfg.network_size = NETWORK_SIZE_SMALL;
522516
if (ws_cfg_network_size_validate(NULL, &cfg) != 1) {

0 commit comments

Comments
 (0)