OpenWSN Firmware
neighbors.h
Go to the documentation of this file.
1 #ifndef __NEIGHBORS_H
2 #define __NEIGHBORS_H
3 
10 #include "openwsn.h"
11 #include "icmpv6rpl.h"
12 
13 //=========================== define ==========================================
14 
15 #define MAXNUMNEIGHBORS 10
16 #define MAXPREFERENCE 2
17 #define BADNEIGHBORMAXRSSI -80 //dBm
18 #define GOODNEIGHBORMINRSSI -90 //dBm
19 #define SWITCHSTABILITYTHRESHOLD 3
20 #define DEFAULTLINKCOST 15
21 
22 #define MAXDAGRANK 0xffff
23 #define DEFAULTDAGRANK MAXDAGRANK
24 #define MINHOPRANKINCREASE 256 //default value in RPL and Minimal 6TiSCH draft
25 
26 //=========================== typedef =========================================
27 
28 BEGIN_PACK
29 typedef struct {
30  bool used;
36  int8_t rssi;
37  uint8_t numRx;
38  uint8_t numTx;
39  uint8_t numTxACK;
40  uint8_t numWraps;//number of times the tx counter wraps. can be removed if memory is a restriction. also check openvisualizer then.
42  uint8_t joinPrio;
44 END_PACK
45 
46 BEGIN_PACK
47 typedef struct {
48  uint8_t row;
51 END_PACK
52 
53 BEGIN_PACK
54 typedef struct {
55  uint8_t last_addr_byte; // last byte of the neighbor's address
56  int8_t rssi;
59  uint16_t asn;
61 END_PACK
62 
63 //=========================== module variables ================================
64 
65 typedef struct {
68  uint8_t debugRow;
69  icmpv6rpl_dio_ht* dio; //keep it global to be able to debug correctly.
71 
72 //=========================== prototypes ======================================
73 
74 void neighbors_init(void);
75 
76 // getters
78 uint8_t neighbors_getNumNeighbors(void);
80 open_addr_t* neighbors_getKANeighbor(uint16_t kaPeriod);
81 
82 // interrogators
85 bool neighbors_isNeighborWithLowerDAGrank(uint8_t index);
86 bool neighbors_isNeighborWithHigherDAGrank(uint8_t index);
87 
88 // updating neighbor information
90  open_addr_t* l2_src,
91  int8_t rssi,
92  asn_t* asnTimestamp,
93  bool joinPrioPresent,
94  uint8_t joinPrio
95 );
97  open_addr_t* dest,
98  uint8_t numTxAttempts,
99  bool was_finally_acked,
100  asn_t* asnTimestamp
101 );
103 
104 // get addresses
105 void neighbors_getNeighbor(open_addr_t* address,uint8_t addr_type,uint8_t index);
106 // managing routing info
108 // maintenance
109 void neighbors_removeOld(void);
110 // debug
111 bool debugPrint_neighbors(void);
113 
119 #endif
dagrank_t myDAGrank
Definition: neighbors.h:67
bool stableNeighbor
Definition: neighbors.h:32
open_addr_t * neighbors_getKANeighbor(uint16_t kaPeriod)
Find neighbor to which to send KA.
Definition: neighbors.c:141
void neighbors_indicateRxDIO(OpenQueueEntry_t *msg)
Indicate I just received a RPL DIO from a neighbor.
Definition: neighbors.c:436
uint8_t debugRow
Definition: neighbors.h:68
dagrank_t neighbors_getMyDAGrank()
Retrieve this mote's current DAG rank.
Definition: neighbors.c:54
Definition: neighbors.h:54
uint8_t row
Definition: neighbors.h:48
bool neighbors_isStableNeighbor(open_addr_t *address)
Indicate whether some neighbor is a stable neighbor.
Definition: neighbors.c:190
neighborRow_t neighborEntry
Definition: neighbors.h:49
void neighbors_updateMyDAGrankAndNeighborPreference()
Update my DAG rank and neighbor preference.
Definition: neighbors.c:497
uint8_t neighbors_getNumNeighbors()
Retrieve the number of neighbors this mote's currently knows of.
Definition: neighbors.c:63
void neighbors_removeOld()
Definition: neighbors.c:553
bool neighbors_isPreferredParent(open_addr_t *address)
Indicate whether some neighbor is a preferred neighbor.
Definition: neighbors.c:229
icmpv6rpl_dio_ht * dio
Definition: neighbors.h:69
void debugNetPrint_neighbors(netDebugNeigborEntry_t *out)
Definition: neighbors.c:586
uint16_t asn
Definition: neighbors.h:59
void neighbors_init()
Initializes this module.
Definition: neighbors.c:34
uint8_t numTx
Definition: neighbors.h:38
asn_t asn
Definition: neighbors.h:41
bool used
Definition: neighbors.h:30
open_addr_t addr_64b
Definition: neighbors.h:34
uint8_t parentPreference
Definition: neighbors.h:57
uint8_t parentPreference
Definition: neighbors.h:31
void neighbors_getNeighbor(open_addr_t *address, uint8_t addr_type, uint8_t index)
Write the 64-bit address of some neighbor to some location.
Definition: neighbors.c:472
Definition: openwsn.h:268
bool neighbors_isNeighborWithHigherDAGrank(uint8_t index)
Indicate whether some neighbor has a lower DAG rank that me.
Definition: neighbors.c:279
bool neighbors_getPreferredParentEui64(open_addr_t *addressToWrite)
Retrieve my preferred parent's EUI64 address.
Definition: neighbors.c:81
uint8_t switchStabilityCounter
Definition: neighbors.h:33
int8_t rssi
Definition: neighbors.h:36
int8_t rssi
Definition: neighbors.h:56
Definition: neighbors.h:65
Definition: neighbors.h:29
void neighbors_indicateTx(open_addr_t *l2_dest, uint8_t numTxAttempts, bool was_finally_acked, asn_t *asnTs)
Indicate some packet was sent to some neighbor.
Definition: neighbors.c:392
Header format of a RPL DIO packet.
Definition: icmpv6rpl.h:81
Definition: openwsn.h:276
dagrank_t DAGrank
Definition: neighbors.h:35
uint8_t last_addr_byte
Definition: neighbors.h:55
void neighbors_indicateRx(open_addr_t *l2_src, int8_t rssi, asn_t *asnTs, bool joinPrioPresent, uint8_t joinPrio)
Indicate some (non-ACK) packet was received from a neighbor.
Definition: neighbors.c:315
uint8_t joinPrio
Definition: neighbors.h:42
uint16_t dagrank_t
Definition: openwsn.h:264
#define MAXNUMNEIGHBORS
Definition: neighbors.h:15
uint8_t numRx
Definition: neighbors.h:37
Definition: openwsn.h:288
uint8_t numTxACK
Definition: neighbors.h:39
dagrank_t DAGrank
Definition: neighbors.h:58
Definition: neighbors.h:47
bool debugPrint_neighbors()
Triggers this module to print status information, over serial.
Definition: neighbors.c:577
uint8_t numWraps
Definition: neighbors.h:40
bool neighbors_isNeighborWithLowerDAGrank(uint8_t index)
Indicate whether some neighbor has a lower DAG rank that me.
Definition: neighbors.c:258