Owl Positioning System: a Wi-Fi-based, infrastructure-centred indoor positioning system. http://owlps.pu-pm.univ-fcomte.fr/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

owlps-aggregator.h 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * This file is part of the Owl Positioning System (OwlPS) project.
  3. * It is subject to the copyright notice and license terms in the
  4. * COPYRIGHT.t2t file found in the top-level directory of this
  5. * distribution and at
  6. * https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
  7. * No part of the OwlPS Project, including this file, may be copied,
  8. * modified, propagated, or distributed except according to the terms
  9. * contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
  10. * distributed along with this file, either separately or by replacing
  11. * this notice by the COPYRIGHT.t2t file's contents.
  12. *
  13. ***********************************************************************
  14. *
  15. * This is the header file of OwlPS Aggregator.
  16. */
  17. #ifndef _OWLPS_AGGREGATOR_H_
  18. #define _OWLPS_AGGREGATOR_H_
  19. #include <owlps-config.h>
  20. #include <owlps.h>
  21. #include <stdio.h>
  22. /* Arguments & program configuration */
  23. #define OPTIONS "Ac:C:Df:FGhH:i:k:K:l:o:O:p:qt:vV" // getopt string
  24. #define DEFAULT_CONFIG_FILE OWL_CONFIG_PREFIX "/owlps-aggregator.conf"
  25. #define DEFAULT_AGGREGATE_TIMEOUT 600 // milliseconds
  26. #define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
  27. #define DEFAULT_CHECK_INTERVAL 300 // milliseconds
  28. #define DEFAULT_CP_KEEP_TIMEOUT 35 // seconds
  29. #define DEFAULT_AC_ORDER_INTERVAL 1000 // milliseconds
  30. #define POSITIONER_DEFAULT_HOST "localhost"
  31. /* Verbosity levels */
  32. #define VERBOSE_QUIET cfg_getint(cfg, "verbose") == 0
  33. #define VERBOSE_WARNING cfg_getint(cfg, "verbose") >= 1
  34. #define VERBOSE_INFO cfg_getint(cfg, "verbose") >= 2
  35. #define VERBOSE_CHATTERBOX cfg_getint(cfg, "verbose") >= 3
  36. #define VERBOSE_REQUESTS cfg_getint(cfg, "verbose") >= 4
  37. #define MAX_VERBOSE_LEVEL 4
  38. /* Linked list storing data of each request */
  39. typedef struct _request_info_list
  40. {
  41. // Number of the current packet:
  42. uint16_t packet_id ;
  43. // MAC address of the transmitter CP (in bytes):
  44. uint8_t cp_mac_addr_bytes[ETHER_ADDR_LEN] ;
  45. // Timestamp of arrival on the listener:
  46. owl_timestamp capture_time ;
  47. // Signal strength received by the CP from the mobile:
  48. int8_t ss_dbm ;
  49. unsigned char __pad0[7]; // 7 bytes alignment
  50. struct _request_info_list *next ;
  51. } request_info_list ;
  52. /* Linked list of the requests */
  53. typedef struct _request_list
  54. {
  55. uint8_t type ;
  56. unsigned char __pad0; // 1 byte alignment
  57. // Number of packets sent by the mobile for this request:
  58. uint16_t nb_packets ;
  59. /* Request identifier */
  60. uint8_t mobile_mac_addr_bytes[ETHER_ADDR_LEN] ; // Mobile MAC address
  61. unsigned char __pad1[2]; // 2 bytes alignment
  62. owl_timestamp request_time ; // Request time on the mobile
  63. /* Calibration data */
  64. float x_position ;
  65. float y_position ;
  66. float z_position ;
  67. owl_direction direction ; // Request orientation
  68. /* Other data */
  69. uint8_t mobile_ip_addr_bytes[4] ; // Mobile IP address
  70. unsigned char __pad2[3]; // 3 bytes alignment
  71. // Arrival time of the first packet of the request on the aggregator:
  72. owl_timestamp start_time ;
  73. request_info_list *info ; // Data for this request
  74. struct _request_list *next ;
  75. } request_list ;
  76. /* Linked list of the known CPs */
  77. typedef struct _cp_list
  78. {
  79. uint8_t mac_addr_bytes[ETHER_ADDR_LEN] ;
  80. char ip_addr[INET_ADDRSTRLEN] ;
  81. unsigned char __pad0[2]; // 2 bytes alignment
  82. owl_timestamp last_seen ;
  83. struct _cp_list *previous ;
  84. struct _cp_list *next ;
  85. } cp_list ;
  86. /* Function headers */
  87. int initialise_configuration(const int argc, char *const *argv) ;
  88. int parse_config_file(const int argc, char *const *argv) ;
  89. int parse_command_line(const int argc, char *const *argv) ;
  90. int check_configuration(void) ;
  91. int read_loop(const int sockfd) ;
  92. void print_captured_request(const owl_captured_request *const request) ;
  93. void got_request(const owl_captured_request *const request) ;
  94. void add_captured_request(const owl_timestamp *const reception_time,
  95. const owl_captured_request *const request,
  96. request_info_list *const request_info) ;
  97. void* monitor_requests(void *const NULL_value) ;
  98. void scan_request_list(FILE *const stream,
  99. const int sockfd,
  100. const struct sockaddr *const serv) ;
  101. void flush_request_list(FILE *const stream,
  102. const int sockfd,
  103. const struct sockaddr *const serv) ;
  104. void output_request(request_list *const request_ptr,
  105. FILE *const stream,
  106. const int sockfd,
  107. const struct sockaddr *const serv) ;
  108. #ifndef NDEBUG
  109. void print_request_list(void) ;
  110. void print_request_info(const request_info_list *const info) ;
  111. #endif // NDEBUG
  112. void* listen_for_cps(void *const NULL_value) ;
  113. void update_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN],
  114. const char ip_addr[INET_ADDRSTRLEN]) ;
  115. cp_list* find_cp(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
  116. cp_list* add_cp_front(const uint8_t mac_addr_bytes[ETHER_ADDR_LEN]) ;
  117. void update_cp_ip_addr(cp_list *const cp,
  118. const char ip_addr[INET_ADDRSTRLEN]) ;
  119. void update_cp_seen(cp_list *const cp) ;
  120. void push_cp(cp_list *const cp) ;
  121. void* monitor_cps(void *const NULL_value) ;
  122. void delete_old_cps(void) ;
  123. void delete_cp(cp_list *const cp) ;
  124. void unlink_cp(const cp_list *const cp) ;
  125. void order_send(const cp_list *const cp) ;
  126. void free_cp_list(void) ;
  127. void print_usage(void) ;
  128. void print_version(void) ;
  129. #endif // _OWLPS_AGGREGATOR_H_