summaryrefslogtreecommitdiff
path: root/client/advertising.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-05-07 18:41:10 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2018-05-24 11:09:30 +0300
commit4f68e5f1fe89702e0fddb69b65ead76499f70d8a (patch)
treec13743b53b6abb1276c3e4c9324115bd9c5dc8c1 /client/advertising.c
parenteca59ac27890843248e764c59ea1b844173d5c63 (diff)
downloadbluez-4f68e5f1fe89702e0fddb69b65ead76499f70d8a.tar.gz
client: Add advertise.discoverable command
This adds advertise.discoverable command which can be used to set it own instance: [bluetooth]# advertise.discoverable on [bluetooth]# advertise on @ MGMT Command: Add Advertising (0x003e) plen 14 Instance: 1 Flags: 0x00000001 Switch into Connectable mode Duration: 0 Timeout: 0 Advertising data length: 3 Flags: 0x02 LE General Discoverable Mode Scan response length: 0 < HCI Command: LE Set Advertising Data (0x08|0x0008) plen 32 Length: 3 Flags: 0x02 LE General Discoverable Mode
Diffstat (limited to 'client/advertising.c')
-rw-r--r--client/advertising.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/client/advertising.c b/client/advertising.c
index 39f99467b..cb0ca4a57 100644
--- a/client/advertising.c
+++ b/client/advertising.c
@@ -71,6 +71,7 @@ static struct ad {
struct service_data service;
struct manufacturer_data manufacturer;
struct data data;
+ bool discoverable;
bool tx_power;
bool name;
bool appearance;
@@ -401,6 +402,21 @@ static gboolean get_data(const GDBusPropertyTable *property,
return TRUE;
}
+static gboolean discoverable_exists(const GDBusPropertyTable *property,
+ void *data)
+{
+ return ad.discoverable;
+}
+
+static gboolean get_discoverable(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN,
+ &ad.discoverable);
+
+ return TRUE;
+}
+
static const GDBusPropertyTable ad_props[] = {
{ "Type", "s", get_type },
{ "ServiceUUIDs", "as", get_uuids, NULL, uuids_exists },
@@ -408,6 +424,7 @@ static const GDBusPropertyTable ad_props[] = {
{ "ManufacturerData", "a{qv}", get_manufacturer_data, NULL,
manufacturer_data_exists },
{ "Data", "a{yv}", get_data, NULL, data_exists },
+ { "Discoverable", "b", get_discoverable, NULL, discoverable_exists },
{ "Includes", "as", get_includes, NULL, includes_exists },
{ "LocalName", "s", get_local_name, NULL, local_name_exits },
{ "Appearance", "q", get_appearance, NULL, appearance_exits },
@@ -708,6 +725,24 @@ void ad_disable_data(DBusConnection *conn)
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+void ad_advertise_discoverable(DBusConnection *conn, dbus_bool_t *value)
+{
+ if (!value) {
+ bt_shell_printf("Discoverable: %s\n",
+ ad.discoverable ? "on" : "off");
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ }
+
+ if (ad.discoverable == *value)
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+
+ ad.discoverable = *value;
+
+ g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "Discoverable");
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}
+
void ad_advertise_tx_power(DBusConnection *conn, dbus_bool_t *value)
{
if (!value) {