Commit 78b7a7a9a8634a78d5cd60dcfcb8f54c253dfd10

Authored by vrobic
1 parent 0c314053

affectation rang selon rssi et lqi

RIOT/examples/dynamic_app/Makefile
1 1 # name of your application
2   -APPLICATION = real_time_app
  2 +APPLICATION = dynamic_app
3 3  
4 4 # If no BOARD is found in the environment, use this default:
5 5 BOARD ?= native
... ...
RIOT/sys/include/net/gnrc/rpl/structs.h
... ... @@ -74,7 +74,14 @@ extern "C" {
74 74 * RFC6550, section 6.7.1, RPL Control Message Option Generic Format
75 75 * </a>
76 76 */
77   -
  77 +/*******************************************************************/
  78 +//ADDED BY PFE7 2017
  79 +typedef struct __attribute__((packed)) {
  80 + uint8_t rssi; /*Received Signal Strength Indication*/
  81 + uint8_t lqi; /*Link Quality Indicator*/
  82 +} rpl_metric_container;
  83 +//\ADDED BY PFE7 2017
  84 +/*******************************************************************/
78 85  
79 86  
80 87 typedef struct __attribute__((packed)) {
... ... @@ -97,6 +104,11 @@ typedef struct __attribute__((packed)) {
97 104 uint8_t flags; /**< unused */
98 105 uint8_t reserved; /**< reserved */
99 106 ipv6_addr_t dodag_id; /**< id of the dodag */
  107 + /*******************************************************************/
  108 + //ADDED BY PFE7 2017
  109 + rpl_metric_container mc;
  110 + //\ADDED BY PFE7 2017
  111 + /*******************************************************************/
100 112 } gnrc_rpl_dio_t;
101 113  
102 114 /**
... ... @@ -218,8 +230,13 @@ struct gnrc_rpl_parent {
218 230 uint16_t rank; /**< rank of the parent */
219 231 gnrc_rpl_dodag_t *dodag; /**< DODAG the parent belongs to */
220 232 uint32_t lifetime; /**< lifetime of this parent in seconds */
221   - double link_metric; /**< metric of the link */
222   - uint8_t link_metric_type; /**< type of the metric */
  233 + /*******************************************************************/
  234 + //ADDED BY PFE7 2017
  235 + rpl_metric_container mc;
  236 + //double link_metric; /**< metric of the link */
  237 + //uint8_t link_metric_type; /**< type of the metric */
  238 + //\ADDED BY PFE7 2017
  239 + /*******************************************************************/
223 240 };
224 241  
225 242 /**
... ... @@ -278,7 +295,11 @@ struct gnrc_rpl_instance {
278 295 uint16_t max_rank_inc; /**< max increase in the rank */
279 296 int8_t cleanup; /**< cleanup time in seconds */
280 297 };
281   -
  298 +/*******************************************************************/
  299 +//ADDED BY PFE7 2017
  300 +static uint8_t dodag_insert;
  301 +//\ADDED BY PFE7 2017
  302 +/*******************************************************************/
282 303 #ifdef __cplusplus
283 304 }
284 305 #endif
... ...
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl.c
... ... @@ -25,7 +25,13 @@
25 25 #include "net/gnrc/rpl/p2p.h"
26 26 #include "net/gnrc/rpl/p2p_dodag.h"
27 27 #endif
  28 +/*******************************************************************/
  29 +//ADDED BY PFE7 2017
  30 +//#include "../../boards/stm32f4discovery/include/board.h"
  31 +//#include "../../boards/stm32f4discovery/include/periph_conf.h"
28 32  
  33 +//\ADDED BY PFE7 2017
  34 +/*******************************************************************/
29 35 #define ENABLE_DEBUG (0)
30 36 #include "debug.h"
31 37  
... ... @@ -103,7 +109,7 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_
103 109 }
104 110  
105 111 dodag = &inst->dodag;
106   -
  112 +
