mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-03 07:13:51 +00:00
des_iterator moved to sdp_util
This commit is contained in:
parent
bbac2f6fce
commit
881797bd1b
@ -9,10 +9,6 @@ CFLAGS += -I${BTSTACK_ROOT}/include
|
||||
CFLAGS += -I${BTSTACK_ROOT}/src
|
||||
CFLAGS += -I${BTSTACK_ROOT}
|
||||
|
||||
# TODO: move des iterator into /src
|
||||
VPATH += ${BTSTACK_ROOT}/test/des_iterator
|
||||
CFLAGS += -I${BTSTACK_ROOT}/test/des_iterator
|
||||
|
||||
CORE += \
|
||||
btstack_memory.c \
|
||||
linked_list.c \
|
||||
@ -57,9 +53,6 @@ SM_MINIMAL += \
|
||||
sm_minimal.c \
|
||||
central_device_db_dummy.c \
|
||||
|
||||
SDP_DES = \
|
||||
des_iterator.c \
|
||||
|
||||
PAN += \
|
||||
pan.c \
|
||||
|
||||
@ -109,7 +102,7 @@ sdp_rfcomm_query: ${CORE_OBJ} ${COMMON_OBJ} ${PAN_OBJ} ${SDP_CLIENT} sdp_rfcomm_
|
||||
sdp_general_query: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} sdp_general_query.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
sdp_bnep_query: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} ${SDP_DES} sdp_bnep_query.c
|
||||
sdp_bnep_query: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} sdp_bnep_query.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
spp_counter: ${CORE_OBJ} ${COMMON_OBJ} spp_counter.c
|
||||
@ -133,7 +126,7 @@ gap_inquiry: ${CORE_OBJ} ${COMMON_OBJ} gap_inquiry.c
|
||||
gap_inquiry_and_bond: ${CORE_OBJ} ${COMMON_OBJ} gap_inquiry_and_bond.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
panu_demo: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_DES} ${SDP_CLIENT} panu_demo.c
|
||||
panu_demo: ${CORE_OBJ} ${COMMON_OBJ} ${SDP_CLIENT} panu_demo.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
l2cap_test: ${CORE_OBJ} ${COMMON_OBJ} l2cap_test.c
|
||||
@ -167,4 +160,8 @@ clean:
|
||||
rm -f ${BTSTACK_ROOT}/include/btstack/version.h
|
||||
rm -f ancs_client.h profile.h spp_and_le_counter.h
|
||||
rm -rf *.dSYM
|
||||
rm -rf ${BTSTACK_ROOT}/ble/*.o
|
||||
rm -rf ${BTSTACK_ROOT}/src/*.o
|
||||
rm -rf ${BTSTACK_ROOT}/platforms/posix/src/*.o
|
||||
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
#include <btstack/hci_cmds.h>
|
||||
#include <btstack/run_loop.h>
|
||||
#include <btstack/sdp_util.h>
|
||||
|
||||
#include "hci.h"
|
||||
#include "btstack_memory.h"
|
||||
@ -34,7 +35,6 @@
|
||||
#include "sdp_parser.h"
|
||||
#include "sdp_client.h"
|
||||
#include "sdp_query_util.h"
|
||||
#include "des_iterator.h"
|
||||
#include "pan.h"
|
||||
|
||||
static int record_id = -1;
|
||||
|
@ -12,19 +12,17 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "sdp_parser.h"
|
||||
#include "sdp_client.h"
|
||||
#include "sdp_query_util.h"
|
||||
|
||||
#include <btstack/hci_cmds.h>
|
||||
#include <btstack/run_loop.h>
|
||||
#include <btstack/sdp_util.h>
|
||||
|
||||
#include "hci.h"
|
||||
#include "btstack_memory.h"
|
||||
#include "hci_dump.h"
|
||||
#include "l2cap.h"
|
||||
#include "sdp_parser.h"
|
||||
#include "des_iterator.h"
|
||||
#include "sdp_client.h"
|
||||
#include "sdp_query_util.h"
|
||||
#include "pan.h"
|
||||
|
||||
int record_id = -1;
|
||||
|
@ -127,6 +127,20 @@ void de_add_uuid128(uint8_t * seq, uint8_t * uuid);
|
||||
uint32_t de_get_uuid32(uint8_t * element);
|
||||
int de_get_normalized_uuid(uint8_t *uuid128, uint8_t *element);
|
||||
|
||||
// MARK: DES iterator
|
||||
typedef struct {
|
||||
uint8_t * element;
|
||||
uint16_t pos;
|
||||
uint16_t length;
|
||||
} des_iterator_t;
|
||||
|
||||
int des_iterator_init(des_iterator_t * it, uint8_t * element);
|
||||
int des_iterator_has_more(des_iterator_t * it);
|
||||
de_type_t des_iterator_get_type (des_iterator_t * it);
|
||||
uint16_t des_iterator_get_size (des_iterator_t * it);
|
||||
uint8_t * des_iterator_get_element(des_iterator_t * it);
|
||||
void des_iterator_next(des_iterator_t * it);
|
||||
|
||||
// MARK: SDP
|
||||
uint16_t sdp_append_attributes_in_attributeIDList(uint8_t *record, uint8_t *attributeIDList, uint16_t startOffset, uint16_t maxBytes, uint8_t *buffer);
|
||||
uint8_t * sdp_get_attribute_value_for_attribute_id(uint8_t * record, uint16_t attributeID);
|
||||
|
@ -251,6 +251,43 @@ void de_add_uuid128(uint8_t * seq, uint8_t * uuid){
|
||||
net_store_16(seq, 1, data_size+1+16);
|
||||
}
|
||||
|
||||
// MARK: DES iterator
|
||||
int des_iterator_init(des_iterator_t * it, uint8_t * element){
|
||||
de_type_t type = de_get_element_type(element);
|
||||
if (type != DE_DES) return 0;
|
||||
|
||||
it->element = element;
|
||||
it->pos = de_get_header_size(element);
|
||||
it->length = de_get_len(element);
|
||||
// printf("des_iterator_init current pos %d, total len %d\n", it->pos, it->length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
de_type_t des_iterator_get_type (des_iterator_t * it){
|
||||
return de_get_element_type(&it->element[it->pos]);
|
||||
}
|
||||
|
||||
uint16_t des_iterator_get_size (des_iterator_t * it){
|
||||
int length = de_get_len(&it->element[it->pos]);
|
||||
int header_size = de_get_header_size(&it->element[it->pos]);
|
||||
return length - header_size;
|
||||
}
|
||||
|
||||
int des_iterator_has_more(des_iterator_t * it){
|
||||
return it->pos < it->length;
|
||||
}
|
||||
|
||||
uint8_t * des_iterator_get_element(des_iterator_t * it){
|
||||
if (!des_iterator_has_more(it)) return NULL;
|
||||
return &it->element[it->pos];
|
||||
}
|
||||
|
||||
void des_iterator_next(des_iterator_t * it){
|
||||
int element_len = de_get_len(&it->element[it->pos]);
|
||||
// printf("des_iterator_next element size %d, current pos %d, total len %d\n", element_len, it->pos, it->length);
|
||||
it->pos += element_len;
|
||||
}
|
||||
|
||||
void sdp_add_attribute(uint8_t *seq, uint16_t attributeID, uint8_t attributeValue){
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,7 @@ LDFLAGS += -L$(CPPUTEST_HOME) -lCppUTest -lCppUTestExt
|
||||
|
||||
COMMON = \
|
||||
${BTSTACK_ROOT}/src/sdp_util.c \
|
||||
${BTSTACK_ROOT}/src/utils.c \
|
||||
des_iterator.c
|
||||
${BTSTACK_ROOT}/src/utils.c
|
||||
|
||||
COMMON_OBJ = $(COMMON:.c=.o)
|
||||
|
||||
|
@ -1,38 +0,0 @@
|
||||
#include "des_iterator.h"
|
||||
|
||||
int des_iterator_init(des_iterator_t * it, uint8_t * element){
|
||||
de_type_t type = de_get_element_type(element);
|
||||
if (type != DE_DES) return 0;
|
||||
|
||||
it->element = element;
|
||||
it->pos = de_get_header_size(element);
|
||||
it->length = de_get_len(element);
|
||||
// printf("des_iterator_init current pos %d, total len %d\n", it->pos, it->length);
|
||||
return 1;
|
||||
}
|
||||
|
||||
de_type_t des_iterator_get_type (des_iterator_t * it){
|
||||
return de_get_element_type(&it->element[it->pos]);
|
||||
}
|
||||
|
||||
uint16_t des_iterator_get_size (des_iterator_t * it){
|
||||
int length = de_get_len(&it->element[it->pos]);
|
||||
int header_size = de_get_header_size(&it->element[it->pos]);
|
||||
return length - header_size;
|
||||
}
|
||||
|
||||
int des_iterator_has_more(des_iterator_t * it){
|
||||
return it->pos < it->length;
|
||||
}
|
||||
|
||||
uint8_t * des_iterator_get_element(des_iterator_t * it){
|
||||
if (!des_iterator_has_more(it)) return NULL;
|
||||
return &it->element[it->pos];
|
||||
}
|
||||
|
||||
void des_iterator_next(des_iterator_t * it){
|
||||
int element_len = de_get_len(&it->element[it->pos]);
|
||||
// printf("des_iterator_next element size %d, current pos %d, total len %d\n", element_len, it->pos, it->length);
|
||||
it->pos += element_len;
|
||||
}
|
||||
|
@ -1,36 +0,0 @@
|
||||
|
||||
#ifndef __DES_ITERATOR_H
|
||||
#define __DES_ITERATOR_H
|
||||
|
||||
#include "btstack-config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <btstack/sdp_util.h>
|
||||
#include <btstack/utils.h>
|
||||
|
||||
#if defined __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
uint8_t * element;
|
||||
uint16_t pos;
|
||||
uint16_t length;
|
||||
} des_iterator_t;
|
||||
|
||||
int des_iterator_init(des_iterator_t * it, uint8_t * element);
|
||||
int des_iterator_has_more(des_iterator_t * it);
|
||||
de_type_t des_iterator_get_type (des_iterator_t * it);
|
||||
uint16_t des_iterator_get_size (des_iterator_t * it);
|
||||
uint8_t * des_iterator_get_element(des_iterator_t * it);
|
||||
void des_iterator_next(des_iterator_t * it);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __DES_ITERATOR_H
|
@ -11,7 +11,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "des_iterator.h"
|
||||
#include <btstack/sdp_util.h>
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user