diff --git a/infrastructure-centred/owlps-aggregator/owlps-aggregator.h b/infrastructure-centred/owlps-aggregator/owlps-aggregator.h index 76f4efa..2c56dc5 100644 --- a/infrastructure-centred/owlps-aggregator/owlps-aggregator.h +++ b/infrastructure-centred/owlps-aggregator/owlps-aggregator.h @@ -15,7 +15,7 @@ /* Arguments & program configuration */ -#define OPTIONS "Aa:c:C:f:hi:k:K:l:o:p:t:" // getopt string +#define OPTIONS "Aa:c:C:f:hi:k:K:l:o:p:t:v" // 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 diff --git a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c index 4984355..c3d0c1c 100644 --- a/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c +++ b/infrastructure-centred/owlps-aggregator/owlps-aggregatord.c @@ -88,6 +88,10 @@ void parse_config_file(int argc, char **argv) // Config file options for confuse cfg_opt_t opts[] = { + // Be verbose? + CFG_BOOL("verbose", cfg_false, CFGF_NONE), + + // Aggregation listening port CFG_INT("listening_port", AGGREGATE_DEFAULT_PORT, CFGF_NONE), // Port and IP address of the localisation server: @@ -204,6 +208,9 @@ void parse_command_line(int argc, char **argv) case 't' : cfg_setint(cfg, "aggregate_timeout", strtol(optarg, NULL, 0)) ; break ; + case 'v' : + cfg_setbool(cfg, "verbose", cfg_true) ; + break ; default : print_usage() ; exit(ERR_BAD_USAGE) ; @@ -313,39 +320,53 @@ int read_loop(int sockfd) } break ; } - ap_mac_string = - mac_bytes_to_string(message.ap_mac_addr_bytes) ; - mobile_mac_string = - mac_bytes_to_string(message.mobile_mac_addr_bytes) ; - mobile_ip_string = - ip_bytes_to_string(message.mobile_ip_addr_bytes) ; - printf("\n" - "*** Message received from client ***\n" - "\tAP MAC: %s\n" - "\tMobile MAC: %s\n" - "\tMobile IP: %s\n" - "\tSequence number (request timestamp): %llu\n" - "\tRequest arrival time on the AP: %llu\n" - "\tSignal: %d dBm\n" - "\tPosition X: %f\n" - "\tPosition Y: %f\n" - "\tPosition Z: %f\n" - "\tDirection: %hhd\n" - , - ap_mac_string, - mobile_mac_string, - mobile_ip_string, - timeval_to_ms(message.request_time), - timeval_to_ms(message.start_time), - message.antenna_signal_dbm - 0x100, - message.x_position, - message.y_position, - message.z_position, - message.direction - ) ; - free(ap_mac_string) ; - free(mobile_mac_string) ; - free(mobile_ip_string) ; + + if (cfg_getbool(cfg, "verbose")) + { + ap_mac_string = + mac_bytes_to_string(message.ap_mac_addr_bytes) ; + mobile_mac_string = + mac_bytes_to_string(message.mobile_mac_addr_bytes) ; + mobile_ip_string = + ip_bytes_to_string(message.mobile_ip_addr_bytes) ; + printf("\n" + "*** Request received from AP ***\n" + "\tAP MAC: %s\n" + "\tMobile MAC: %s\n" + "\tMobile IP: %s\n" + "\tSequence number (request timestamp): %llu\n" + "\tRequest arrival time on the AP: %llu\n" + "\tSignal: %d dBm\n" + "\tPosition X: %f\n" + "\tPosition Y: %f\n" + "\tPosition Z: %f\n" + "\tDirection: %hhd\n" + , + ap_mac_string, + mobile_mac_string, + mobile_ip_string, + timeval_to_ms(message.request_time), + timeval_to_ms(message.start_time), + message.antenna_signal_dbm - 0x100, + message.x_position, + message.y_position, + message.z_position, + message.direction + ) ; + free(ap_mac_string) ; + free(mobile_mac_string) ; + free(mobile_ip_string) ; + } +#ifdef DEBUG + else + { + ap_mac_string = + mac_bytes_to_string(message.ap_mac_addr_bytes) ; + fprintf(stderr, "Request received from AP « %s ».\n", + ap_mac_string) ; + free(ap_mac_string) ; + } +#endif // DEBUG got_couple_info(message) ; } @@ -1062,16 +1083,28 @@ char* ip_bytes_to_string(unsigned char *ip_binary) void print_usage() { printf("Usage:\n" - "\t%s [-f config_file] [-l listening_port] [-i positionner_ip]" - " [-p positioner_port] [-t aggregate_timeout] [-k keep_timeout]" - " [-c check_interval] [-o output_file] [-A]" - " [-a autocalibration_port] [-K ap_keep_timeout]" - " [-C ap_check_interval]\n" + "\t%s" + " [-f config_file]" + " [-v]" + " [-l listening_port]" + " [-i positionner_ip]" + " [-p positioner_port]" + " [-t aggregate_timeout]" + " [-k keep_timeout]" + " [-c check_interval]" + " [-o output_file]" + " [-A]" + " [-a autocalibration_port]" + " [-K ap_keep_timeout]" + " [-C ap_check_interval]" + "\n" "Main options:\n" "\t-h\t\tPrint this help.\n" "\t-f config_file\tUse 'config_file' instead of the default" " configuration file.\n" + "\t-v\t\tBe verbose (print detailed info on each received" + " message).\n" "Server options:\n" "\t-l listening_port\tOnly requests sent on this port will be"