LO53 PROJECT - AP DOCUMENTATION
Project based on Indoor Positionning System
/home/junicode/Documents/LO53_Project/LO53_AP_Development/rssi_list.h
Go to the documentation of this file.
1 
10 #include <stdio.h>
11 #include <string.h>
12 #include <stdlib.h>
13 #include <math.h>
14 #include <arpa/inet.h>
15 #include <sys/time.h>
16 
17 #define SAMPLE_DELAY 6 // This the maximum time of life of a captured sample
18 
19 /*
20  * Data definitions
21  */
22 
28 typedef struct _Rssi_sample
29 {
30  double rssi_mW;
31  unsigned long deadline;
32  struct _Rssi_sample * next;
33 } Rssi_sample;
34 
40 typedef struct _Deque
41 {
44 } Deque;
45 
51 typedef struct _Element
52 {
53  u_char * mac_addr;
55  struct _Element *next;
56 } Element;
57 
58 /*
59  * Functions signatures
60  */
61 
62 // General functions
63 
64 // Rssi_sample functions
69 void clear_outdated_values(Deque * list);
70 
76 void add_value(Deque * list, double value);
77 
78 // Element functions
79 
84 void clear_outdated_Elements(Element ** list);
85 
92 Element * find_mac(Element * list, u_char * mac_value);
93 
101 Element * add_element(Element ** list, u_char * mac_value);
102 
103 // Other useful functions
104 
112 void calculate_avg(Element ** list, u_char * mac_value, u_char * nb_samples, u_char * avg_value);
113 
114 
121 unsigned int mac_maching(u_char * mac1, u_char * mac2);
122 
129 Element * find_deque(Element * list, Deque * deq);
130 
135 void decrement_all_deadlines(Element * list);
contains one element of the Device list The device list shall be sorted by device's MAC ...
unsigned long deadline
Time after which this sample shall be deleted.
Definition: rssi_list.h:31
Definition: rssi_list.h:51
struct _Element * next
next node (a different device)
Definition: rssi_list.h:55
void calculate_avg(Element **list, u_char *mac_value, u_char *nb_samples, u_char *avg_value)
Calculate avg ss values from a given string mac address.
Definition: rssi_list.c:117
Element * add_element(Element **list, u_char *mac_value)
add_element adds an element (a new device node) to the list. Elements shall be ordered.
Definition: rssi_list.c:41
struct _Rssi_sample * next
next RSSI sample
Definition: rssi_list.h:32
Definition: rssi_list.h:28
struct _Deque Deque
struct _Rssi_sample Rssi_sample
void clear_outdated_values(Deque *list)
clear_outdated_values removes all outdated RSSI in a RSSI deque.
Definition: rssi_list.c:163
Element * find_mac(Element *list, u_char *mac_value)
find_mac looks up for a MAC address in the list.
Definition: rssi_list.c:97
Element * find_deque(Element *list, Deque *deq)
This function find a specific Deque in the Element List.
Definition: rssi_list.c:107
void add_value(Deque *list, double value)
add_value adds a new RSSI value at the end of the deque.
Definition: rssi_list.c:14
Rssi_sample * tail
Tail (last element), useful for adding elements.
Definition: rssi_list.h:43
Rssi_sample * head
Head (first element of deque)
Definition: rssi_list.h:42
unsigned int mac_maching(u_char *mac1, u_char *mac2)
This function makes the comparison of two mac addresses to check if they are equals.
Definition: rssi_list.c:81
contains an RSSI sample value, extracted from a packet It is a linked list.
Definition: rssi_list.h:40
void decrement_all_deadlines(Element *list)
This function decrement every second the deadline value of all the samples included in an element lis...
Definition: rssi_list.c:239
void clear_outdated_Elements(Element **list)
clear_outdated_Elements removes all outdated Elements in the linked-list.
Definition: rssi_list.c:207
u_char * mac_addr
MAC address in binary format [6].
Definition: rssi_list.h:53
defines a pseudo double ended queue It shall contain the RSSI values sorted by deadline.
double rssi_mW
rssi_mW RSSI as mW value (=10^(rssi_dBm/10))
Definition: rssi_list.h:30
Deque * measurements
deque with the actual measurements
Definition: rssi_list.h:54
struct _Element Element