diff --git a/tools/mcaptest.c b/tools/mcaptest.c
index c44750f..6aba7a5 100644
--- a/tools/mcaptest.c
+++ b/tools/mcaptest.c
#define REQ_CLOCK_ACC 0x1400
-static void mdl_connected_cb(struct mcap_mdl *mdl, void *data)
+static void mdl_close(struct mcap_mdl *mdl)
{
int fd = -1;
printf("%s\n", __func__);
- if (mdl_disconnect && mdl_disconnect_timeout >= 0) {
+ if (mdl_disconnect_timeout >= 0)
sleep(mdl_disconnect_timeout);
- fd = mcap_mdl_get_fd(mdl);
+ fd = mcap_mdl_get_fd(mdl);
- if (fd > 0)
- close(fd);
- }
+ if (fd > 0)
+ close(fd);
+}
+
+static void mdl_connected_cb(struct mcap_mdl *mdl, void *data)
+{
+ printf("%s\n", __func__);
+
+ if (mdl_disconnect)
+ mdl_close(mdl);
}
static void mdl_closed_cb(struct mcap_mdl *mdl, void *data)
if (mcl_disconnect && mcl_disconnect_timeout >= 0) {
sleep(mcl_disconnect_timeout);
+ printf("Closing MCAP communication link\n");
mcap_close_mcl(mcl, TRUE);
+
+ if (no_close)
+ return;
+
+ g_main_loop_quit(mloop);
}
}
{
/* TODO */
printf("%s\n", __func__);
+
+ /* Disconnecting MDL latency timeout */
+ if (mdl_disconnect_timeout >= 0)
+ sleep(mdl_disconnect_timeout);
}
static void mdl_aborted_cb(struct mcap_mdl *mdl, void *data)
"\tmcaptest <control_mode> <data_mode> [options]\n");
printf("Control Link Mode:\n"
"\t-c connect <dst_addr>\n"
+ "\t-b close control link after closing data link\n"
"\t-e <timeout> disconnect MCL and quit after MDL is closed\n"
"\t-g send clock sync capability request if MCL connected\n");
printf("Data Link Mode:\n"
"\t-d connect\n"
+ "\t-a close data link immediately after being connected"
"\t-f <timeout> disconnect MDL after it's connected\n"
"\t-u send \'Unavailable\' on first MDL connection request\n");
printf("Options:\n"
{ "disconnect_cl", 1, 0, 'e' },
{ "synccap_req", 0, 0, 'g' },
{ "connect_dl", 0, 0, 'd' },
+ { "disconnect_da", 0, 0, 'a' },
+ { "disconnect_ca", 0, 0, 'b' },
{ "disconnect_dl", 1, 0, 'f' },
{ "unavailable_dl", 0, 0, 'u' },
{ "no exit mcl dis/err",0, 0, 'n' },
exit(1);
}
- while ((opt = getopt_long(argc, argv, "+i:c:C:D:e:f:dghun",
+ while ((opt = getopt_long(argc, argv, "+i:c:C:D:e:f:dghunab",
main_options, NULL)) != EOF) {
switch (opt) {
case 'i':
break;
- case 'e':
+ case 'a':
+ mdl_disconnect = TRUE;
+
+ break;
+
+ case 'b':
mcl_disconnect = TRUE;
+
+ break;
+
+ case 'e':
mcl_disconnect_timeout = atoi(optarg);
break;
case 'f':
- mdl_disconnect = TRUE;
mdl_disconnect_timeout = atoi(optarg);
break;