struct service_data service;
struct manufacturer_data manufacturer;
struct data data;
+ bool discoverable;
bool tx_power;
bool name;
bool appearance;
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 },
{ "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 },
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) {
ad_advertise_data(dbus_conn, argc, argv);
}
+static void cmd_advertise_discoverable(int argc, char *argv[])
+{
+ dbus_bool_t discoverable;
+
+ if (argc < 2) {
+ ad_advertise_discoverable(dbus_conn, NULL);
+ return;
+ }
+
+ if (!parse_argument(argc, argv, NULL, NULL, &discoverable, NULL))
+ return bt_shell_noninteractive_quit(EXIT_FAILURE);
+
+ ad_advertise_discoverable(dbus_conn, &discoverable);
+}
+
static void cmd_advertise_tx_power(int argc, char *argv[])
{
dbus_bool_t powered;
"Set/Get advertise manufacturer data" },
{ "data", "[type] [data=xx xx ...]", cmd_advertise_data,
"Set/Get advertise data" },
+ { "discoverable", "[on/off]", cmd_advertise_discoverable,
+ "Set/Get advertise discoverable" },
{ "tx-power", "[on/off]", cmd_advertise_tx_power,
"Show/Enable/Disable TX power to be advertised",
NULL },