Commit 9348015326c9cc380fb957bf83aa08e10107c905

Authored by vrobic
1 parent eb2661bd

modif dynamic_app

RIOT/examples/dynamic_app/main.c
... ... @@ -25,6 +25,7 @@
25 25 #include <inttypes.h>
26 26  
27 27 #include <arpa/inet.h>
  28 +#include "periph/gpio.h"
28 29 #include "../../boards/stm32f4discovery/include/board.h"
29 30 #include "../../boards/stm32f4discovery/include/periph_conf.h"
30 31 #include "net/sock/udp.h"
... ... @@ -83,9 +84,9 @@
83 84 #define _STACKSIZE (THREAD_STACKSIZE_DEFAULT + THREAD_EXTRA_STACKSIZE_PRINTF)
84 85 #define MSG_TYPE_ISR (0x3456)
85 86  
86   -#define PWM_FREQ 100
87   -#define PWM_RES 100
88   -#define DEADLINE 24000
  87 +#define PWM_FREQ 1000
  88 +#define PWM_RES 1000
  89 +#define DEADLINE 15000
89 90  
90 91 static msg_t _main_msg_queue[MAIN_QUEUE_SIZE];
91 92  
... ... @@ -125,11 +126,11 @@ sock_udp_ep_t local = SOCK_IPV6_EP_ANY;
125 126 sock_udp_t sock;
126 127 sock_udp_ep_t local_ntp = SOCK_IPV6_EP_ANY;
127 128 sock_udp_t sock_ntp;
128   -//static ntp_packet_t sntp_packet;
  129 +static ntp_packet_t sntp_packet;
129 130  
130 131 typedef struct tableau {
131   - uint32_t heure_actuelle;
132   - char donnees[2];
  132 + uint32_t heure_actuelle;
  133 + char donnees[2];
133 134 }Data;
134 135  
135 136 /***************** RPL functions *****************/
... ... @@ -138,143 +139,143 @@ int crea_rpl_dodag_root(char *arg1, char *arg2)
138 139 {
139 140 uint8_t instance_id = (uint8_t) atoi(arg1);
140 141 ipv6_addr_t dodag_id;
141   -
  142 +
142 143 if (ipv6_addr_from_str(&dodag_id, arg2) == NULL) {
143 144 puts("error: <dodag_id> must be a valid IPv6 address");
144 145 return 1;
145 146 }
146   -
  147 +
147 148 gnrc_rpl_instance_t *inst = NULL;
148 149 inst = gnrc_rpl_root_init(instance_id, &dodag_id, false, false);
149 150 if (inst == NULL) {
150 151 char addr_str[IPV6_ADDR_MAX_STR_LEN];
151 152 printf("error: could not add DODAG (%s) to instance (%d)\n",
152   - ipv6_addr_to_str(addr_str, &dodag_id, sizeof(addr_str)), instance_id);
  153 + ipv6_addr_to_str(addr_str, &dodag_id, sizeof(addr_str)), instance_id);
153 154 return 1;
154 155 }
155   -
  156 +
