19 #ifndef CONVERGENCE_LAYER_H
20 #define CONVERGENCE_LAYER_H
30 #define CONVERGENCE_LAYER_QUEUE 10
35 #define CONVERGENCE_LAYER_QUEUE_FREE (0.2 * CONVERGENCE_LAYER_QUEUE)
40 #define CONVERGENCE_LAYER_RETRIES 4
45 #define CONVERGENCE_LAYER_FAILED_RETRIES 15
50 #define CONVERGENCE_LAYER_TIMEOUT 5
55 #define CONVERGENCE_LAYER_RETRANSMIT_TIMEOUT 0.5
60 #define CONVERGENCE_LAYER_RETRANSMIT_TRIES (CONVERGENCE_LAYER_TIMEOUT / CONVERGENCE_LAYER_RETRANSMIT_TIMEOUT)
65 #define CONVERGENCE_LAYER_QUEUE_ACTIVE 0x01
66 #define CONVERGENCE_LAYER_QUEUE_IN_TRANSIT 0x02
67 #define CONVERGENCE_LAYER_QUEUE_ACK_PEND 0x04
68 #define CONVERGENCE_LAYER_QUEUE_DONE 0x08
69 #define CONVERGENCE_LAYER_QUEUE_FAIL 0x10
70 #define CONVERGENCE_LAYER_QUEUE_ACK 0x20
71 #define CONVERGENCE_LAYER_QUEUE_NACK 0x40
76 #define CONVERGENCE_LAYER_COMPAT 0x00
81 #define CONVERGENCE_LAYER_TYPE_DATA 0x10
82 #define CONVERGENCE_LAYER_TYPE_DISCOVERY 0x20
83 #define CONVERGENCE_LAYER_TYPE_ACK 0x30
84 #define CONVERGENCE_LAYER_TYPE_NACK 0x00
89 #define CONVERGENCE_LAYER_FLAGS_FIRST 0x02
90 #define CONVERGENCE_LAYER_FLAGS_LAST 0x01
95 #define CONVERGENCE_LAYER_MASK_COMPAT 0xC0
96 #define CONVERGENCE_LAYER_MASK_TYPE 0x30
97 #define CONVERGENCE_LAYER_MASK_SEQNO 0x0C
98 #define CONVERGENCE_LAYER_MASK_FLAGS 0x03
103 #define CONVERGENCE_LAYER_STATUS_OK 0x01
104 #define CONVERGENCE_LAYER_STATUS_NOACK 0x02
105 #define CONVERGENCE_LAYER_STATUS_NOSEND 0x04
106 #define CONVERGENCE_LAYER_STATUS_FATAL 0x08
111 #define CONVERGENCE_LAYER_PRIORITY_NORMAL 0x01
112 #define CONVERGENCE_LAYER_PRIORITY_HIGH 0x02
114 #define CONVERGENCE_LAYER_VALID_FLAG 0x7a03ab12UL
119 #define CONVERGENCE_LAYER_MAX_LENGTH 115
134 uint8_t failed_tries;
135 rimeaddr_t neighbour;
136 uint32_t bundle_number;
137 uint8_t sequence_number;
138 clock_time_t timestamp;
140 struct mmem * bundle;
143 int convergence_layer_init(
void);
149 int convergence_layer_send_discovery(uint8_t * payload, uint8_t length, rimeaddr_t * neighbour);
151 int convergence_layer_incoming_frame(rimeaddr_t * source, uint8_t * payload, uint8_t length, packetbuf_attr_t rssi);
152 int convergence_layer_status(
void * pointer, uint8_t status);
156 int convergence_layer_neighbour_down(rimeaddr_t * neighbour);