summaryrefslogtreecommitdiff
path: root/client/advertising.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-11-02 16:03:41 +0200
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-11-02 16:03:41 +0200
commit068e0ba214b9f4ec448a6f28be969d974094e5b4 (patch)
treebd63a551f20946a4156ace6fea01e61cd88a41a9 /client/advertising.c
parent5b9596dac4d0e25c5179be8643726a02c058b00a (diff)
downloadbluez-068e0ba214b9f4ec448a6f28be969d974094e5b4.tar.gz
client: Add set-advertise-{duration, timeout}
This adds the following command which can be used to control the advertisement intervals: [bluetooth]# set-advertise-duration 4 [bluetooth]# set-advertise-timeout 4 [bluetooth]# advertise on [CHG] Controller B8:8A:60:D8:17:D7 SupportedInstances: 0x04 [CHG] Controller B8:8A:60:D8:17:D7 ActiveInstances: 0x01 Advertising object registered [CHG] Controller B8:8A:60:D8:17:D7 SupportedInstances: 0x05 [CHG] Controller B8:8A:60:D8:17:D7 ActiveInstances: 0x00
Diffstat (limited to 'client/advertising.c')
-rw-r--r--client/advertising.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/client/advertising.c b/client/advertising.c
index e950aa278..56093f387 100644
--- a/client/advertising.c
+++ b/client/advertising.c
@@ -59,6 +59,8 @@ static struct ad {
char *type;
char *local_name;
uint16_t local_appearance;
+ uint16_t duration;
+ uint16_t timeout;
char **uuids;
size_t uuids_len;
struct service_data service;
@@ -323,6 +325,32 @@ static gboolean get_appearance(const GDBusPropertyTable *property,
return TRUE;
}
+static gboolean duration_exits(const GDBusPropertyTable *property, void *data)
+{
+ return ad.duration;
+}
+
+static gboolean get_duration(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &ad.duration);
+
+ return TRUE;
+}
+
+static gboolean timeout_exits(const GDBusPropertyTable *property, void *data)
+{
+ return ad.timeout;
+}
+
+static gboolean get_timeout(const GDBusPropertyTable *property,
+ DBusMessageIter *iter, void *user_data)
+{
+ dbus_message_iter_append_basic(iter, DBUS_TYPE_UINT16, &ad.timeout);
+
+ return TRUE;
+}
+
static const GDBusPropertyTable ad_props[] = {
{ "Type", "s", get_type },
{ "ServiceUUIDs", "as", get_uuids, NULL, uuids_exists },
@@ -332,6 +360,8 @@ static const GDBusPropertyTable ad_props[] = {
{ "Includes", "as", get_includes, NULL, includes_exists },
{ "LocalName", "s", get_local_name, NULL, local_name_exits },
{ "Appearance", "q", get_appearance, NULL, appearance_exits },
+ { "Duration", "q", get_duration, NULL, duration_exits },
+ { "Timeout", "q", get_timeout, NULL, timeout_exits },
{ }
};
@@ -592,3 +622,23 @@ void ad_advertise_local_appearance(DBusConnection *conn, uint16_t value)
g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "Appearance");
}
+
+void ad_advertise_duration(DBusConnection *conn, uint16_t value)
+{
+ if (ad.duration == value)
+ return;
+
+ ad.duration = value;
+
+ g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "Duration");
+}
+
+void ad_advertise_timeout(DBusConnection *conn, uint16_t value)
+{
+ if (ad.timeout == value)
+ return;
+
+ ad.timeout = value;
+
+ g_dbus_emit_property_changed(conn, AD_PATH, AD_IFACE, "Timeout");
+}