diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2014-03-24 16:25:39 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-03-24 22:10:16 +0200 |
commit | e13e1abb8b5fba233dd0594198c44e21568e1a19 (patch) | |
tree | 2a9060a2e5e83004e858bc1d010ab2ac4ee1c444 /attrib | |
parent | 1a1e9b4fa98bec70229cc88fbc7bb7b143853dd7 (diff) | |
download | bluez-e13e1abb8b5fba233dd0594198c44e21568e1a19.tar.gz |
Replace att_put_uuid() by util.h helpers
Diffstat (limited to 'attrib')
-rw-r--r-- | attrib/att.c | 13 | ||||
-rw-r--r-- | attrib/gatt-service.c | 22 |
2 files changed, 24 insertions, 11 deletions
diff --git a/attrib/att.c b/attrib/att.c index bd231426b..bdf7c003e 100644 --- a/attrib/att.c +++ b/attrib/att.c @@ -38,6 +38,15 @@ #include "lib/uuid.h" #include "att.h" +static inline void put_uuid_le(const bt_uuid_t *src, void *dst) +{ + if (src->type == BT_UUID16) + put_le16(src->value.u16, dst); + else + /* Convert from 128-bit BE to LE */ + bswap_128(&src->value.u128, dst); +} + const char *att_ecode2str(uint8_t status) { switch (status) { @@ -156,7 +165,7 @@ uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, bt_uuid_t *uuid, /* Ending Handle (2 octets) */ att_put_u16(end, &pdu[3]); /* Attribute Group Type (2 or 16 octet UUID) */ - att_put_uuid(*uuid, &pdu[5]); + put_uuid_le(uuid, &pdu[5]); return 5 + uuid_len; } @@ -401,7 +410,7 @@ uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid, /* Ending Handle (2 octets) */ att_put_u16(end, &pdu[3]); /* Attribute Type (2 or 16 octet UUID) */ - att_put_uuid(*uuid, &pdu[5]); + put_uuid_le(uuid, &pdu[5]); return 5 + uuid_len; } diff --git a/attrib/gatt-service.c b/attrib/gatt-service.c index d15536cc4..8d80b6939 100644 --- a/attrib/gatt-service.c +++ b/attrib/gatt-service.c @@ -29,6 +29,7 @@ #include <glib.h> #include "src/adapter.h" +#include "src/shared/util.h" #include "lib/uuid.h" #include "attrib/gattrib.h" #include "attrib/att.h" @@ -55,6 +56,15 @@ struct attrib_cb { void *user_data; }; +static inline void put_uuid_le(const bt_uuid_t *src, void *dst) +{ + if (src->type == BT_UUID16) + put_le16(src->value.u16, dst); + else + /* Convert from 128-bit BE to LE */ + bswap_128(&src->value.u128, dst); +} + static GSList *parse_opts(gatt_option opt1, va_list args) { gatt_option opt = opt1; @@ -129,14 +139,8 @@ static struct attribute *add_service_declaration(struct btd_adapter *adapter, uint8_t atval[16]; int len; - if (uuid->type == BT_UUID16) { - att_put_u16(uuid->value.u16, &atval[0]); - len = 2; - } else if (uuid->type == BT_UUID128) { - att_put_u128(uuid->value.u128, &atval[0]); - len = 16; - } else - return NULL; + put_uuid_le(uuid, &atval[0]); + len = bt_uuid_len(uuid); bt_uuid16_create(&bt_uuid, svc); @@ -228,7 +232,7 @@ static gboolean add_characteristic(struct btd_adapter *adapter, bt_uuid16_create(&bt_uuid, GATT_CHARAC_UUID); atval[0] = info->props; att_put_u16(h + 1, &atval[1]); - att_put_uuid(info->uuid, &atval[3]); + put_uuid_le(&info->uuid, &atval[3]); if (attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 3 + info->uuid.type / 8) == NULL) return FALSE; |