156 157 printf("successfully added a new RPL DODAG\n");
157 158 return 0;
158 159 }
159   -int _gnrc_rpl_send_dis(void)
160   -{
161   - gnrc_rpl_send_DIS(NULL, (ipv6_addr_t *) &ipv6_addr_all_rpl_nodes);
162   -
163   - puts("success: send a DIS\n");
164   - return 0;
165   -}
166   -
167 160 /***************** /RPL functions ****************/
168 161  
169   -/*void *sock_time_server_thread(void *arg)
  162 +void *sock_time_server_thread(void *arg)
170 163 {
171 164 (void) arg;
172 165 local_ntp.port = NTP_PORT;
173   -
  166 +
174 167 if (sock_udp_create(&sock_ntp, &local_ntp, NULL, 0) < 0) {
175   - puts("Error creating UDP sock");
176   - return NULL;
177   - }
178   -
179   - while (1) {
180   - sock_udp_ep_t remote;
181   - ssize_t res;
182   -
183   - if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT,
184   - &remote)) >= 0) {
185   - puts("Received a message");
186   - //printf("TT: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
187   -
188   - // printf("%c\n",remote.addr.ipv6[15]);
189   - //xtimer_ticks64_t now = xtimer_now64();
190   - // heure actuelle du serveur
191   - sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec());
192   - sntp_packet.origin.seconds=sntp_packet.transmit.seconds;
193   - sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec());
194   - //printf("heure actuelle : %lu\n",xtimer_now_usec());
195   - //printf("TT2: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
196   - //memset(&sntp_packet, 0, sizeof(sntp_packet));
197   - //ntp_packet_set_vn(&sntp_packet);
198   - //ntp_packet_set_mode(&sntp_packet, NTP_MODE_SERVER);
199   - if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) {
200   - puts("Error sending reply");
201   - }
202   - }
203   - }
  168 + puts("Error creating UDP sock");
  169 + return NULL;
  170 + }
  171 +
  172 + while (1) {
  173 + sock_udp_ep_t remote;
  174 + ssize_t res;
  175 +
  176 + if ((res = sock_udp_recv(&sock_ntp,&sntp_packet, sizeof(sntp_packet), SOCK_NO_TIMEOUT,
  177 + &remote)) >= 0) {
  178 + puts("Received a message");
  179 + //printf("TT: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
  180 +
  181 + // printf("%c\n",remote.addr.ipv6[15]);
  182 + //xtimer_ticks64_t now = xtimer_now64();
  183 + // heure actuelle du serveur
  184 + sntp_packet.receive.seconds=byteorder_htonl( xtimer_now_usec());
  185 + sntp_packet.origin.seconds=sntp_packet.transmit.seconds;
  186 + sntp_packet.transmit.seconds=byteorder_htonl( xtimer_now_usec());
  187 + //printf("heure actuelle : %lu\n",xtimer_now_usec());
  188 + //printf("TT2: %lu\n", byteorder_ntohl(sntp_packet.transmit.seconds));
  189 + //memset(&sntp_packet, 0, sizeof(sntp_packet));
  190 + //ntp_packet_set_vn(&sntp_packet);
  191 + //ntp_packet_set_mode(&sntp_packet, NTP_MODE_SERVER);
  192 + if (sock_udp_send(&sock_ntp, &sntp_packet, sizeof(sntp_packet), &remote) < 0) {
  193 + puts("Error sending reply");
  194 + }
  195 + }
  196 + }
204 197 return NULL;
205   -}*/
  198 +}
206 199  
207 200  
208 201 void *sock_server_thread(void *arg)
209 202 {
210 203 (void) arg;
211 204 Data buf;
212   - // int compteur = 5;
213   - // int deadline;
  205 + int compteur = 5;
  206 + int deadline;
214 207 local.port = 1234;
215 208 sock_udp_ep_t server = { .port = NTP_PORT, .family = AF_INET6 };
216 209 ipv6_addr_from_str((ipv6_addr_t *)&server.addr, "dead:beef::3402");
217 210  
218 211 if (sock_udp_create(&sock, &local, NULL, 0) < 0) {
219   - puts("Error creating UDP sock");
220   - return NULL;
  212 + puts("Error creating UDP sock");
  213 + return NULL;
  214 + }
  215 + if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
  216 + puts("Error in synchronization");
221 217 }
222   - /*if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
223   - puts("Error in synchronization");
224   - return NULL;
225   - }
226   - offset = sntp_get_offset();
227   - printf("offset : %i\n",(int)offset);*/
  218 + offset = sntp_get_offset();
  219 + printf("offset : %i\n",(int)offset);
