summaryrefslogtreecommitdiff
path: root/attrib/att.c
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2010-11-18 15:48:44 -0200
committerJohan Hedberg <johan.hedberg@nokia.com>2010-11-18 21:53:54 +0200
commit2b3f200f291b5e55c31063e10f5d46f891caedde (patch)
tree4140233e1ec9cae4299877de6a398011980be2d2 /attrib/att.c
parentf127d461f565dbf4849d767801223cca9f09cf1e (diff)
downloadbluez-2b3f200f291b5e55c31063e10f5d46f891caedde.tar.gz
Add Find By Type Value Response encoding/decoding functions
Find by type operation is used by Discover Primary Service by Service UUID. Find By Type Value Response shall contain one or more group handles.
Diffstat (limited to 'attrib/att.c')
-rw-r--r--attrib/att.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/attrib/att.c b/attrib/att.c
index 6c889f214..8655e5e65 100644
--- a/attrib/att.c
+++ b/attrib/att.c
@@ -30,6 +30,8 @@
#include <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
+#include <glib.h>
+
#include "att.h"
const char *att_ecode2str(uint8_t status)
@@ -271,6 +273,50 @@ uint16_t dec_find_by_type_req(const uint8_t *pdu, int len, uint16_t *start,
return len;
}
+uint16_t enc_find_by_type_resp(GSList *matches, uint8_t *pdu, int len)
+{
+ GSList *l;
+ uint16_t offset;
+
+ if (pdu == NULL || len < 5)
+ return 0;
+
+ pdu[0] = ATT_OP_FIND_BY_TYPE_RESP;
+
+ for (l = matches, offset = 1; l && len >= (offset + 4);
+ l = l->next, offset += 4) {
+ struct att_range *range = l->data;
+
+ att_put_u16(range->start, &pdu[offset]);
+ att_put_u16(range->end, &pdu[offset + 2]);
+ }
+
+ return offset;
+}
+
+GSList *dec_find_by_type_resp(const uint8_t *pdu, int len)
+{
+ struct att_range *range;
+ GSList *matches;
+ int offset;
+
+ if (pdu == NULL || len < 5)
+ return NULL;
+
+ if (pdu[0] != ATT_OP_FIND_BY_TYPE_RESP)
+ return NULL;
+
+ for (offset = 1, matches = NULL; len >= (offset + 4); offset += 4) {
+ range = malloc(sizeof(struct att_range));
+ range->start = att_get_u16(&pdu[offset]);
+ range->end = att_get_u16(&pdu[offset + 2]);
+
+ matches = g_slist_append(matches, range);
+ }
+
+ return matches;
+}
+
uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, uuid_t *uuid,
uint8_t *pdu, int len)
{