From b6eb133d4e5b59d79e2abba4157496768ee0853d Mon Sep 17 00:00:00 2001 From: "mila@ringwald.ch" Date: Mon, 11 Nov 2013 22:28:38 +0000 Subject: [PATCH] implemented convinient functions --- example/libusb/ad_parser.c | 40 +++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/example/libusb/ad_parser.c b/example/libusb/ad_parser.c index db4146ac2..82c979718 100644 --- a/example/libusb/ad_parser.c +++ b/example/libusb/ad_parser.c @@ -42,6 +42,8 @@ #include #include +#include + #include "ad_parser.h" typedef enum { @@ -78,21 +80,38 @@ uint8_t * ad_iterator_get_data(ad_context_t * context){ return &context->data[context->offset + 2]; } -int ad_data_contains_uuid16(uint8_t ad_len, uint8_t * ad_data, uint16_t uuid){ +static inline void swap128(uint8_t src[16], uint8_t dst[16]){ + int i; + for (i = 0; i < 16; i++) + dst[15 - i] = src[i]; +} + +int ad_data_contains_uuid16(uint8_t ad_len, uint8_t * ad_data, uint16_t uuid16){ ad_context_t context; for (ad_iterator_init(&context, ad_len, ad_data) ; ad_iterator_has_more(&context) ; ad_iterator_next(&context)){ uint8_t data_type = ad_iterator_get_data_type(&context); uint8_t data_len = ad_iterator_get_data_len(&context); uint8_t * data = ad_iterator_get_data(&context); + int i; + uint8_t ad_uuid128[16], uuid128_bt[16]; + switch (data_type){ case IncompleteList16: case CompleteList16: - // ... iterate through list of uuids + for (i=0; i