mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-21 13:21:05 +00:00
added ble-client unit-test skeleton
This commit is contained in:
parent
5e457cb758
commit
f45e14b190
35
test/gatt_client/Makefile
Normal file
35
test/gatt_client/Makefile
Normal file
@ -0,0 +1,35 @@
|
||||
CC = g++
|
||||
|
||||
# Requirements: http://www.cpputest.org/ should be placed in btstack/test
|
||||
|
||||
BTSTACK_ROOT = ../..
|
||||
CPPUTEST_HOME = ${BTSTACK_ROOT}/test/cpputest
|
||||
|
||||
CFLAGS = -DUNIT_TEST -g -Wall -I. -I${BTSTACK_ROOT}/example/libusb -I${BTSTACK_ROOT}/src -I${BTSTACK_ROOT}/ble -I${BTSTACK_ROOT}/include -I$(CPPUTEST_HOME)/include
|
||||
LDFLAGS += -L$(CPPUTEST_HOME) -lCppUTest -lCppUTestExt
|
||||
|
||||
COMMON = \
|
||||
${BTSTACK_ROOT}/src/utils.c \
|
||||
${BTSTACK_ROOT}/src/btstack_memory.c \
|
||||
${BTSTACK_ROOT}/src/memory_pool.c \
|
||||
${BTSTACK_ROOT}/src/linked_list.c \
|
||||
${BTSTACK_ROOT}/src/sdp_util.c \
|
||||
${BTSTACK_ROOT}/src/remote_device_db_memory.c \
|
||||
${BTSTACK_ROOT}/src/run_loop.c \
|
||||
${BTSTACK_ROOT}/src/run_loop_posix.c \
|
||||
${BTSTACK_ROOT}/src/hci_cmds.c \
|
||||
${BTSTACK_ROOT}/example/libusb/ble_client.c \
|
||||
mock.c
|
||||
|
||||
COMMON_OBJ = $(COMMON:.c=.o)
|
||||
|
||||
all: gatt_client
|
||||
|
||||
gatt_client: ${CORE_OBJ} ${COMMON_OBJ} gatt_client.c
|
||||
${CC} ${CORE_OBJ} ${COMMON_OBJ} gatt_client.c ${CFLAGS} ${LDFLAGS} -o $@
|
||||
|
||||
clean:
|
||||
rm -f gatt_client
|
||||
rm -f *.o ${BTSTACK_ROOT}/src/*.o
|
||||
rm -rf *.dSYM
|
||||
|
39
test/gatt_client/gatt_client.c
Normal file
39
test/gatt_client/gatt_client.c
Normal file
@ -0,0 +1,39 @@
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// test rfcomm query tests
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "CppUTest/TestHarness.h"
|
||||
#include "CppUTest/CommandLineTestRunner.h"
|
||||
|
||||
#include <btstack/hci_cmds.h>
|
||||
|
||||
#include "btstack_memory.h"
|
||||
#include "hci.h"
|
||||
|
||||
// #include "hci_dump.h"
|
||||
// #include "l2cap.h"
|
||||
// #include "sdp_parser.h"
|
||||
|
||||
TEST_GROUP(ADParser){
|
||||
};
|
||||
|
||||
|
||||
TEST(ADParser, TestDataParsing){
|
||||
}
|
||||
|
||||
TEST(ADParser, TestHasUUID){
|
||||
|
||||
}
|
||||
|
||||
int main (int argc, const char * argv[]){
|
||||
return CommandLineTestRunner::RunAllTests(argc, argv);
|
||||
}
|
77
test/gatt_client/mock.c
Normal file
77
test/gatt_client/mock.c
Normal file
@ -0,0 +1,77 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <btstack/btstack.h>
|
||||
#include "hci.h"
|
||||
#include "hci_dump.h"
|
||||
#include "l2cap.h"
|
||||
|
||||
int hci_can_send_packet_now_using_packet_buffer(uint8_t packet_type){
|
||||
printf("hci_can_send_packet_now_using_packet_buffer \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
void hci_disconnect_security_block(hci_con_handle_t con_handle){
|
||||
printf("hci_disconnect_security_block \n");
|
||||
}
|
||||
|
||||
void hci_dump_log(const char * format, ...){
|
||||
printf("hci_disconnect_security_block \n");
|
||||
}
|
||||
|
||||
int hci_send_cmd(const hci_cmd_t *cmd, ...){
|
||||
printf("hci_send_cmd \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int l2cap_can_send_connectionless_packet_now(void){
|
||||
printf("l2cap_can_send_connectionless_packet_now \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
static uint8_t l2cap_stack_buffer[20];
|
||||
static uint16_t max_l2cap_data_packet_length = 20;
|
||||
|
||||
|
||||
uint8_t *l2cap_get_outgoing_buffer(void){
|
||||
printf("l2cap_get_outgoing_buffer \n");
|
||||
return (uint8_t *)&l2cap_stack_buffer; // 8 bytes
|
||||
}
|
||||
|
||||
|
||||
|
||||
uint16_t l2cap_max_mtu(void){
|
||||
printf("l2cap_max_mtu \n");
|
||||
return max_l2cap_data_packet_length;
|
||||
}
|
||||
|
||||
|
||||
void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint16_t channel_id) {
|
||||
printf("l2cap_register_fixed_channel \n");
|
||||
}
|
||||
|
||||
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){
|
||||
printf("l2cap_register_packet_handler \n");
|
||||
}
|
||||
|
||||
int hci_reserve_packet_buffer(void){
|
||||
printf("hci_reserve_packet_buffer \n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
int l2cap_reserve_packet_buffer(void){
|
||||
printf("l2cap_reserve_packet_buffer \n");
|
||||
return hci_reserve_packet_buffer();
|
||||
}
|
||||
|
||||
int l2cap_send_prepared_connectionless(uint16_t handle, uint16_t cid, uint16_t len){
|
||||
printf("l2cap_send_prepared_connectionless \n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void l2cap_run(void){
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user