diff --git a/android/README b/android/README
index b7ecf5f..6ee0c69 100644
--- a/android/README
+++ b/android/README
After changing property value Bluetooth needs to be restarted to apply changes.
+There is also a possibility to enable mgmt debug logs which also enables debugs
+as above. To enable it procced in the same way as described above but use
+system properties called: persist.sys.bluetooth.mgmtdbg
+
Note: Debugs are only available on NON USER build variants
=============================
Building and running on Linux
diff --git a/android/bluetooth.c b/android/bluetooth.c
index c6e40ca..ba4f14b 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
static struct ipc *hal_ipc = NULL;
+static void mgmt_debug(const char *str, void *user_data)
+{
+ const char *prefix = user_data;
+ info("%s%s", prefix, str);
+}
+
static void store_adapter_config(void)
{
GKeyFile *key_file;
cb(-EIO, NULL);
}
-bool bt_bluetooth_start(int index, bt_bluetooth_ready cb)
+bool bt_bluetooth_start(int index, bool mgmt_dbg, bt_bluetooth_ready cb)
{
DBG("index %d", index);
return false;
}
+ if (mgmt_dbg)
+ mgmt_set_debug(mgmt_if, mgmt_debug, "mgmt_if: ", NULL);
+
if (mgmt_send(mgmt_if, MGMT_OP_READ_VERSION, MGMT_INDEX_NONE, 0, NULL,
read_version_complete, cb, NULL) == 0) {
error("Error sending READ_VERSION mgmt command");
diff --git a/android/bluetooth.h b/android/bluetooth.h
index 4731e2b..f436178 100644
--- a/android/bluetooth.h
+++ b/android/bluetooth.h
*/
typedef void (*bt_bluetooth_ready)(int err, const bdaddr_t *addr);
-bool bt_bluetooth_start(int index, bt_bluetooth_ready cb);
+bool bt_bluetooth_start(int index, bool mgmt_dbg, bt_bluetooth_ready cb);
typedef void (*bt_bluetooth_stopped)(void);
bool bt_bluetooth_stop(bt_bluetooth_stopped cb);
diff --git a/android/bluetoothd-wrapper.c b/android/bluetoothd-wrapper.c
index 56b8a78..80c59c9 100644
--- a/android/bluetoothd-wrapper.c
+++ b/android/bluetoothd-wrapper.c
#define PROPERTY_DEBUG_NAME "persist.sys.bluetooth.debug"
+#define PROPERTY_MGMT_DEBUG_NAME "persist.sys.bluetooth.mgmtdbg"
+
#define VALGRIND_BIN "/system/bin/valgrind"
#define BLUETOOTHD_BIN "/system/bin/bluetoothd-main"
execve(prg_argv[0], prg_argv, prg_envp);
}
-static void run_bluetoothd(int debug)
+static void run_bluetoothd(int debug, int mgmt_dbg)
{
- char *prg_argv[3];
+ char *prg_argv[4];
char *prg_envp[1];
prg_argv[0] = BLUETOOTHD_BIN;
prg_argv[1] = debug ? "-d" : NULL;
- prg_argv[2] = NULL;
+ prg_argv[2] = mgmt_dbg ? "--mgmt-debug" : NULL;
+ prg_argv[3] = NULL;
prg_envp[0] = NULL;
{
char value[PROPERTY_VALUE_MAX];
int debug = 0;
+ int mgmt_dbg = 0;
if (property_get(PROPERTY_VALGRIND_NAME, value, "") > 0 &&
(!strcasecmp(value, "true") || atoi(value) > 0))
(!strcasecmp(value, "true") || atoi(value) > 0))
debug = 1;
+ if (property_get(PROPERTY_MGMT_DEBUG_NAME, value, "") > 0 &&
+ (!strcasecmp(value, "true") || atoi(value) > 0)) {
+ debug = 1;
+ mgmt_dbg = 1;
+ }
+
/* In case we failed to execute Valgrind, try to run bluetoothd
* without it
*/
- run_bluetoothd(debug);
+ run_bluetoothd(debug, mgmt_dbg);
return 0;
}
diff --git a/android/main.c b/android/main.c
index edec7dc..a34f885 100644
--- a/android/main.c
+++ b/android/main.c
static gboolean option_version = FALSE;
static gint option_index = -1;
static gboolean option_dbg = FALSE;
+static gboolean option_mgmt_dbg = FALSE;
static GOptionEntry options[] = {
{ "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
"Use specified controller", "INDEX"},
{ "debug", 'd', 0, G_OPTION_ARG_NONE, &option_dbg,
"Enable debug logs", NULL},
+ { "mgmt-debug", 0, 0, G_OPTION_ARG_NONE, &option_mgmt_dbg,
+ "Enable mgmt debug logs", NULL},
+
{ NULL }
};
if (!signal)
return EXIT_FAILURE;
- if (option_dbg)
+ if (option_dbg || option_mgmt_dbg)
__btd_log_init("*", 0);
else
__btd_log_init(NULL, 0);
return EXIT_FAILURE;
}
- if (!bt_bluetooth_start(option_index, adapter_ready)) {
+ if (!bt_bluetooth_start(option_index, option_mgmt_dbg, adapter_ready)) {
__btd_log_cleanup();
g_source_remove(bluetooth_start_timeout);
g_source_remove(signal);