228 220  
229 221 while (1) {
230   - sock_udp_ep_t remote;
231   - ssize_t res;
232   -
233   - if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), SOCK_NO_TIMEOUT,
234   - &remote)) >= 0) {
235   - puts("Received a message");
236   - //printf("%s\n",buf);
237   - /*if (sock_udp_send(&sock, buf, res, &remote) < 0) {
238   - puts("Error sending reply");
239   - }*/
240   -
241   - /*deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
242   - printf("tps de transmission : %i\n",deadline);
243   -
244   - if(deadline >= DEADLINE && compteur >=5)
245   - {
246   - //ordre = 2;
247   - compteur = 0;
248   - if(tourne == 1)
249   - pwm_set(PWM_DEV(0),1,31);
250   - if(timer_run == 0)
251   - {
252   - timer_set(TIMER_DEV(1),0,25200);
253   - printf("relance timer\n");
254   - timer_run = 1;
255   - }
256   - }
257   - if(deadline >= DEADLINE && compteur < 5)
258   - {
259   - compteur = 0;
260   - }
261   - if(deadline<=DEADLINE && compteur >=5)
262   - {
263   - //ordre = 1;
264   - pwm_set(PWM_DEV(0),1,45);
265   - tourne = 1;
266   - timer_run=0;
267   - timer_clear(TIMER_DEV(1),0);
268   - printf("clear timer\n");
269   - }
270   - if(deadline<=DEADLINE && compteur <5)
271   - {
272   - compteur++;
273   - }
274   -
275   - printf("compteur : %d\n",compteur);
276   - memset(&buf,0,sizeof(buf));*/
277   - }
  222 + sock_udp_ep_t remote;
  223 + ssize_t res;
  224 + if ((res = sock_udp_recv(&sock, &buf, sizeof(buf), 5 * SEC_IN_USEC,&remote)) >= 0) {
  225 + deadline = xtimer_now_usec() + offset - buf.heure_actuelle;
  226 + printf("tps de transmission : %i\n",deadline);
  227 +
  228 + if(buf.donnees[0] == 'g' && buf.donnees[1] == 'o') {
  229 + if(deadline >= DEADLINE && compteur >=5) {
  230 + compteur = 0;
  231 + if(tourne == 1){
  232 + pwm_set(PWM_DEV(0),1,987);
  233 + pwm_set(PWM_DEV(1),1,960);
  234 + }
  235 + if(timer_run == 0) {
  236 + if (sock_udp_send(&sock, "d", sizeof("d"), &remote) < 0) {
  237 + puts("Error sending reply");
  238 + }
  239 + gpio_clear(LED1_PIN);
  240 + gpio_clear(LED2_PIN);
  241 + gpio_set(LED0_PIN);
  242 + timer_set(TIMER_DEV(1),0,25200);
  243 + printf("relance timer\n");
  244 + if (sntp_sync(&server, SOCK_NO_TIMEOUT) < 0) {
  245 + puts("Error in synchronization");
  246 + return NULL;
  247 + }
  248 + offset = sntp_get_offset();
  249 + printf("offset : %i\n",(int)offset);
  250 + timer_run = 1;
  251 + }
  252 + }
  253 + if(deadline >= DEADLINE && compteur < 5) {
  254 + compteur = 0;
  255 + }
  256 + if(deadline<=DEADLINE && compteur >=5) {
  257 + pwm_set(PWM_DEV(0),1,992);
  258 + pwm_set(PWM_DEV(1),1,658);
  259 + tourne = 1;
  260 + timer_run=0;
  261 + timer_clear(TIMER_DEV(1),0);
  262 + printf("clear timer\n");
  263 + if (sock_udp_send(&sock, "n", sizeof("n"), &remote) < 0) {
  264 + puts("Error sending reply");
  265 + }
  266 + gpio_clear(LED2_PIN);
  267 + gpio_clear(LED0_PIN);
  268 + gpio_set(LED1_PIN);
  269 + }
  270 + if(deadline<=DEADLINE && compteur <5) {
  271 + compteur++;
  272 + }
  273 + printf("compteur : %d\n",compteur);
  274 + memset(&buf,0,sizeof(buf));
  275 + }
  276 + }else{
  277 + puts("msg non recu");
  278 + }
