fb11e647
vrobic
reseau statique a...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*
* Copyright (C) 2014 Oliver Hahm <oliver.hahm@inria.fr>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup net_gnrc_rpl
* @{
* @file
* @brief Objective Function Zero.
*
* Implementation of Objective Function Zero.
*
* @author Eric Engel <eric.engel@fu-berlin.de>
* @}
*/
#include <string.h>
#include "of0.h"
#include "net/gnrc/rpl.h"
#include "net/gnrc/rpl/structs.h"
static uint16_t calc_rank(gnrc_rpl_parent_t *, uint16_t);
static gnrc_rpl_parent_t *which_parent(gnrc_rpl_parent_t *, gnrc_rpl_parent_t *);
static gnrc_rpl_dodag_t *which_dodag(gnrc_rpl_dodag_t *, gnrc_rpl_dodag_t *);
static void reset(gnrc_rpl_dodag_t *);
static gnrc_rpl_of_t gnrc_rpl_of0 = {
0x0,
calc_rank,
which_parent,
which_dodag,
reset,
NULL,
NULL,
NULL
};
gnrc_rpl_of_t *gnrc_rpl_get_of0(void)
{
return &gnrc_rpl_of0;
}
void reset(gnrc_rpl_dodag_t *dodag)
{
/* Nothing to do in OF0 */
(void) dodag;
}
uint16_t calc_rank(gnrc_rpl_parent_t *parent, uint16_t base_rank)
{
if (base_rank == 0) {
if (parent == NULL) {
|
78b7a7a9
vrobic
affectation rang ...
|
57
|
puts("pas parent");
|
fb11e647
vrobic
reseau statique a...
|
58
59
|
return GNRC_RPL_INFINITE_RANK;
}
|
93480153
vrobic
modif dynamic_app
|
60
|
//puts("if1");
|
fb11e647
vrobic
reseau statique a...
|
61
|
base_rank = parent->rank;
|
78b7a7a9
vrobic
affectation rang ...
|
62
|
|
fb11e647
vrobic
reseau statique a...
|
63
64
65
66
67
|
}
uint16_t add;
if (parent != NULL) {
|
93480153
vrobic
modif dynamic_app
|
68
|
//puts("if2");
|
78b7a7a9
vrobic
affectation rang ...
|
69
70
71
72
73
74
|
//add = parent->dodag->instance->min_hop_rank_inc;
/*******************************************************************/
//ADDED BY PFE7 2017
add = 256 - (parent->mc.rssi + parent->mc.lqi)/10;
parent->dodag->instance->min_hop_rank_inc=add;
|
93480153
vrobic
modif dynamic_app
|
75
|
//printf("add= %u\n",add);
|
78b7a7a9
vrobic
affectation rang ...
|
76
77
78
|
//\ADDED BY PFE7 2017
/*******************************************************************/
|
fb11e647
vrobic
reseau statique a...
|
79
80
|
}
else {
|
78b7a7a9
vrobic
affectation rang ...
|
81
|
puts("else1");
|
fb11e647
vrobic
reseau statique a...
|
82
|
add = GNRC_RPL_DEFAULT_MIN_HOP_RANK_INCREASE;
|
78b7a7a9
vrobic
affectation rang ...
|
83
|
|
fb11e647
vrobic
reseau statique a...
|
84
85
86
|
}
if ((base_rank + add) < base_rank) {
|
78b7a7a9
vrobic
affectation rang ...
|
87
|
puts("b_r + add < br");
|
fb11e647
vrobic
reseau statique a...
|
88
89
|
return GNRC_RPL_INFINITE_RANK;
}
|
fb11e647
vrobic
reseau statique a...
|
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
return base_rank + add;
}
/* We simply return the Parent with lower rank */
gnrc_rpl_parent_t *which_parent(gnrc_rpl_parent_t *p1, gnrc_rpl_parent_t *p2)
{
if (p1->rank <= p2->rank) {
return p1;
}
return p2;
}
/* Not used yet */
gnrc_rpl_dodag_t *which_dodag(gnrc_rpl_dodag_t *d1, gnrc_rpl_dodag_t *d2)
{
(void) d2;
return d1;
}
|