[i-c] Make more verbose autocalibration exchanges
When in debug mode, aggregator and listener both output information when sending or receiving autocalibration hello messages or orders.
This commit is contained in:
parent
564996262a
commit
05ceea9950
|
@ -30,6 +30,7 @@
|
||||||
#define ERR_CREATING_SOCKET 2 // Erreur when creating listening socket
|
#define ERR_CREATING_SOCKET 2 // Erreur when creating listening socket
|
||||||
#define ERR_BAD_USAGE 3 // Bad program call
|
#define ERR_BAD_USAGE 3 // Bad program call
|
||||||
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
#define ERR_PARSING_CONFIG_FILE 4 // Error reading the configuration file
|
||||||
|
#define ERR_SENDING_INFO 5 // Error sending a message on a socket
|
||||||
|
|
||||||
|
|
||||||
/* Linked list storing data of couples MAC / sequence number */
|
/* Linked list storing data of couples MAC / sequence number */
|
||||||
|
|
|
@ -692,9 +692,9 @@ void listen_for_aps(void)
|
||||||
fprintf(stderr, "No message received from aggregator!\n") ;
|
fprintf(stderr, "No message received from aggregator!\n") ;
|
||||||
continue ;
|
continue ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
else
|
fprintf(stderr, "Got a Hello message.\n") ;
|
||||||
fprintf(stderr, "Got a Hello message.\n") ;
|
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
update_ap(message.ap_mac_addr_bytes, message.ap_ip_addr) ;
|
update_ap(message.ap_mac_addr_bytes, message.ap_ip_addr) ;
|
||||||
|
@ -870,14 +870,26 @@ void order_send(ap_list *ap)
|
||||||
struct sockaddr_in serv;
|
struct sockaddr_in serv;
|
||||||
struct sockaddr_in client ;
|
struct sockaddr_in client ;
|
||||||
socklen_t serv_len = sizeof(serv);
|
socklen_t serv_len = sizeof(serv);
|
||||||
int sockfd =
|
int sockfd ;
|
||||||
|
ssize_t nsent ;
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "Sending an order to %s...\n", ap->ip_addr) ;
|
||||||
|
#endif // DEBUG
|
||||||
|
|
||||||
|
sockfd =
|
||||||
create_udp_sending_socket(ap->ip_addr,
|
create_udp_sending_socket(ap->ip_addr,
|
||||||
cfg_getint(cfg, "autocalibration_port"),
|
cfg_getint(cfg, "autocalibration_port"),
|
||||||
&serv, &client) ;
|
&serv, &client) ;
|
||||||
|
|
||||||
message.order = AUTOCALIBRATION_ORDER_SEND ;
|
message.order = AUTOCALIBRATION_ORDER_SEND ;
|
||||||
sendto(sockfd, (void *)&message, sizeof(message), 0,
|
nsent = sendto(sockfd, (void *)&message, sizeof(message), 0,
|
||||||
(struct sockaddr *)&serv, serv_len) ;
|
(struct sockaddr *)&serv, serv_len) ;
|
||||||
|
if (nsent != (ssize_t) sizeof(message))
|
||||||
|
{
|
||||||
|
perror("Error sending order to the listener") ;
|
||||||
|
exit(ERR_SENDING_INFO) ;
|
||||||
|
}
|
||||||
|
|
||||||
(void) close(sockfd) ;
|
(void) close(sockfd) ;
|
||||||
}
|
}
|
||||||
|
@ -1011,7 +1023,8 @@ void print_usage()
|
||||||
"\t%s [-f config_file] [-l listening_port] [-i positionner_ip]"
|
"\t%s [-f config_file] [-l listening_port] [-i positionner_ip]"
|
||||||
" [-p positioner_port] [-t aggregate_timeout] [-k keep_timeout]"
|
" [-p positioner_port] [-t aggregate_timeout] [-k keep_timeout]"
|
||||||
" [-c check_interval] [-o output_file] [-A]"
|
" [-c check_interval] [-o output_file] [-A]"
|
||||||
" [-a autocalibration_port]\n"
|
" [-a autocalibration_port] [-K ap_keep_timeout]"
|
||||||
|
" [-C ap_check_interval]\n"
|
||||||
|
|
||||||
"Main options:\n"
|
"Main options:\n"
|
||||||
"\t-h\t\tPrint this help.\n"
|
"\t-h\t\tPrint this help.\n"
|
||||||
|
@ -1031,7 +1044,7 @@ void print_usage()
|
||||||
" 'aggregate_timeout' milliseconds before to be grouped"
|
" 'aggregate_timeout' milliseconds before to be grouped"
|
||||||
" (default: %d ms).\n"
|
" (default: %d ms).\n"
|
||||||
"\t-k keep_timeout\t\tAggregated requests are kept during"
|
"\t-k keep_timeout\t\tAggregated requests are kept during"
|
||||||
" 'keep_timeout' milliseconds (default: %d milliseconds).\n"
|
" 'keep_timeout' milliseconds (default: %d ms).\n"
|
||||||
"\t-c check_interval\tTime between two checks of the stored"
|
"\t-c check_interval\tTime between two checks of the stored"
|
||||||
" requests (default\t%d microseconds).\n"
|
" requests (default\t%d microseconds).\n"
|
||||||
|
|
||||||
|
|
|
@ -918,12 +918,16 @@ void autocalibrate()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.order == AUTOCALIBRATION_ORDER_SEND)
|
if (message.order == AUTOCALIBRATION_ORDER_SEND)
|
||||||
send_autocalibration_request() ;
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "I just was ordered to send an autocalibration"
|
||||||
|
" request...\n") ;
|
||||||
|
#endif // DEBUG
|
||||||
|
send_autocalibration_request() ;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Autocalibration order unknown: %d.\n", message.order) ;
|
"Autocalibration order unknown: %d.\n", message.order) ;
|
||||||
#endif // DEBUG
|
|
||||||
}
|
}
|
||||||
|
|
||||||
(void) close(listen_sockfd) ;
|
(void) close(listen_sockfd) ;
|
||||||
|
|
Loading…
Reference in New Issue