278 279 }
279 280 return NULL;
280 281 }
... ... @@ -282,53 +283,83 @@ void *sock_server_thread(void *arg)
282 283  
283 284 void *sock_client_thread(void *arg)
284 285 {
285   - (void) arg;
286   - Data data;
287   - data.donnees[0] = 'g';
288   - data.donnees[1] = 'o';
289   - //uint8_t paquet[];
290   - sock_udp_ep_t remote = { .family = AF_INET6 };
291   -
292   - remote.port = 1234;
293   - remote.addr.ipv6[0] = 0xde;
294   - remote.addr.ipv6[1] = 0xad;
295   - remote.addr.ipv6[2] = 0xbe;
296   - remote.addr.ipv6[3] = 0xef;
297   - remote.addr.ipv6[14] = 0x34;
298   - remote.addr.ipv6[15] = 0x1e;
299   -// memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN);
300   - while (1) {
301   -// //ipv6_addr_set_all_nodes_multicast((ipv6_addr_t *)&remote.addr.ipv6,
302   -// // IPV6_ADDR_MCAST_SCP_LINK_LOCAL);
303   - data.heure_actuelle = xtimer_now_usec();
304   -
305   - if (sock_udp_send(NULL, &data, sizeof(data), &remote) < 0) {
306   - puts("Error sending message");
307   - }
308   - puts("Send a message");
309   - xtimer_sleep(2);
310   - }
311   - return NULL;
  286 + (void) arg;
  287 + Data data;
  288 + int vitesse=2;
  289 + uint8_t buf[3];
  290 + ssize_t res;
  291 + data.donnees[0] = 'g';
  292 + data.donnees[1] = 'o';
  293 + //uint8_t paquet[];
  294 + sock_udp_ep_t remote = { .family = AF_INET6 };
  295 +
  296 + remote.port = 1234;
  297 + remote.addr.ipv6[0] = 0xde;
  298 + remote.addr.ipv6[1] = 0xad;
  299 + remote.addr.ipv6[2] = 0xbe;
  300 + remote.addr.ipv6[3] = 0xef;
  301 + remote.addr.ipv6[14] = 0x34;
  302 + remote.addr.ipv6[15] = 0x1e;
  303 + // memcpy(remote.addr.ipv6,addr.u8,IPV6_ADDR_BIT_LEN);
  304 + while (1) {
  305 + data.heure_actuelle = xtimer_now_usec();
  306 +
  307 + if (sock_udp_send(&sock, &data, sizeof(data), &remote) < 0) {
  308 + puts("Error sending message");
  309 + }
  310 + puts("Send a message");
  311 + if(vitesse==2) {
  312 + gpio_clear(LED0_PIN);
  313 + gpio_toggle(LED1_PIN);
  314 + }
  315 + else {
  316 + gpio_clear(LED1_PIN);
  317 + gpio_toggle(LED0_PIN);
  318 + }
  319 + if ((res = sock_udp_recv(&sock, buf, sizeof(buf), 0.05 * SEC_IN_USEC,NULL)) < 0) {
  320 + if (res == -ETIMEDOUT) {
  321 + puts("Timed out");
  322 + }
  323 + else {
  324 + puts("Error receiving message");
  325 + }
  326 + }
  327 + else {
  328 + printf("Received message: \"");
  329 + for (int i = 0; i < res; i++) {
  330 + printf("%c", buf[i]);
  331 + }
  332 + if(buf[0] == 'n')
  333 + vitesse = 2;
  334 + else vitesse = 1;
  335 + printf("\"\n");
  336 + }
  337 + xtimer_sleep(vitesse);
  338 + }
  339 + return NULL;
312 340 }
313 341  
314   -/*static void arret_urgence(void *arg,int channel)
  342 +static void arret_urgence(void *arg,int channel)
315 343 {
316   - pwm_set(PWM_DEV(0),1,0);
317   - tourne = 0;
318   - //ordre=0;
319   - timer_run = 0;
320   - printf("Arret d'urgence\n");
321   -}*/
  344 + pwm_set(PWM_DEV(0),1,0);
  345 + pwm_set(PWM_DEV(1),1,0);
  346 + tourne = 0;
  347 + timer_run = 0;
  348 + gpio_clear(LED0_PIN);
  349 + gpio_clear(LED1_PIN);
  350 + gpio_set(LED2_PIN);
  351 + printf("Arret d'urgence\n");
  352 +}
