Skip to content

Commit 0ec37a6

Browse files
author
Mika Tervonen
committed
Count the amount of configuration solicits
if count exeeds defined value device goes back to discovery Added check for RPL domain Start advertisements after Routing is ready
1 parent 7406149 commit 0ec37a6

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,7 @@ static void ws_bootstrap_start_configuration_learn(protocol_interface_info_entry
10881088
// Clear all temporary information
10891089
ws_bootstrap_ip_stack_reset(cur);
10901090

1091+
cur->ws_info->pas_requests = 0;
10911092
// Reset advertisement solicit trickle to start discovering network
10921093
trickle_start(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
10931094
trickle_inconsistent_heard(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery);
@@ -1163,7 +1164,9 @@ static uint16_t ws_bootstrap_route_cost_calculate(protocol_interface_info_entry_
11631164
// Find selected parent from RPL
11641165

11651166
struct rpl_instance *best_instance = NULL;
1166-
1167+
if (!cur->rpl_domain) {
1168+
return 0xffff;
1169+
}
11671170
ns_list_foreach(struct rpl_instance, instance, &cur->rpl_domain->instances) {
11681171
best_instance = instance;
11691172
// Select best grounded and lowest rank? But there should be only one really
@@ -1300,7 +1303,6 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
13001303
ws_bootstrap_ip_stack_activate(cur);
13011304
ws_bootstrap_rpl_activate(cur);
13021305
ws_bootstrap_network_start(cur);
1303-
ws_bootstrap_advertise_start(cur);
13041306
// Wait for RPL start
13051307
if (cur->bootsrap_mode == ARM_NWK_BOOTSRAP_MODE_6LoWPAN_BORDER_ROUTER) {
13061308
ws_bootstrap_event_routing_ready(cur);
@@ -1311,6 +1313,7 @@ static void ws_bootstrap_event_handler(arm_event_s *event)
13111313
break;
13121314
case WS_ROUTING_READY:
13131315
tr_info("Routing ready");
1316+
ws_bootstrap_advertise_start(cur);
13141317
ws_bootstrap_state_change(cur, ER_BOOTSRAP_DONE);
13151318
break;
13161319
case WS_ADDRESS_ADDED:
@@ -1449,7 +1452,13 @@ void ws_bootstrap_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t s
14491452
}
14501453
if(trickle_timer(&cur->ws_info->trickle_pan_config_solicit, &trickle_params_pan_discovery, seconds)) {
14511454
// send PAN Configuration solicit
1455+
if (cur->ws_info->pas_requests > PCS_MAX) {
1456+
// if MAX PCS sent restart discovery
1457+
ws_bootstrap_event_discovery_start(cur);
1458+
return;
1459+
}
14521460
tr_info("Send PAN configuration Solicit");
1461+
cur->ws_info->pas_requests++;
14531462
ws_bootstrap_pan_config_solicit(cur);
14541463
}
14551464
if(trickle_timer(&cur->ws_info->trickle_pan_advertisement, &trickle_params_pan_discovery, seconds)) {

source/6LoWPAN/ws/ws_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ typedef struct ws_info_s {
4848
trickle_t trickle_pan_advertisement_solicit;
4949
trickle_t trickle_pan_advertisement;
5050
uint8_t rpl_state; // state from rpl_event_t
51+
uint8_t pas_requests; // Amount of PAN solicits sent
5152
parent_info_t parent_info;
5253
uint32_t pan_version_timer; /**< border router version udate timeout */
5354
uint32_t pan_version_timeout_timer; /**< routers will fallback to previous state after this */

source/6LoWPAN/ws/ws_config.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,4 +74,9 @@ extern int8_t DEVICE_MIN_SENS;
7474
/* Candidate parent Threshold hysteresis
7575
*/
7676
#define CAND_PARENT_HYSTERISIS 3
77-
#endif /* WS_CONFIG_H_ */
77+
78+
/* Maximum amount of Pan Configuration Solicits before restarting Discovery.
79+
*/
80+
#define PCS_MAX 5
81+
82+
#endif /* WS_CONFIG_H_ */

0 commit comments

Comments
 (0)