mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-16 22:21:21 +00:00
started des iterator
This commit is contained in:
parent
c21fc473f7
commit
7ebf954ce9
27
test/des_iterator/Makefile
Normal file
27
test/des_iterator/Makefile
Normal file
@ -0,0 +1,27 @@
|
||||
CC = g++
|
||||
|
||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
||||
|
||||
BTSTACK_ROOT = ../..
|
||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
||||
|
||||
CFLAGS = -g -Wall -I. -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
||||
LDFLAGS += -L$(CPPUTEST_HOME) -lCppUTest -lCppUTestExt
|
||||
|
||||
COMMON = \
|
||||
${BTSTACK_ROOT}/src/sdp_util.c \
|
||||
${BTSTACK_ROOT}/src/utils.c \
|
||||
des_iterator.c
|
||||
|
||||
COMMON_OBJ = $(COMMON:.c=.o)
|
||||
|
||||
all: des_iterator_test
|
||||
|
||||
des_iterator_test: ${COMMON_OBJ} des_iterator_test.c
|
||||
${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
|
||||
clean:
|
||||
rm -f des_iterator_test *.o ${BTSTACK_ROOT}/src/*.o
|
||||
rm -rf *.dSYM
|
||||
|
18
test/des_iterator/btstack-config.h
Normal file
18
test/des_iterator/btstack-config.h
Normal file
@ -0,0 +1,18 @@
|
||||
// config.h created by configure for BTstack Sun Sep 25 16:06:59 CEST 2011
|
||||
#ifndef __CONFIG_H
|
||||
#define __CONFIG_H
|
||||
#define HAVE_TRANSPORT_H4
|
||||
#define UART_DEVICE "/dev/tty.usbserial-A600eIDu"
|
||||
#define UART_SPEED 115200
|
||||
#define USE_POSIX_RUN_LOOP
|
||||
#define HAVE_TIME
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_BZERO
|
||||
#define ENABLE_LOG_INFO
|
||||
#define ENABLE_LOG_ERROR
|
||||
#define HAVE_SDP_EXTRA_QUERIES
|
||||
#define SDP_DES_DUMP
|
||||
#define HCI_ACL_PAYLOAD_SIZE 1021
|
||||
// #define HCI_ACL_PAYLOAD_SIZE 52
|
||||
|
||||
#endif // __CONFIG_H
|
29
test/des_iterator/des_iterator.c
Normal file
29
test/des_iterator/des_iterator.c
Normal file
@ -0,0 +1,29 @@
|
||||
#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);
|
||||
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 0;
|
||||
}
|
||||
|
||||
uint8_t * des_iterator_get_value(des_iterator_t * it){
|
||||
return NULL;
|
||||
}
|
35
test/des_iterator/des_iterator.h
Normal file
35
test/des_iterator/des_iterator.h
Normal file
@ -0,0 +1,35 @@
|
||||
|
||||
#ifndef __SDP_PARSER_H
|
||||
#define __SDP_PARSER_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_value(des_iterator_t * it);
|
||||
|
||||
#if defined __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // __DES_PARSER_H
|
42
test/des_iterator/des_iterator_test.c
Normal file
42
test/des_iterator/des_iterator_test.c
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// des iterator tests
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "des_iterator.h"
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
|
||||
static uint8_t des_test[] = {
|
||||
0x35, 0x1E, 0x35, 0x06, 0x19, 0x01, 0x00, 0x09, 0x00, 0x0F, 0x35, 0x14, 0x19, 0x00, 0x0F, 0x09,
|
||||
0x01, 0x00, 0x35, 0x0C, 0x09, 0x08, 0x00, 0x09, 0x08, 0x06, 0x09, 0x86, 0xDD, 0x09, 0x88, 0x0B
|
||||
};
|
||||
|
||||
|
||||
TEST_GROUP(DESParser){
|
||||
des_iterator_t des_protcol_list_it;
|
||||
int iterator_initialized;
|
||||
|
||||
void setup(){
|
||||
iterator_initialized = des_iterator_init(&des_protcol_list_it, des_test);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
TEST(DESParser, DESIterator){
|
||||
CHECK_EQUAL(iterator_initialized, 1);
|
||||
}
|
||||
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
return CommandLineTestRunner::RunAllTests(argc, argv);
|
||||
}
|
Loading…
Reference in New Issue
Block a user