[Aggregator] Send order to APs
Add options -C and -K. Rename default autocalibration values in aggregator and listener.
This commit is contained in:
parent
f35170173a
commit
f804855309
|
@ -15,11 +15,13 @@
|
||||||
|
|
||||||
|
|
||||||
/* Arguments & program configuration */
|
/* Arguments & program configuration */
|
||||||
#define OPTIONS "Aa:c:f:hi:k:l:o:p:t:" // getopt string
|
#define OPTIONS "Aa:c:C:f:hi:k:K:l:o:p:t:" // getopt string
|
||||||
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
|
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-aggregator.conf"
|
||||||
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
|
#define DEFAULT_AGGREGATE_TIMEOUT 1500 // milliseconds
|
||||||
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
#define DEFAULT_KEEP_TIMEOUT 3000 // milliseconds
|
||||||
#define DEFAULT_CHECK_INTERVAL 500000 // microseconds
|
#define DEFAULT_CHECK_INTERVAL 500000 // microseconds
|
||||||
|
#define DEFAULT_AP_KEEP_TIMEOUT 600 // s
|
||||||
|
#define DEFAULT_AP_CHECK_INTERVAL 1000 // ms
|
||||||
#define POSITIONER_DEFAULT_IP "127.0.0.1"
|
#define POSITIONER_DEFAULT_IP "127.0.0.1"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -103,8 +103,12 @@ void parse_config_file(int argc, char **argv)
|
||||||
// Autocalibration activated?
|
// Autocalibration activated?
|
||||||
CFG_BOOL("autocalibration", cfg_false, CFGF_NONE),
|
CFG_BOOL("autocalibration", cfg_false, CFGF_NONE),
|
||||||
// Port on which autocalibration data are exchanged:
|
// Port on which autocalibration data are exchanged:
|
||||||
CFG_INT("autocalbration_port", AUTOCALIBRATION_DEFAULT_PORT,
|
CFG_INT("autocalbration_port", DEFAULT_AUTOCALIBRATION_PORT,
|
||||||
CFGF_NONE),
|
CFGF_NONE),
|
||||||
|
// Time we keep APs in the list (in seconds):
|
||||||
|
CFG_INT("ap_keep_timeout", DEFAULT_AP_KEEP_TIMEOUT, CFGF_NONE),
|
||||||
|
// Time between two checks of the AP list (in milliseconds):
|
||||||
|
CFG_INT("ap_check_interval", DEFAULT_AP_CHECK_INTERVAL, CFGF_NONE),
|
||||||
|
|
||||||
CFG_END()
|
CFG_END()
|
||||||
} ;
|
} ;
|
||||||
|
@ -168,6 +172,9 @@ void parse_command_line(int argc, char **argv)
|
||||||
case 'c' :
|
case 'c' :
|
||||||
cfg_setint(cfg, "check_interval", strtol(optarg, NULL, 0)) ;
|
cfg_setint(cfg, "check_interval", strtol(optarg, NULL, 0)) ;
|
||||||
break ;
|
break ;
|
||||||
|
case 'C' :
|
||||||
|
cfg_setint(cfg, "ap_check_interval", strtol(optarg, NULL, 0)) ;
|
||||||
|
break ;
|
||||||
case 'f' : // Config file
|
case 'f' : // Config file
|
||||||
break ; // (already parsed)
|
break ; // (already parsed)
|
||||||
case 'h' :
|
case 'h' :
|
||||||
|
@ -179,6 +186,9 @@ void parse_command_line(int argc, char **argv)
|
||||||
case 'k' :
|
case 'k' :
|
||||||
cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ;
|
cfg_setint(cfg, "keep_timeout", strtol(optarg, NULL, 0)) ;
|
||||||
break ;
|
break ;
|
||||||
|
case 'K' :
|
||||||
|
cfg_setint(cfg, "ap_keep_timeout", strtol(optarg, NULL, 0)) ;
|
||||||
|
break ;
|
||||||
case 'l' :
|
case 'l' :
|
||||||
cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ;
|
cfg_setint(cfg, "listening_port", strtol(optarg, NULL, 0)) ;
|
||||||
break ;
|
break ;
|
||||||
|
@ -247,6 +257,26 @@ void check_configuration()
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
cfg_setint(cfg, "check_interval", DEFAULT_CHECK_INTERVAL) ;
|
cfg_setint(cfg, "check_interval", DEFAULT_CHECK_INTERVAL) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ap_keep_timeout //
|
||||||
|
if (cfg_getint(cfg, "ap_keep_timeout") < 0)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "Warning! ap_keep_timeout cannot be negative:"
|
||||||
|
" failing back to default value.\n") ;
|
||||||
|
#endif // DEBUG
|
||||||
|
cfg_setint(cfg, "ap_keep_timeout", DEFAULT_AP_KEEP_TIMEOUT) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ap_check_interval //
|
||||||
|
if (cfg_getint(cfg, "ap_check_interval") < 0)
|
||||||
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
fprintf(stderr, "Warning! ap_check_interval cannot be negative:"
|
||||||
|
" failing back to default value.\n") ;
|
||||||
|
#endif // DEBUG
|
||||||
|
cfg_setint(cfg, "ap_check_interval", DEFAULT_AP_CHECK_INTERVAL) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -763,7 +793,7 @@ void monitor_aps()
|
||||||
if (nb_aps > 1)
|
if (nb_aps > 1)
|
||||||
order_send(aps) ;
|
order_send(aps) ;
|
||||||
|
|
||||||
usleep(cfg_getint(cfg, "ap_check_interval")) ;
|
usleep(cfg_getint(cfg, "ap_check_interval") * 1000) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -779,7 +809,7 @@ void delete_old_aps()
|
||||||
|
|
||||||
while (aps != NULL)
|
while (aps != NULL)
|
||||||
if (sub_date(aps->last_seen, now) >
|
if (sub_date(aps->last_seen, now) >
|
||||||
(unsigned long) cfg_getint(cfg, "keep_ap_timeout"))
|
(unsigned long) cfg_getint(cfg, "ap_keep_timeout") * 1000)
|
||||||
delete_ap(aps) ;
|
delete_ap(aps) ;
|
||||||
else
|
else
|
||||||
return ;
|
return ;
|
||||||
|
@ -819,9 +849,25 @@ void unlink_ap(ap_list *ap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Sends a send order to the given AP.
|
||||||
|
*/
|
||||||
void order_send(ap_list *ap)
|
void order_send(ap_list *ap)
|
||||||
{
|
{
|
||||||
|
autocalibration_order message ;
|
||||||
|
struct sockaddr_in serv;
|
||||||
|
struct sockaddr_in client ;
|
||||||
|
socklen_t serv_len = sizeof(serv);
|
||||||
|
int sockfd =
|
||||||
|
create_udp_sending_socket(ap->ip_addr,
|
||||||
|
cfg_getint(cfg, "autocalibration_port"),
|
||||||
|
&serv, &client) ;
|
||||||
|
|
||||||
|
message.order = AUTOCALIBRATION_ORDER_SEND ;
|
||||||
|
sendto(sockfd, (void *)&message, sizeof(message), 0,
|
||||||
|
(struct sockaddr *)&serv, serv_len) ;
|
||||||
|
|
||||||
|
(void) close(sockfd) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -970,8 +1016,8 @@ void print_usage()
|
||||||
|
|
||||||
"Aggregation options:\n"
|
"Aggregation options:\n"
|
||||||
"\t-t aggregate_timeout\tRequests are stored during"
|
"\t-t aggregate_timeout\tRequests are stored during"
|
||||||
" 'aggregate_timeout' before to be grouped (default:"
|
" 'aggregate_timeout' milliseconds before to be grouped"
|
||||||
" %d millisecondes).\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 milliseconds).\n"
|
||||||
"\t-c check_interval\tTime between two checks of the stored"
|
"\t-c check_interval\tTime between two checks of the stored"
|
||||||
|
@ -981,6 +1027,10 @@ void print_usage()
|
||||||
"\t-A\tEnable autocalibration (default: disabled).\n"
|
"\t-A\tEnable autocalibration (default: disabled).\n"
|
||||||
"\t-a port\tPort on which autocalibration data"
|
"\t-a port\tPort on which autocalibration data"
|
||||||
" are exchanged with the listeners (default: %d).\n"
|
" are exchanged with the listeners (default: %d).\n"
|
||||||
|
"\t-K ap_keep_timeout\tInactive APs are kept during"
|
||||||
|
" 'ap_keep_timeout' seconds (default: %d s).\n"
|
||||||
|
"\t-C ap_check_interval\tTime (in milliseconds) between two"
|
||||||
|
" checks of the stored APs (default: %d ms).\n"
|
||||||
,
|
,
|
||||||
program_name,
|
program_name,
|
||||||
AGGREGATE_DEFAULT_PORT,
|
AGGREGATE_DEFAULT_PORT,
|
||||||
|
@ -989,6 +1039,8 @@ void print_usage()
|
||||||
DEFAULT_AGGREGATE_TIMEOUT,
|
DEFAULT_AGGREGATE_TIMEOUT,
|
||||||
DEFAULT_KEEP_TIMEOUT,
|
DEFAULT_KEEP_TIMEOUT,
|
||||||
DEFAULT_CHECK_INTERVAL,
|
DEFAULT_CHECK_INTERVAL,
|
||||||
AUTOCALIBRATION_DEFAULT_PORT
|
DEFAULT_AUTOCALIBRATION_PORT,
|
||||||
|
DEFAULT_AP_KEEP_TIMEOUT,
|
||||||
|
DEFAULT_AP_CHECK_INTERVAL
|
||||||
) ;
|
) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,9 +51,9 @@
|
||||||
#define OPTIONS "Aa:d:f:hH:kl:m:n:p:qr:t:vw:" // getopt string
|
#define OPTIONS "Aa:d:f:hH:kl:m:n:p:qr:t:vw:" // getopt string
|
||||||
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf"
|
#define DEFAULT_CONFIG_FILE "/usr/local/etc/owlps/owlps-listener.conf"
|
||||||
enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
enum {MODE_ACTIVE = 'a', MODE_PASSIVE = 'p', MODE_MIXED = 'm'} ;
|
||||||
#define AUTOCALIBRATION_DEFAULT_HELLO_DELAY 120 // seconds
|
#define DEFAULT_AUTOCALIBRATION_HELLO_DELAY 120 // seconds
|
||||||
#define AUTOCALIBRATION_DEFAULT_DELAY 25000 // ms
|
#define DEFAULT_AUTOCALIBRATION_DELAY 25000 // ms
|
||||||
#define AUTOCALIBRATION_DEFAULT_NBPKT 20
|
#define DEFAULT_AUTOCALIBRATION_NBPKT 20
|
||||||
|
|
||||||
|
|
||||||
/* Error codes */
|
/* Error codes */
|
||||||
|
|
|
@ -53,10 +53,10 @@ struct {
|
||||||
"",
|
"",
|
||||||
#ifdef USE_PTHREAD
|
#ifdef USE_PTHREAD
|
||||||
FALSE,
|
FALSE,
|
||||||
AUTOCALIBRATION_DEFAULT_PORT,
|
DEFAULT_AUTOCALIBRATION_PORT,
|
||||||
AUTOCALIBRATION_DEFAULT_HELLO_DELAY,
|
DEFAULT_AUTOCALIBRATION_HELLO_DELAY,
|
||||||
AUTOCALIBRATION_DEFAULT_DELAY,
|
DEFAULT_AUTOCALIBRATION_DELAY,
|
||||||
AUTOCALIBRATION_DEFAULT_NBPKT,
|
DEFAULT_AUTOCALIBRATION_NBPKT,
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
FALSE
|
FALSE
|
||||||
} ;
|
} ;
|
||||||
|
@ -163,18 +163,18 @@ void parse_config_file(int argc, char **argv)
|
||||||
// Autocalibration activated?
|
// Autocalibration activated?
|
||||||
CFG_BOOL("autocalibration", cfg_false, CFGF_NONE),
|
CFG_BOOL("autocalibration", cfg_false, CFGF_NONE),
|
||||||
// Port on which autocalibration data are exchanged:
|
// Port on which autocalibration data are exchanged:
|
||||||
CFG_INT("autocalibration_port", AUTOCALIBRATION_DEFAULT_PORT,
|
CFG_INT("autocalibration_port", DEFAULT_AUTOCALIBRATION_PORT,
|
||||||
CFGF_NONE),
|
CFGF_NONE),
|
||||||
// Delay between two hello messages:
|
// Delay between two hello messages:
|
||||||
CFG_INT("autocalibration_hello_delay",
|
CFG_INT("autocalibration_hello_delay",
|
||||||
AUTOCALIBRATION_DEFAULT_HELLO_DELAY,
|
DEFAULT_AUTOCALIBRATION_HELLO_DELAY,
|
||||||
CFGF_NONE),
|
CFGF_NONE),
|
||||||
// Delay between two calibration packet transmission:
|
// Delay between two calibration packet transmission:
|
||||||
CFG_INT("autocalibration_delay", AUTOCALIBRATION_DEFAULT_DELAY,
|
CFG_INT("autocalibration_delay", DEFAULT_AUTOCALIBRATION_DELAY,
|
||||||
CFGF_NONE),
|
CFGF_NONE),
|
||||||
// Number of packets for a calibration request:
|
// Number of packets for a calibration request:
|
||||||
CFG_INT("autocalibration_nb_packets",
|
CFG_INT("autocalibration_nb_packets",
|
||||||
AUTOCALIBRATION_DEFAULT_NBPKT, CFGF_NONE),
|
DEFAULT_AUTOCALIBRATION_NBPKT, CFGF_NONE),
|
||||||
#endif // USE_PTHREAD
|
#endif // USE_PTHREAD
|
||||||
// Display capture packets, or not:
|
// Display capture packets, or not:
|
||||||
CFG_BOOL("verbose", cfg_false, CFGF_NONE),
|
CFG_BOOL("verbose", cfg_false, CFGF_NONE),
|
||||||
|
@ -1005,9 +1005,9 @@ void print_usage()
|
||||||
DEFAULT_CONFIG_FILE,
|
DEFAULT_CONFIG_FILE,
|
||||||
LOC_REQUEST_DEFAULT_PORT,
|
LOC_REQUEST_DEFAULT_PORT,
|
||||||
AGGREGATE_DEFAULT_PORT,
|
AGGREGATE_DEFAULT_PORT,
|
||||||
AUTOCALIBRATION_DEFAULT_PORT,
|
DEFAULT_AUTOCALIBRATION_PORT,
|
||||||
AUTOCALIBRATION_DEFAULT_HELLO_DELAY,
|
DEFAULT_AUTOCALIBRATION_HELLO_DELAY,
|
||||||
AUTOCALIBRATION_DEFAULT_DELAY,
|
DEFAULT_AUTOCALIBRATION_DELAY,
|
||||||
AUTOCALIBRATION_DEFAULT_NBPKT
|
DEFAULT_AUTOCALIBRATION_NBPKT
|
||||||
) ;
|
) ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
#define POSITIONER_DEFAULT_PORT 9902
|
#define POSITIONER_DEFAULT_PORT 9902
|
||||||
// Port on which listener listens for order from aggregator:
|
// Port on which listener listens for order from aggregator:
|
||||||
#define LISTENER_DEFAULT_PORT 9903
|
#define LISTENER_DEFAULT_PORT 9903
|
||||||
#define AUTOCALIBRATION_DEFAULT_PORT 9904
|
#define DEFAULT_AUTOCALIBRATION_PORT 9904
|
||||||
// Port on which the mobile listens for its position:
|
// Port on which the mobile listens for its position:
|
||||||
#define MOBILE_DEFAULT_PORT 9910
|
#define MOBILE_DEFAULT_PORT 9910
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue