diff options
author | Claudio Takahasi <claudio.takahasi@openbossa.org> | 2014-03-24 16:25:37 -0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2014-03-24 22:08:20 +0200 |
commit | 91744cb56f13be246a8614800aea3065b46181d3 (patch) | |
tree | dd98768c89dbad773dd3dd15f6e9d2f77c6e3437 /attrib | |
parent | 3f03ab5766de008f008fdd7cfb8679849accc51f (diff) | |
download | bluez-91744cb56f13be246a8614800aea3065b46181d3.tar.gz |
Replace att_get_u16() by get_le16()
Diffstat (limited to 'attrib')
-rw-r--r-- | attrib/att.c | 44 | ||||
-rw-r--r-- | attrib/gatt.c | 14 | ||||
-rw-r--r-- | attrib/gattrib.c | 3 | ||||
-rw-r--r-- | attrib/gatttool.c | 6 | ||||
-rw-r--r-- | attrib/interactive.c | 6 |
5 files changed, 37 insertions, 36 deletions
diff --git a/attrib/att.c b/attrib/att.c index b35349991..1df619011 100644 --- a/attrib/att.c +++ b/attrib/att.c @@ -165,8 +165,8 @@ uint16_t dec_read_by_grp_req(const uint8_t *pdu, size_t len, uint16_t *start, if (len != (min_len + 2) && len != (min_len + 16)) return 0; - *start = att_get_u16(&pdu[1]); - *end = att_get_u16(&pdu[3]); + *start = get_le16(&pdu[1]); + *end = get_le16(&pdu[3]); if (len == min_len + 2) bt_uuid16_create(uuid, get_le16(&pdu[5])); else @@ -293,9 +293,9 @@ uint16_t dec_find_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start, return 0; /* First requested handle number (2 octets) */ - *start = att_get_u16(&pdu[1]); + *start = get_le16(&pdu[1]); /* Last requested handle number (2 octets) */ - *end = att_get_u16(&pdu[3]); + *end = get_le16(&pdu[3]); /* 16-bit UUID to find (2 octets) */ bt_uuid16_create(uuid, get_le16(&pdu[5])); @@ -354,8 +354,8 @@ GSList *dec_find_by_type_resp(const uint8_t *pdu, size_t len) len >= (offset + sizeof(uint16_t) * 2); offset += sizeof(uint16_t) * 2) { range = g_new0(struct att_range, 1); - range->start = att_get_u16(&pdu[offset]); - range->end = att_get_u16(&pdu[offset + 2]); + range->start = get_le16(&pdu[offset]); + range->end = get_le16(&pdu[offset + 2]); matches = g_slist_append(matches, range); } @@ -407,8 +407,8 @@ uint16_t dec_read_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start, if (pdu[0] != ATT_OP_READ_BY_TYPE_REQ) return 0; - *start = att_get_u16(&pdu[1]); - *end = att_get_u16(&pdu[3]); + *start = get_le16(&pdu[1]); + *end = get_le16(&pdu[3]); if (len == min_len + 2) bt_uuid16_create(uuid, get_le16(&pdu[5])); @@ -527,7 +527,7 @@ uint16_t dec_write_cmd(const uint8_t *pdu, size_t len, uint16_t *handle, if (pdu[0] != ATT_OP_WRITE_CMD) return 0; - *handle = att_get_u16(&pdu[1]); + *handle = get_le16(&pdu[1]); memcpy(value, pdu + min_len, len - min_len); *vlen = len - min_len; @@ -573,7 +573,7 @@ uint16_t dec_write_req(const uint8_t *pdu, size_t len, uint16_t *handle, if (pdu[0] != ATT_OP_WRITE_REQ) return 0; - *handle = att_get_u16(&pdu[1]); + *handle = get_le16(&pdu[1]); *vlen = len - min_len; if (*vlen > 0) memcpy(value, pdu + min_len, *vlen); @@ -647,7 +647,7 @@ uint16_t dec_read_req(const uint8_t *pdu, size_t len, uint16_t *handle) if (pdu[0] != ATT_OP_READ_REQ) return 0; - *handle = att_get_u16(&pdu[1]); + *handle = get_le16(&pdu[1]); return min_len; } @@ -673,8 +673,8 @@ uint16_t dec_read_blob_req(const uint8_t *pdu, size_t len, uint16_t *handle, if (pdu[0] != ATT_OP_READ_BLOB_REQ) return 0; - *handle = att_get_u16(&pdu[1]); - *offset = att_get_u16(&pdu[3]); + *handle = get_le16(&pdu[1]); + *offset = get_le16(&pdu[3]); return min_len; } @@ -782,8 +782,8 @@ uint16_t dec_find_info_req(const uint8_t *pdu, size_t len, uint16_t *start, if (pdu[0] != ATT_OP_FIND_INFO_REQ) return 0; - *start = att_get_u16(&pdu[1]); - *end = att_get_u16(&pdu[3]); + *start = get_le16(&pdu[1]); + *end = get_le16(&pdu[3]); return min_len; } @@ -910,7 +910,7 @@ uint16_t dec_indication(const uint8_t *pdu, size_t len, uint16_t *handle, dlen = MIN(len - min_len, vlen); if (handle) - *handle = att_get_u16(&pdu[1]); + *handle = get_le16(&pdu[1]); memcpy(value, &pdu[3], dlen); @@ -957,7 +957,7 @@ uint16_t dec_mtu_req(const uint8_t *pdu, size_t len, uint16_t *mtu) if (pdu[0] != ATT_OP_MTU_REQ) return 0; - *mtu = att_get_u16(&pdu[1]); + *mtu = get_le16(&pdu[1]); return min_len; } @@ -991,7 +991,7 @@ uint16_t dec_mtu_resp(const uint8_t *pdu, size_t len, uint16_t *mtu) if (pdu[0] != ATT_OP_MTU_RESP) return 0; - *mtu = att_get_u16(&pdu[1]); + *mtu = get_le16(&pdu[1]); return min_len; } @@ -1039,8 +1039,8 @@ uint16_t dec_prep_write_req(const uint8_t *pdu, size_t len, uint16_t *handle, if (pdu[0] != ATT_OP_PREP_WRITE_REQ) return 0; - *handle = att_get_u16(&pdu[1]); - *offset = att_get_u16(&pdu[3]); + *handle = get_le16(&pdu[1]); + *offset = get_le16(&pdu[3]); *vlen = len - min_len; if (*vlen > 0) @@ -1092,8 +1092,8 @@ uint16_t dec_prep_write_resp(const uint8_t *pdu, size_t len, uint16_t *handle, if (pdu[0] != ATT_OP_PREP_WRITE_REQ) return 0; - *handle = att_get_u16(&pdu[1]); - *offset = att_get_u16(&pdu[3]); + *handle = get_le16(&pdu[1]); + *offset = get_le16(&pdu[3]); *vlen = len - min_len; if (*vlen > 0) memcpy(value, pdu + min_len, *vlen); diff --git a/attrib/gatt.c b/attrib/gatt.c index 0d439136b..83692f4ce 100644 --- a/attrib/gatt.c +++ b/attrib/gatt.c @@ -242,8 +242,8 @@ static void primary_all_cb(guint8 status, const guint8 *ipdu, guint16 iplen, struct gatt_primary *primary; bt_uuid_t uuid; - start = att_get_u16(&data[0]); - end = att_get_u16(&data[2]); + start = get_le16(&data[0]); + end = get_le16(&data[2]); if (list->len == 6) { bt_uuid_t uuid16; @@ -381,9 +381,9 @@ static struct gatt_included *included_from_buf(const uint8_t *buf, gsize len) { struct gatt_included *incl = g_new0(struct gatt_included, 1); - incl->handle = att_get_u16(&buf[0]); - incl->range.start = att_get_u16(&buf[2]); - incl->range.end = att_get_u16(&buf[4]); + incl->handle = get_le16(&buf[0]); + incl->range.start = get_le16(&buf[2]); + incl->range.end = get_le16(&buf[4]); if (len == 8) { bt_uuid_t uuid128; @@ -505,7 +505,7 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen, struct gatt_char *chars; bt_uuid_t uuid; - last = att_get_u16(value); + last = get_le16(value); if (list->len == 7) { bt_uuid_t uuid16; @@ -526,7 +526,7 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen, chars->handle = last; chars->properties = value[2]; - chars->value_handle = att_get_u16(&value[3]); + chars->value_handle = get_le16(&value[3]); bt_uuid_to_string(&uuid, chars->uuid, sizeof(chars->uuid)); dc->characteristics = g_slist_append(dc->characteristics, chars); diff --git a/attrib/gattrib.c b/attrib/gattrib.c index 31450a3bd..912dffb15 100644 --- a/attrib/gattrib.c +++ b/attrib/gattrib.c @@ -37,6 +37,7 @@ #include "btio/btio.h" #include "lib/uuid.h" +#include "src/shared/util.h" #include "src/log.h" #include "attrib/att.h" #include "attrib/gattrib.h" @@ -381,7 +382,7 @@ static bool match_event(struct event *evt, const uint8_t *pdu, gsize len) if (len < 3) return false; - handle = att_get_u16(&pdu[1]); + handle = get_le16(&pdu[1]); if (evt->expected == pdu[0] && evt->handle == handle) return true; diff --git a/attrib/gatttool.c b/attrib/gatttool.c index 10415a86d..4eb252850 100644 --- a/attrib/gatttool.c +++ b/attrib/gatttool.c @@ -79,7 +79,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data) uint16_t handle, i, olen = 0; size_t plen; - handle = att_get_u16(&pdu[1]); + handle = get_le16(&pdu[1]); switch (pdu[0]) { case ATT_OP_HANDLE_NOTIFY: @@ -272,7 +272,7 @@ static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu, uint8_t *value = list->data[i]; int j; - g_print("handle: 0x%04x \t value: ", att_get_u16(value)); + g_print("handle: 0x%04x \t value: ", get_le16(value)); value += 2; for (j = 0; j < list->len - 2; j++, value++) g_print("%02x ", *value); @@ -424,7 +424,7 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen, bt_uuid_t uuid; value = list->data[i]; - handle = att_get_u16(value); + handle = get_le16(value); if (format == 0x01) bt_uuid16_create(&uuid, get_le16(&value[2])); diff --git a/attrib/interactive.c b/attrib/interactive.c index 38403dd62..5dd47ec58 100644 --- a/attrib/interactive.c +++ b/attrib/interactive.c @@ -114,7 +114,7 @@ static void events_handler(const uint8_t *pdu, uint16_t len, gpointer user_data) size_t plen; GString *s; - handle = att_get_u16(&pdu[1]); + handle = get_le16(&pdu[1]); switch (pdu[0]) { case ATT_OP_HANDLE_NOTIFY: @@ -293,7 +293,7 @@ static void char_desc_cb(guint8 status, const guint8 *pdu, guint16 plen, bt_uuid_t uuid; value = list->data[i]; - handle = att_get_u16(value); + handle = get_le16(value); if (format == 0x01) bt_uuid16_create(&uuid, get_le16(&value[2])); @@ -362,7 +362,7 @@ static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu, int j; g_string_printf(s, "handle: 0x%04x \t value: ", - att_get_u16(value)); + get_le16(value)); value += 2; for (j = 0; j < list->len - 2; j++, value++) g_string_append_printf(s, "%02x ", *value); |