owlps/infrastructure-centred/owlps-aggregator/owlps-aggregator.h

85 lines
2.4 KiB
C
Raw Normal View History

/*
* This file is part of the rtap localisation project.
*/
#ifndef _OWLPS_AGGREGATOR_H_
#define _OWLPS_AGGREGATOR_H_
#include "../../libowlps/owlps.h"
#include <confuse.h>
#define DEBUG
// Uncomment to output the timestamp on each line of the output file:
//#define TIMESTAMP
/* Arguments & program configuration */
2010-07-12 16:57:32 +02:00
#define OPTIONS "a:c:f:hi:k:l:o:p:" // getopt string
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
#define DEFAULT_CHECK_INTERVAL 500000 // microseconds
#define POSITIONER_DEFAULT_IP "127.0.0.1"
/* Error codes */
#define ERR_NO_MESSAGE_RECEIVED 1 // Error when reading the socket
#define ERR_CREATING_SOCKET 2 // Erreur when creating listening socket
#define ERR_BAD_USAGE 3 // Bad program call
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
/* Linked list storing data of couples MAC / sequence number */
typedef struct _couple_info_list
{
// MAC address of the data sender (in bytes):
unsigned char ap_mac_addr_bytes[6] ;
// Signal strength received by the AP from the mobile:
unsigned char antenna_signal_dbm ;
struct _couple_info_list *next ;
} couple_info_list ;
/* Linked list of the couples MAC / sequence number */
typedef struct _couple_list
{
/* Numéro de séquence de la demande de localisation du mobile */
unsigned char mobile_mac_addr_bytes[6] ; // Mobile MAC address (in bytes)
struct timeval request_time ; // Request time on the mobile
/* Calibration data */
float x_position ;
float y_position ;
float z_position ;
DIRECTION direction ; // Request orientation
/* Other data */
// Arrival time of the first packet of the couple on the aggregator:
struct timeval start_time ;
couple_info_list *info ; // Data for this couple
struct _couple_list *next ;
} couple_list ;
/* Function headers */
void initialise_configuration(int argc, char **argv) ;
void parse_config_file(int argc, char **argv) ;
void parse_command_line(int argc, char **argv) ;
void check_configuration(void) ;
int read_loop(int sockfd) ;
void got_couple_info(couple_message message) ;
void free_couple_list(void) ;
#ifdef DEBUG
void print_couple_list(void) ;
void print_couple_info(couple_info_list *info) ;
#endif // DEBUG
void* monitor_couples(void) ;
char* ip_bytes_to_string(unsigned char *ip_binary) ;
void print_usage(void) ;
#endif // _OWLPS_AGGREGATOR_H_