107 113 dodag->dtsn = 1;
108 114 dodag->prf = 0;
109 115 dodag->dio_interval_doubl = GNRC_RPL_DEFAULT_DIO_INTERVAL_DOUBLINGS;
... ... @@ -119,7 +125,6 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_
119 125 #ifndef GNRC_RPL_WITHOUT_PIO
120 126 dodag->dio_opts |= GNRC_RPL_REQ_DIO_OPT_PREFIX_INFO;
121 127 #endif
122   -
123 128 trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL,
124 129 GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min),
125 130 dodag->dio_interval_doubl, dodag->dio_redun);
... ... @@ -133,12 +138,11 @@ static void _receive(gnrc_pktsnip_t *icmpv6)
133 138 ipv6_hdr_t *ipv6_hdr;
134 139 icmpv6_hdr_t *icmpv6_hdr;
135 140 kernel_pid_t iface = KERNEL_PID_UNDEF;
136   -
  141 +
137 142 assert(icmpv6 != NULL);
138 143  
139 144 ipv6 = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_IPV6);
140 145 netif = gnrc_pktsnip_search_type(icmpv6, GNRC_NETTYPE_NETIF);
141   -
142 146 assert(ipv6 != NULL);
143 147  
144 148 if (netif) {
... ... @@ -156,6 +160,14 @@ static void _receive(gnrc_pktsnip_t *icmpv6)
156 160 break;
157 161 case GNRC_RPL_ICMPV6_CODE_DIO:
158 162 DEBUG("RPL: DIO received\n");
  163 + /*******************************************************************/
  164 + //ADDED BY PFE7 2017
  165 + gnrc_netif_hdr_t* header=(gnrc_netif_hdr_t*)netif->data;
  166 + gnrc_rpl_dio_t * dio_msg=(gnrc_rpl_dio_t *)(icmpv6_hdr + 1);
  167 + dio_msg->mc.rssi=header->rssi;
  168 + dio_msg->mc.lqi=header->lqi;
  169 + //\ADDED BY PFE7 2017
  170 + /*******************************************************************/
159 171 gnrc_rpl_recv_DIO((gnrc_rpl_dio_t *)(icmpv6_hdr + 1), iface, &ipv6_hdr->src,
160 172 &ipv6_hdr->dst, byteorder_ntohs(ipv6_hdr->len));
161 173 break;
... ...
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_control_messages.c
... ... @@ -477,7 +477,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
477 477 /* new instance and DODAG */
478 478  
479 479 if (byteorder_ntohs(dio->rank) == GNRC_RPL_INFINITE_RANK) {
480   - DEBUG("RPL: ignore INFINITE_RANK DIO when we are not yet part of this DODAG\n");
  480 + puts("RPL: ignore INFINITE_RANK DIO when we are not yet part of this DODAG\n");
481 481 gnrc_rpl_instance_remove(inst);
482 482 return;
483 483 }
... ... @@ -500,7 +500,7 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
500 500 gnrc_rpl_parent_t *parent = NULL;
501 501  
502 502 if (!gnrc_rpl_parent_add_by_addr(dodag, src, &parent) && (parent == NULL)) {
503   - DEBUG("RPL: Could not allocate new parent.\n");
  503 + puts("RPL: Could not allocate new parent.\n");
504 504 gnrc_rpl_instance_remove(inst);
505 505 return;
506 506 }
... ... @@ -508,7 +508,14 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
508 508 dodag->version = dio->version_number;
509 509 dodag->grounded = dio->g_mop_prf >> GNRC_RPL_GROUNDED_SHIFT;
510 510 dodag->prf = dio->g_mop_prf & GNRC_RPL_PRF_MASK;
511   -
  511 + /*******************************************************************/
  512 + //ADDED BY PFE7 2017
  513 + parent->mc.rssi=dio->mc.rssi;
  514 + parent->mc.lqi=dio->mc.lqi;
  515 + //\ADDED BY PFE7 2017
  516 + /*******************************************************************/
  517 +
  518 +
512 519 parent->rank = byteorder_ntohs(dio->rank);
513 520  
514 521 uint32_t included_opts = 0;
... ... @@ -625,7 +632,12 @@ void gnrc_rpl_recv_DIO(gnrc_rpl_dio_t *dio, kernel_pid_t iface, ipv6_addr_t *src
625 632  
626 633 /* gnrc_rpl_parent_add_by_addr should have set this already */
627 634 assert(parent != NULL);
628   -
  635 + /*******************************************************************/
  636 + //ADDED BY PFE7 2017
  637 + parent->mc.rssi=dio->mc.rssi;
  638 + parent->mc.lqi=dio->mc.lqi;
  639 + //\ADDED BY PFE7 2017
  640 + /*******************************************************************/
629 641 parent->rank = byteorder_ntohs(dio->rank);
630 642  
631 643 gnrc_rpl_parent_update(dodag, parent);
... ...
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
... ... @@ -288,6 +288,7 @@ void gnrc_rpl_parent_update(gnrc_rpl_dodag_t *dodag, gnrc_rpl_parent_t *parent)
288 288 }
289 289  
290 290 if (_gnrc_rpl_find_preferred_parent(dodag) == NULL) {
  291 + puts("local repair");
291 292 gnrc_rpl_local_repair(dodag);
292 293 }
293 294 }
... ... @@ -308,6 +309,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
308 309 gnrc_rpl_parent_t *elt, *tmp;
309 310  
310 311 if (dodag->parents == NULL) {
  312 + puts("NULL 1");
311 313 return NULL;
312 314 }
313 315  
... ... @@ -316,6 +318,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
316 318 }
317 319  
318 320 if (new_best->rank == GNRC_RPL_INFINITE_RANK) {
  321 + puts("NULL 2");
319 322 return NULL;
320 323 }
321 324  
... ... @@ -346,8 +349,9 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
346 349 #endif
347 350  
348 351 }
349   -
  352 + printf("AVmy_rank : %d\n",dodag->my_rank);
