diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 21514af..8a43ec1 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
static gchar *opt_src = NULL;
static gchar *opt_dst = NULL;
+static gchar *opt_dst_type = NULL;
static gchar *opt_value = NULL;
static gchar *opt_sec_level = NULL;
static bt_uuid_t *opt_uuid = NULL;
"Specify local adapter interface", "hciX" },
{ "device", 'b', 0, G_OPTION_ARG_STRING, &opt_dst,
"Specify remote Bluetooth address", "MAC" },
+ { "addr-type", 't', 0, G_OPTION_ARG_STRING, &opt_dst_type,
+ "Set LE address type. Default: public", "[public | random]"},
{ "mtu", 'm', 0, G_OPTION_ARG_INT, &opt_mtu,
"Specify the MTU size", "MTU" },
{ "psm", 'p', 0, G_OPTION_ARG_INT, &opt_psm,
GError *gerr = NULL;
GIOChannel *chan;
+ opt_dst_type = g_strdup("public");
opt_sec_level = g_strdup("low");
context = g_option_context_new(NULL);
}
if (opt_interactive) {
- interactive(opt_src, opt_dst, opt_psm);
+ interactive(opt_src, opt_dst, opt_dst_type, opt_psm);
goto done;
}
goto done;
}
- chan = gatt_connect(opt_src, opt_dst, opt_sec_level,
+ chan = gatt_connect(opt_src, opt_dst, opt_dst_type, opt_sec_level,
opt_psm, opt_mtu, connect_cb);
if (chan == NULL) {
got_error = TRUE;
diff --git a/attrib/gatttool.h b/attrib/gatttool.h
index 89ac282..a38339b 100644
--- a/attrib/gatttool.h
+++ b/attrib/gatttool.h
*
*/
-int interactive(const gchar *src, const gchar *dst, gboolean le);
+int interactive(const gchar *src, const gchar *dst, const gchar *dst_type,
+ gboolean le);
GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
- const gchar *sec_level, int psm, int mtu,
- BtIOConnect connect_cb);
+ const gchar *dst_type, const gchar *sec_level,
+ int psm, int mtu, BtIOConnect connect_cb);
size_t gatt_attr_data_from_string(const char *str, uint8_t **data);
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 073e3f7..0a01cdf 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
static gchar *opt_src = NULL;
static gchar *opt_dst = NULL;
+static gchar *opt_dst_type = NULL;
static gchar *opt_sec_level = NULL;
static int opt_psm = 0;
static int opt_mtu = 0;
if (argcp > 1) {
g_free(opt_dst);
opt_dst = g_strdup(argvp[1]);
+
+ g_free(opt_dst_type);
+ if (argcp > 2)
+ opt_dst_type = g_strdup(argvp[2]);
+ else
+ opt_dst_type = g_strdup("public");
}
if (opt_dst == NULL) {
}
set_state(STATE_CONNECTING);
- iochannel = gatt_connect(opt_src, opt_dst, opt_sec_level, opt_psm,
- opt_mtu, connect_cb);
+ iochannel = gatt_connect(opt_src, opt_dst, opt_dst_type, opt_sec_level,
+ opt_psm, opt_mtu, connect_cb);
if (iochannel == NULL)
set_state(STATE_DISCONNECTED);
else
"Exit interactive mode" },
{ "quit", cmd_exit, "",
"Exit interactive mode" },
- { "connect", cmd_connect, "[address]",
+ { "connect", cmd_connect, "[address [address type]]",
"Connect to a remote device" },
{ "disconnect", cmd_disconnect, "",
"Disconnect from a remote device" },
return NULL;
}
-int interactive(const gchar *src, const gchar *dst, int psm)
+int interactive(const gchar *src, const gchar *dst,
+ const gchar *dst_type, int psm)
{
GIOChannel *pchan;
gint events;
opt_src = g_strdup(src);
opt_dst = g_strdup(dst);
+ opt_dst_type = g_strdup(dst_type);
opt_psm = psm;
prompt = g_string_new(NULL);
diff --git a/attrib/utils.c b/attrib/utils.c
index 22d23a4..c951f44 100644
--- a/attrib/utils.c
+++ b/attrib/utils.c
#define ATT_MIN_MTU_L2CAP 48
GIOChannel *gatt_connect(const gchar *src, const gchar *dst,
- const gchar *sec_level, int psm, int mtu,
- BtIOConnect connect_cb)
+ const gchar *dst_type, const gchar *sec_level,
+ int psm, int mtu, BtIOConnect connect_cb)
{
GIOChannel *chan;
bdaddr_t sba, dba;
+ uint8_t dest_type;
GError *err = NULL;
BtIOSecLevel sec;
int minimum_mtu;
} else
bacpy(&sba, BDADDR_ANY);
+ /* Not used for BR/EDR */
+ if (strcmp(dst_type, "random") == 0)
+ dest_type = BDADDR_LE_RANDOM;
+ else
+ dest_type = BDADDR_LE_PUBLIC;
+
if (strcmp(sec_level, "medium") == 0)
sec = BT_IO_SEC_MEDIUM;
else if (strcmp(sec_level, "high") == 0)
chan = bt_io_connect(BT_IO_L2CAP, connect_cb, NULL, NULL, &err,
BT_IO_OPT_SOURCE_BDADDR, &sba,
BT_IO_OPT_DEST_BDADDR, &dba,
+ BT_IO_OPT_DEST_TYPE, dest_type,
BT_IO_OPT_CID, ATT_CID,
BT_IO_OPT_OMTU, mtu,
BT_IO_OPT_SEC_LEVEL, sec,