322 353  
323 354 /*static void degradation(void *arg,int channel)
324   -{
325   - ordre=2;
326   - //pwm_set(PWM_DEV(0),1,0);
327   - printf("Ralentissement\n");
328   - timer_set(TIMER_DEV(1),0,25200);
329   -}*/
330   -
331   -/*static void _init_timer(void)
  355 + * {
  356 + * ordre=2;
  357 + * //pwm_set(PWM_DEV(0),1,0);
  358 + * printf("Ralentissement\n");
  359 + * timer_set(TIMER_DEV(1),0,25200);
  360 + * }*/
  361 +
  362 +static void _init_timer(void)
332 363 {
333 364 printf("ok timer\n");
334 365 //timer_init(XTIMER_DEV, CLOCK_CORECLOCK/2 ,&degradation,NULL);
... ... @@ -342,13 +373,14 @@ static void _init_pwm(void)
342 373 {
343 374 pwm_init(PWM_DEV(0), PWM_LEFT, PWM_FREQ, PWM_RES);
344 375 pwm_set(PWM_DEV(0),1,0);
345   -
346   -// thread_create(pwm_stack,sizeof(pwm_stack),7,THREAD_CREATE_STACKTEST,pwm_thread,NULL,"pwm_thread");
  376 + pwm_init(PWM_DEV(1), PWM_LEFT, PWM_FREQ, PWM_RES);
  377 + pwm_set(PWM_DEV(1),1,0);
  378 +
  379 + // thread_create(pwm_stack,sizeof(pwm_stack),7,THREAD_CREATE_STACKTEST,pwm_thread,NULL,"pwm_thread");
347 380 }
348   -*/
349 381  
350 382  
351   -
  383 +
352 384 static void _init_interface(void)
353 385 {
354 386 kernel_pid_t ifs[GNRC_NETIF_NUMOF];
... ... @@ -358,43 +390,38 @@ static void _init_interface(void)
358 390 int res;
359 391  
360 392 gnrc_netif_get(ifs);
361   -
  393 +
362 394 //addresses gobales
363 395 addr.u8[0] = 0xde;
364 396 addr.u8[1] = 0xad;
365 397 addr.u8[2] = 0xbe;
366 398 addr.u8[3] = 0xef;
367   -
  399 +
368 400 res = gnrc_netapi_get(ifs[0], NETOPT_ADDRESS, 0, hwaddr, sizeof(hwaddr));
369   -
  401 +
370 402 if (res >= 0) {
371 403 addr.u8[14] = *hwaddr;
372 404 addr.u8[15] = *(hwaddr+1);
373 405 }
374   - //init RPL
375   - //init_RPL(ifs[0]);
376   - _gnrc_rpl_send_dis();
  406 +
377 407 memcpy(tmp_addr.u8,addr.u8,IPV6_ADDR_BIT_LEN);
378   -
  408 +
379 409 gnrc_ipv6_netif_add_addr(ifs[0], &addr, 64, GNRC_IPV6_NETIF_ADDR_FLAGS_UNICAST);
380 410 /* model ipv6 addr: dead:beef::Hwaddr */
381 411 if((addr.u8[14]==0x34)&&(addr.u8[15]==0x02)){
382 412 crea_rpl_dodag_root("1", "dead:beef::3402");
383   - _gnrc_rpl_send_dis();
384   - client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
385   - // xtimer_usleep(200);
386   - //time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread");
387   - // xtimer_usleep(200);
  413 + client=thread_create(sock_client_stack,sizeof(sock_client_stack),8,THREAD_CREATE_STACKTEST,sock_client_thread,NULL,"sock_client_thread");
  414 + time_server=thread_create(sock_time_server_stack,sizeof(sock_time_server_stack),6,THREAD_CREATE_STACKTEST,sock_time_server_thread,NULL,"sock_time_server_thread");
388 415 }else if((addr.u8[14]==0x37)&&(addr.u8[15]==0x62)){
389   -
  416 +
390 417 }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x12)){
391   - //_init_timer();
392   - //_init_pwm();
393   - /*server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");*/
394 418  
395 419 }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x0a)){
396 420 }else if((addr.u8[14]==0x34)&&(addr.u8[15]==0x1e)){
397   - server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");
  421 + _init_timer();
  422 + _init_pwm();
  423 + xtimer_sleep(2);
  424 + server=thread_create(sock_server_stack,sizeof(sock_server_stack),6,THREAD_CREATE_STACKTEST,sock_server_thread,NULL,"sock_server_thread");
398 425 }else{
399 426 puts("new node ?");
400 427 }
... ... @@ -403,9 +430,9 @@ static void _init_interface(void)
403 430  
404 431 int main(void)
405 432 {
406   -
407 433 msg_init_queue(_main_msg_queue, MAIN_QUEUE_SIZE);
408 434 puts("RIOT network stack example application");
  435 +
409 436 _init_interface();
410 437  
411 438 /* start shell */
... ...
RIOT/sys/include/net/gnrc/rpl.h
... ... @@ -294,7 +294,7 @@ static inline bool GNRC_RPL_COUNTER_GREATER_THAN(uint8_t A, uint8_t B)
294 294 * @{
295 295 */
296 296 #ifndef GNRC_RPL_DEFAULT_LIFETIME
297   -#define GNRC_RPL_DEFAULT_LIFETIME (5)
  297 +#define GNRC_RPL_DEFAULT_LIFETIME (1)
298 298 #endif
299 299 #ifndef GNRC_RPL_LIFETIME_UNIT
300 300 #define GNRC_RPL_LIFETIME_UNIT (60)
... ...
RIOT/sys/include/net/gnrc/rpl/structs.h
... ... @@ -297,7 +297,7 @@ struct gnrc_rpl_instance {
297 297 };
298 298 /*******************************************************************/
299 299 //ADDED BY PFE7 2017
300   -static uint8_t dodag_insert;
  300 +//uint8_t LED_flag_dodag;
301 301 //\ADDED BY PFE7 2017
302 302 /*******************************************************************/
303 303 #ifdef __cplusplus
... ...
RIOT/sys/net/gnrc/network_layer/icmpv6/echo/gnrc_icmpv6_echo.c
... ... @@ -20,7 +20,7 @@
20 20 #include "net/gnrc/ipv6/hdr.h"
21 21 #include "utlist.h"
22 22  
23   -#define ENABLE_DEBUG (1)
  23 +#define ENABLE_DEBUG (0)
24 24 #include "debug.h"
25 25  
26 26 #if ENABLE_DEBUG
... ...
RIOT/sys/net/gnrc/network_layer/ipv6/gnrc_ipv6.c
... ... @@ -906,7 +906,7 @@ static void _receive(gnrc_pktsnip_t *pkt)
906 906  
907 907 #ifdef MODULE_GNRC_IPV6_ROUTER /* only routers redirect */
908 908 /* redirect to next hop */
909   - printf("ipv6: decrement hop limit to %u\n", (uint8_t) (hdr->hl - 1));
  909 + DEBUG("ipv6: decrement hop limit to %u\n", (uint8_t) (hdr->hl - 1));
910 910  
911 911 /* RFC 4291, section 2.5.6 states: "Routers must not forward any
912 912 * packets with Link-Local source or destination addresses to other
... ... @@ -923,7 +923,7 @@ static void _receive(gnrc_pktsnip_t *pkt)
923 923 gnrc_pktsnip_t *reversed_pkt = NULL, *ptr = pkt;
924 924  
925 925 DEBUG("ipv6: forward packet to next hop\n");
926   - printf ("transmission\n");
  926 + // printf ("transmission\n");
927 927 /* pkt might not be writable yet, if header was given above */
928 928 ipv6 = gnrc_pktbuf_start_write(ipv6);
929 929 if (ipv6 == NULL) {
... ...
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl.c
... ... @@ -19,19 +19,15 @@
19 19 #include "net/gnrc/ipv6/netif.h"
20 20 #include "net/gnrc.h"
21 21 #include "mutex.h"
22   -
  22 +#include "board.h"
  23 +#include "periph_conf.h"
  24 +#include "periph/gpio.h"
23 25 #include "net/gnrc/rpl.h"
  26 +
24 27 #ifdef MODULE_GNRC_RPL_P2P
25 28 #include "net/gnrc/rpl/p2p.h"
26 29 #include "net/gnrc/rpl/p2p_dodag.h"
27 30 #endif
28   -/*******************************************************************/
29   -//ADDED BY PFE7 2017
30   -//#include "../../boards/stm32f4discovery/include/board.h"
31   -//#include "../../boards/stm32f4discovery/include/periph_conf.h"
32   -
33   -//\ADDED BY PFE7 2017
34   -/*******************************************************************/
35 31 #define ENABLE_DEBUG (0)
36 32 #include "debug.h"
37 33  
... ... @@ -128,7 +124,6 @@ gnrc_rpl_instance_t *gnrc_rpl_root_init(uint8_t instance_id, ipv6_addr_t *dodag_
128 124 trickle_start(gnrc_rpl_pid, &dodag->trickle, GNRC_RPL_MSG_TYPE_TRICKLE_INTERVAL,
129 125 GNRC_RPL_MSG_TYPE_TRICKLE_CALLBACK, (1 << dodag->dio_min),
130 126 dodag->dio_interval_doubl, dodag->dio_redun);
131   -
132 127 return inst;
133 128 }
134 129  
... ... @@ -288,6 +283,16 @@ void _update_lifetime(void)
288 283 for (int i = 0; i < GNRC_RPL_INSTANCES_NUMOF; ++i) {
289 284 inst = &gnrc_rpl_instances[i];
290 285 if (inst->state != 0) {
  286 + /*******************************************************************/
  287 + //ADDED BY PFE7 2017
  288 + if((inst->dodag.my_rank >= GNRC_RPL_INFINITE_RANK) || (inst-> dodag.my_rank<=0)){
  289 + LED3_OFF;
  290 + }
  291 + else{
  292 + LED3_ON;
  293 + }
  294 + //\ADDED BY PFE7 2017
  295 + /*******************************************************************/
291 296 if ((inst->cleanup > 0) && (inst->dodag.parents == NULL) &&
292 297 (inst->dodag.my_rank == GNRC_RPL_INFINITE_RANK)) {
293 298 inst->cleanup -= GNRC_RPL_LIFETIME_UPDATE_STEP;
... ...
RIOT/sys/net/gnrc/routing/rpl/gnrc_rpl_dodag.c
... ... @@ -349,9 +349,7 @@ static gnrc_rpl_parent_t *_gnrc_rpl_find_preferred_parent(gnrc_rpl_dodag_t *doda
349 349 #endif
350 350  
351 351 }
352   - printf("AVmy_rank : %d\n",dodag->my_rank);
353 352 dodag->my_rank = dodag->instance->of->calc_rank(dodag->parents, 0);
354   - printf("my_rank : %d\n",dodag->my_rank);
355 353 if (dodag->my_rank != old_rank) {
356 354 trickle_reset_timer(&dodag->trickle);
357 355 }
... ...
RIOT/sys/net/gnrc/routing/rpl/of0.c
... ... @@ -57,7 +57,7 @@ uint16_t calc_rank(gnrc_rpl_parent_t *parent, uint16_t base_rank)
57 57 puts("pas parent");
58 58 return GNRC_RPL_INFINITE_RANK;
59 59 }
60   - puts("if1");
  60 + //puts("if1");
61 61 base_rank = parent->rank;
62 62  
63 63 }
... ... @@ -65,14 +65,14 @@ uint16_t calc_rank(gnrc_rpl_parent_t *parent, uint16_t base_rank)
65 65 uint16_t add;
66 66  
67 67 if (parent != NULL) {
68   - puts("if2");
  68 + //puts("if2");
69 69 //add = parent->dodag->instance->min_hop_rank_inc;
70 70 /*******************************************************************/
71 71 //ADDED BY PFE7 2017
72 72  
73 73 add = 256 - (parent->mc.rssi + parent->mc.lqi)/10;
74 74 parent->dodag->instance->min_hop_rank_inc=add;
75   - printf("add= %u\n",add);
  75 + //printf("add= %u\n",add);
76 76  
77 77 //\ADDED BY PFE7 2017
78 78 /*******************************************************************/
... ...