summaryrefslogtreecommitdiff
path: root/mesh/main.c
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@gmail.com>2023-05-05 12:39:31 -0700
committerBrian Gix <brian.gix@gmail.com>2023-05-12 11:22:14 -0700
commit93d0d8b2fc696212743be2fe9cedcf0edb1073d4 (patch)
tree8657b05f8c1b87af1655d1381e41045a35c87e84 /mesh/main.c
parent8c452c2ec1739efe581273bacd738e5294d0ca0f (diff)
downloadbluez-93d0d8b2fc696212743be2fe9cedcf0edb1073d4.tar.gz
mesh: Update the behavior of --io option
This aligns the behavior of command line option --io to add new "auto" value and modify the behavior of "generic" value: *auto* - Use first available controller: via MGMT interface if kernel supports it, otherwise, via raw HCI socket (i.e., default to *generic*). *generic:[hci]<index>* - Use generic HCI io on interface hci<index> The default value is now *auto*, whereas *generic* is used only if the specific HCI controller is explicitly specified.
Diffstat (limited to 'mesh/main.c')
-rw-r--r--mesh/main.c40
1 files changed, 12 insertions, 28 deletions
diff --git a/mesh/main.c b/mesh/main.c
index 3bca020a0..145bcfa98 100644
--- a/mesh/main.c
+++ b/mesh/main.c
@@ -48,6 +48,12 @@ static const struct option main_options[] = {
{ }
};
+static const char *io_usage =
+ "\t(auto | generic:[hci]<index> | unit:<fd_path>)\n"
+ "\t\tauto - Use first available controller (MGMT or raw HCI)\n"
+ "\t\tgeneric - Use raw HCI io on interface hci<index>\n"
+ "\t\tunit - Use test IO (for automatic testing only)\n";
+
static void usage(void)
{
fprintf(stderr,
@@ -55,18 +61,14 @@ static void usage(void)
"\tbluetooth-meshd [options]\n");
fprintf(stderr,
"Options:\n"
- "\t--io <io> Use specified io (default: generic)\n"
+ "\t--io <io> Use specified io (default: auto)\n"
"\t--config Daemon configuration directory\n"
"\t--storage Mesh node(s) configuration directory\n"
"\t--nodetach Run in foreground\n"
"\t--debug Enable debug output\n"
"\t--dbus-debug Enable D-Bus debugging\n"
"\t--help Show %s information\n", __func__);
- fprintf(stderr,
- "io:\n"
- "\t([hci]<index> | generic[:[hci]<index>] | unit:<fd_path>)\n"
- "\t\tUse generic HCI io on interface hci<index>, or the first\n"
- "\t\tavailable one\n");
+ fprintf(stderr, "\n\t io: %s", io_usage);
}
static void do_debug(const char *str, void *user_data)
@@ -157,21 +159,8 @@ static bool parse_io(const char *optarg, enum mesh_io_type *type, void **opts)
*opts = index;
optarg += strlen("auto");
- if (!*optarg) {
- *index = MGMT_INDEX_NONE;
- return true;
- }
-
- if (*optarg != ':')
- return false;
-
- optarg++;
-
- if (sscanf(optarg, "hci%d", index) == 1)
- return true;
-
- if (sscanf(optarg, "%d", index) == 1)
- return true;
+ *index = MGMT_INDEX_NONE;
+ return true;
return false;
} else if (strstr(optarg, "generic") == optarg) {
@@ -181,12 +170,7 @@ static bool parse_io(const char *optarg, enum mesh_io_type *type, void **opts)
*opts = index;
optarg += strlen("generic");
- if (!*optarg) {
- *index = MGMT_INDEX_NONE;
- return true;
- }
-
- if (*optarg != ':')
+ if (!*optarg || *optarg != ':')
return false;
optarg++;
@@ -291,7 +275,7 @@ int main(int argc, char *argv[])
io = l_strdup_printf("auto");
if (!parse_io(io, &io_type, &io_opts)) {
- l_error("Invalid io: %s", io);
+ l_error("Invalid io: %s\n%s", io, io_usage);
status = EXIT_FAILURE;
goto done;
}