summaryrefslogtreecommitdiff
path: root/src/advertising.c
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-08-10 13:45:13 +0300
committerLuiz Augusto von Dentz <luiz.von.dentz@intel.com>2017-08-10 16:32:08 +0300
commit80cee3a56c2066737c6915772c034e4ad3a1de32 (patch)
tree20b8d7c9f949b4629024330483c66769a75296a9 /src/advertising.c
parent177eccc14523bfd936323ba6bb422ff087a3b626 (diff)
downloadbluez-80cee3a56c2066737c6915772c034e4ad3a1de32.tar.gz
advertising: Add Appearance property
With this property applications can select their own appearance to be advertised, as opposed to just including the adapter's appearance.
Diffstat (limited to 'src/advertising.c')
-rw-r--r--src/advertising.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/src/advertising.c b/src/advertising.c
index e45207071..9eb22b9fd 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -62,6 +62,7 @@ struct btd_adv_client {
char *owner;
char *path;
char *name;
+ uint16_t appearance;
GDBusClient *client;
GDBusProxy *proxy;
DBusMessage *reg;
@@ -472,6 +473,22 @@ static bool parse_local_name(DBusMessageIter *iter,
return true;
}
+static bool parse_appearance(DBusMessageIter *iter,
+ struct btd_adv_client *client)
+{
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
+ return false;
+
+ if (client->flags & MGMT_ADV_FLAG_APPEARANCE) {
+ error("Appearance already included");
+ return false;
+ }
+
+ dbus_message_iter_get_basic(iter, &client->appearance);
+
+ return true;
+}
+
static struct adv_parser {
const char *name;
bool (*func)(DBusMessageIter *iter, struct btd_adv_client *client);
@@ -483,6 +500,7 @@ static struct adv_parser {
{ "ServiceData", parse_service_data },
{ "Includes", parse_includes },
{ "LocalName", parse_local_name },
+ { "Appearance", parse_appearance },
{ },
};
@@ -562,10 +580,18 @@ static size_t calc_max_adv_len(struct btd_adv_client *client, uint32_t flags)
static uint8_t *generate_adv_data(struct btd_adv_client *client,
uint32_t *flags, size_t *len)
{
- if ((*flags & MGMT_ADV_FLAG_APPEARANCE)) {
- *flags &= ~MGMT_ADV_FLAG_APPEARANCE;
- /* TODO: Get the appearance from the adaptor once supported. */
- bt_ad_add_appearance(client->data, 0x0000);
+ if ((*flags & MGMT_ADV_FLAG_APPEARANCE) ||
+ client->appearance != UINT16_MAX) {
+ uint16_t appearance;
+
+ appearance = client->appearance;
+ if (appearance == UINT16_MAX)
+ /* TODO: Get the appearance from the adaptor once
+ * supported.
+ */
+ appearance = 0x000;
+
+ bt_ad_add_appearance(client->data, appearance);
}
return bt_ad_generate(client->data, len);
@@ -753,6 +779,7 @@ static struct btd_adv_client *client_create(struct btd_adv_manager *manager,
goto fail;
client->manager = manager;
+ client->appearance = UINT16_MAX;
return client;