#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) {
/* 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;
}
/* 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;
}
#include <glib.h>
#include "src/adapter.h"
+#include "src/shared/util.h"
#include "lib/uuid.h"
#include "attrib/gattrib.h"
#include "attrib/att.h"
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;
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);
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;
.value.u16 = GATT_CLIENT_CHARAC_CFG_UUID
};
+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 void attrib_free(void *data)
{
struct attribute *a = data;
att_put_u16(a->handle, value);
/* Attribute Value */
- att_put_uuid(a->uuid, &value[2]);
+ put_uuid_le(&a->uuid, &value[2]);
}
length = enc_find_info_resp(format, adl, pdu, len);