350 353 dodag->my_rank = dodag->instance->of->calc_rank(dodag->parents, 0);
  354 + printf("my_rank : %d\n",dodag->my_rank);
351 355 if (dodag->my_rank != old_rank) {
352 356 trickle_reset_timer(&dodag->trickle);
353 357 }
... ...
RIOT/sys/net/gnrc/routing/rpl/of0.c
... ... @@ -54,25 +54,39 @@ uint16_t calc_rank(gnrc_rpl_parent_t *parent, uint16_t base_rank)
54 54 {
55 55 if (base_rank == 0) {
56 56 if (parent == NULL) {
  57 + puts("pas parent");
57 58 return GNRC_RPL_INFINITE_RANK;
58 59 }
59   -
  60 + puts("if1");
60 61 base_rank = parent->rank;
  62 +
61 63 }
62 64  
63 65 uint16_t add;
64 66  
65 67 if (parent != NULL) {
66   - add = parent->dodag->instance->min_hop_rank_inc;
  68 + puts("if2");
  69 + //add = parent->dodag->instance->min_hop_rank_inc;
  70 + /*******************************************************************/
  71 + //ADDED BY PFE7 2017
  72 +
  73 + add = 256 - (parent->mc.rssi + parent->mc.lqi)/10;
  74 + parent->dodag->instance->min_hop_rank_inc=add;
  75 + printf("add= %u\n",add);
  76 +
  77 + //\ADDED BY PFE7 2017
  78 + /*******************************************************************/
67 79 }
68 80 else {
  81 + puts("else1");
69 82 add = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
  83 +
70 84 }
71 85  
72 86 if ((base_rank + add) < base_rank) {
  87 + puts("b_r + add < br");
73 88 return GNRC_RPL_INFINITE_RANK;
74 89 }
75   -
76 90 return base_rank + add;
77 91 }
78 92  
... ...