summaryrefslogtreecommitdiff
path: root/client/advertising.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-04-05 16:04:28 -0700
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2023-04-05 17:00:00 -0700
commit070c78c4269c66cfaea75bc9f77fad9b5c4d511c (patch)
tree9752bd23b477831983db354f244b0693d77001dd /client/advertising.c
parenteef2e62a5bc4eb4d90a507b3834937102d906b95 (diff)
downloadbluez-070c78c4269c66cfaea75bc9f77fad9b5c4d511c.tar.gz
client/advertising: Add support for advertise.rsi command
This adds support for advertise.rsi command which can be used to request the generation of RSI and include it as part of advertising data: [bluetooth]# advertise.rsi --help Show/Enable/Disable RSI to be advertised Usage: rsi [on/off] [bluetooth]# advertise.rsi RSI: on [bluetooth]# advertise on ... Advertising object registered Tx Power: off Name: off Appearance: off Discoverable: on RSI: on [bluetooth]#
Diffstat (limited to 'client/advertising.c')
-rw-r--r--client/advertising.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/client/advertising.c b/client/advertising.c
index fb9b049fd..24852d93d 100644
--- a/client/advertising.c
+++ b/client/advertising.c
@@ -67,9 +67,11 @@ static struct ad {
bool tx_power;
bool name;
bool appearance;
+ bool rsi;
} ad = {
.local_appearance = UINT16_MAX,
.discoverable = true,
+ .rsi = true,
};
static void ad_release(DBusConnection *conn)
@@ -175,7 +177,8 @@ static void print_ad(void)
bt_shell_printf("Appearance: %s\n",
ad.appearance ? "on" : "off");
- bt_shell_printf("Discoverable: %s\n", ad.discoverable ? "on": "off");
+ bt_shell_printf("Discoverable: %s\n", ad.discoverable ? "on" : "off");
+ bt_shell_printf("RSI: %s\n", ad.rsi ? "on" : "off");
if (ad.duration)
bt_shell_printf("Duration: %u sec\n", ad.duration);
@@ -295,7 +298,7 @@ static gboolean get_manufacturer_data(const GDBusPropertyTable *property,
static gboolean includes_exists(const GDBusPropertyTable *property, void *data)
{
- return ad.tx_power || ad.name || ad.appearance;
+ return ad.tx_power || ad.name || ad.appearance || ad.rsi;
}
static gboolean get_includes(const GDBusPropertyTable *property,
@@ -323,6 +326,12 @@ static gboolean get_includes(const GDBusPropertyTable *property,
dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &str);
}
+ if (ad.rsi) {
+ const char *str = "rsi";
+
+ dbus_message_iter_append_basic(&array, DBUS_TYPE_STRING, &str);
+ }
+
dbus_message_iter_close_container(iter, &array);
@@ -1023,3 +1032,20 @@ void ad_advertise_interval(DBusConnection *conn, uint32_t *min, uint32_t *max)
return bt_shell_noninteractive_quit(EXIT_SUCCESS);
}
+
+void ad_advertise_rsi(DBusConnection *conn, dbus_bool_t *value)
+{
+ if (!value) {
+ bt_shell_printf("RSI: %s\n", ad.rsi ? "on" : "off");
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+ }
+
+ if (ad.rsi == *value)
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+
+ ad.rsi = *value;
+
+ g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "Includes");
+
+ return bt_shell_noninteractive_quit(EXIT_SUCCESS);
+}