From 6bdecec7ba8f55d805af8d13b9f45c3a7f6d5810 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 8 Mar 2021 10:09:41 +0100 Subject: [PATCH] move GATT Service clients into ble/gatt-service --- example/ancs_client_demo.c | 21 ++----------------- port/arduino/Makefile | 5 ++++- port/stm32-f4discovery-cc256x/Makefile | 4 ++-- port/stm32-f4discovery-usb/Makefile | 4 ++-- port/stm32-l073rz-nucleo-em9304/Makefile | 6 +++--- port/stm32-l451-miromico-sx1280/Makefile | 4 ++-- port/stm32-wb55xx-nucleo-freertos/Makefile | 6 +++--- src/ble/Makefile.inc | 3 --- src/ble/gatt-service/Makefile.inc | 3 +++ src/ble/{ => gatt-service}/ancs_client.c | 3 +-- src/ble/{ => gatt-service}/ancs_client.h | 0 .../battery_service_client.c | 2 +- .../battery_service_client.h | 0 .../device_information_service_client.c | 2 +- .../device_information_service_client.h | 0 src/btstack.h | 6 +++--- src/btstack_memory.c | 5 ----- src/btstack_memory.h | 6 ++---- test/gatt_client/Makefile | 1 + test/pts/Makefile | 8 +++---- tool/btstack_memory_generator.py | 2 +- 21 files changed, 35 insertions(+), 56 deletions(-) rename src/ble/{ => gatt-service}/ancs_client.c (99%) rename src/ble/{ => gatt-service}/ancs_client.h (100%) rename src/ble/{ => gatt-service}/battery_service_client.c (99%) rename src/ble/{ => gatt-service}/battery_service_client.h (100%) rename src/ble/{ => gatt-service}/device_information_service_client.c (99%) rename src/ble/{ => gatt-service}/device_information_service_client.h (100%) diff --git a/example/ancs_client_demo.c b/example/ancs_client_demo.c index e95063475..e34394933 100644 --- a/example/ancs_client_demo.c +++ b/example/ancs_client_demo.c @@ -47,24 +47,7 @@ #include #include -#include "btstack_config.h" - -#include "btstack_run_loop.h" - -#include "btstack_debug.h" -#include "btstack_event.h" -#include "btstack_memory.h" -#include "gap.h" -#include "hci.h" -#include "hci_dump.h" -#include "l2cap.h" - -#include "ble/ancs_client.h" -#include "ble/att_db.h" -#include "ble/att_server.h" -#include "ble/gatt_client.h" -#include "ble/le_device_db.h" -#include "ble/sm.h" +#include "btstack.h" // TODO: query full text upon notification using control point // TODO: present notifications in human readable form @@ -189,4 +172,4 @@ int btstack_main(int argc, const char * argv[]){ return 0; } -/* EXAMPLE_END */ \ No newline at end of file +/* EXAMPLE_END */ diff --git a/port/arduino/Makefile b/port/arduino/Makefile index aaf5c5c86..0607ad68f 100644 --- a/port/arduino/Makefile +++ b/port/arduino/Makefile @@ -12,7 +12,8 @@ ARCHIVE=btstack-arduino-${VERSION}.zip SRC_FILES = btstack_memory.c btstack_linked_list.c btstack_memory_pool.c btstack_run_loop.c btstack_run_loop_base.c btstack_crypto.c SRC_FILES += hci_dump.c hci.c hci_cmd.c btstack_util.c l2cap.c ad_parser.c hci_transport_h4.c BLE_FILES = att_db.c att_server.c att_dispatch.c att_db_util.c le_device_db_memory.c gatt_client.c -BLE_FILES += sm.c ancs_client.h ancs_client.c +BLE_FILES += sm.c +BEL_GATT_FILES = ancs_client.c PORT_FILES = btstack_config.h bsp_arduino_em9301.cpp BTstack.cpp BTstack.h EMBEDDED_FILES = btstack_run_loop_embedded.c btstack_uart_block_embedded.c @@ -20,6 +21,8 @@ PATHS = $(addprefix ${BTSTACK_ROOT}/src/, ${SRC_FILES}) PATHS += $(filter-out ${BTSTACK_ROOT}/src/btstack.h, $(wildcard ${BTSTACK_ROOT}/src/*.h)) PATHS += $(addprefix ${BTSTACK_ROOT}/src/ble/, ${BLE_FILES}) PATHS += $(wildcard ${BTSTACK_ROOT}/src/ble/*.h) +PATHS += $(addprefix ${BTSTACK_ROOT}/src/ble/gatt-service/, ${BEL_GATT_FILES}) +PATHS += $(wildcard ${BTSTACK_ROOT}/src/ble/gatt-service/*.h) PATHS += $(addprefix ${BTSTACK_ROOT}/platform/embedded/, ${EMBEDDED_FILES}) PATHS += $(wildcard ${BTSTACK_ROOT}/platform/embedded/*.h) PATHS += $(wildcard ${BTSTACK_ROOT}/chipset/em9301/*) diff --git a/port/stm32-f4discovery-cc256x/Makefile b/port/stm32-f4discovery-cc256x/Makefile index 3577d908c..b1f4a1e60 100644 --- a/port/stm32-f4discovery-cc256x/Makefile +++ b/port/stm32-f4discovery-cc256x/Makefile @@ -58,10 +58,10 @@ ${BTSTACK_ROOT}/src/ble/ancs_client.c \ ${BTSTACK_ROOT}/src/ble/att_db.c \ ${BTSTACK_ROOT}/src/ble/att_dispatch.c \ ${BTSTACK_ROOT}/src/ble/att_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \ -${BTSTACK_ROOT}/src/ble/battery_service_client.c \ -${BTSTACK_ROOT}/src/ble/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \ ${BTSTACK_ROOT}/src/ble/gatt_client.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \ diff --git a/port/stm32-f4discovery-usb/Makefile b/port/stm32-f4discovery-usb/Makefile index f58265a66..f5b76aee4 100644 --- a/port/stm32-f4discovery-usb/Makefile +++ b/port/stm32-f4discovery-usb/Makefile @@ -59,10 +59,10 @@ ${BTSTACK_ROOT}/src/ble/ancs_client.c \ ${BTSTACK_ROOT}/src/ble/att_db.c \ ${BTSTACK_ROOT}/src/ble/att_dispatch.c \ ${BTSTACK_ROOT}/src/ble/att_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \ -${BTSTACK_ROOT}/src/ble/battery_service_client.c \ -${BTSTACK_ROOT}/src/ble/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \ ${BTSTACK_ROOT}/src/ble/gatt_client.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \ diff --git a/port/stm32-l073rz-nucleo-em9304/Makefile b/port/stm32-l073rz-nucleo-em9304/Makefile index 92510381d..76961a2ab 100644 --- a/port/stm32-l073rz-nucleo-em9304/Makefile +++ b/port/stm32-l073rz-nucleo-em9304/Makefile @@ -49,15 +49,15 @@ ${BTSTACK_ROOT}/platform/embedded/btstack_stdin_embedded.c \ ${BTSTACK_ROOT}/platform/embedded/btstack_tlv_flash_bank.c \ ${BTSTACK_ROOT}/platform/embedded/btstack_uart_block_embedded.c \ ${BTSTACK_ROOT}/src/ad_parser.c \ -${BTSTACK_ROOT}/src/ble/ancs_client.c \ ${BTSTACK_ROOT}/src/ble/att_db.c \ ${BTSTACK_ROOT}/src/ble/att_dispatch.c \ ${BTSTACK_ROOT}/src/ble/att_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/ancs_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_client.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \ -${BTSTACK_ROOT}/src/ble/battery_service_client.c \ -${BTSTACK_ROOT}/src/ble/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt_client.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \ diff --git a/port/stm32-l451-miromico-sx1280/Makefile b/port/stm32-l451-miromico-sx1280/Makefile index c895b143c..b79bfec0a 100644 --- a/port/stm32-l451-miromico-sx1280/Makefile +++ b/port/stm32-l451-miromico-sx1280/Makefile @@ -53,11 +53,11 @@ ${BTSTACK_ROOT}/src/ble/ancs_client.c \ ${BTSTACK_ROOT}/src/ble/att_db.c \ ${BTSTACK_ROOT}/src/ble/att_dispatch.c \ ${BTSTACK_ROOT}/src/ble/att_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \ -${BTSTACK_ROOT}/src/ble/battery_service_client.c \ -${BTSTACK_ROOT}/src/ble/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt_client.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \ diff --git a/port/stm32-wb55xx-nucleo-freertos/Makefile b/port/stm32-wb55xx-nucleo-freertos/Makefile index 60b33d119..df9c824f0 100644 --- a/port/stm32-wb55xx-nucleo-freertos/Makefile +++ b/port/stm32-wb55xx-nucleo-freertos/Makefile @@ -46,15 +46,15 @@ ${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \ ${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \ ${BTSTACK_ROOT}/platform/freertos/btstack_run_loop_freertos.c \ ${BTSTACK_ROOT}/src/ad_parser.c \ -${BTSTACK_ROOT}/src/ble/ancs_client.c \ ${BTSTACK_ROOT}/src/ble/att_db.c \ ${BTSTACK_ROOT}/src/ble/att_dispatch.c \ ${BTSTACK_ROOT}/src/ble/att_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/ancs_client.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \ +${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \ ${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \ -${BTSTACK_ROOT}/src/ble/battery_service_client.c \ -${BTSTACK_ROOT}/src/ble/device_information_service_client.c \ ${BTSTACK_ROOT}/src/ble/gatt_client.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \ ${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \ diff --git a/src/ble/Makefile.inc b/src/ble/Makefile.inc index 49433f011..e3ccf9e34 100644 --- a/src/ble/Makefile.inc +++ b/src/ble/Makefile.inc @@ -1,13 +1,10 @@ # Makefile to collect all C source files of src/ble SRC_BLE_FILES = \ - ancs_client.c \ att_db.c \ att_db_util.c \ att_dispatch.c \ att_server.c \ - battery_service_client.c \ - device_information_service_client.c \ gatt_client.c \ hids_client.c \ le_device_db_memory.c \ diff --git a/src/ble/gatt-service/Makefile.inc b/src/ble/gatt-service/Makefile.inc index b0f674166..728ca1c1d 100644 --- a/src/ble/gatt-service/Makefile.inc +++ b/src/ble/gatt-service/Makefile.inc @@ -1,9 +1,12 @@ # Makefile to collect all C source files of src/ble/gatt-service SRC_BLE_GATT_SERVICE_FILES = \ + ancs_client.c \ battery_service_server.c \ + battery_service_client.c \ cycling_power_service_server.c \ cycling_speed_and_cadence_service_server.c \ + device_information_service_client.c \ device_information_service_server.c \ heart_rate_service_server.c \ hids_device.c \ diff --git a/src/ble/ancs_client.c b/src/ble/gatt-service/ancs_client.c similarity index 99% rename from src/ble/ancs_client.c rename to src/ble/gatt-service/ancs_client.c index 58adf8932..24ea7a05e 100644 --- a/src/ble/ancs_client.c +++ b/src/ble/gatt-service/ancs_client.c @@ -42,7 +42,7 @@ #include #include -#include "ancs_client.h" +#include "ble/gatt-service/ancs_client.h" #include "ble/att_db.h" #include "ble/core.h" @@ -51,7 +51,6 @@ #include "btstack_debug.h" #include "btstack_event.h" #include "btstack_run_loop.h" -#include "classic/sdp_util.h" #include "gap.h" // ancs_client.h Start diff --git a/src/ble/ancs_client.h b/src/ble/gatt-service/ancs_client.h similarity index 100% rename from src/ble/ancs_client.h rename to src/ble/gatt-service/ancs_client.h diff --git a/src/ble/battery_service_client.c b/src/ble/gatt-service/battery_service_client.c similarity index 99% rename from src/ble/battery_service_client.c rename to src/ble/gatt-service/battery_service_client.c index a4ec1b24f..04ffaff4c 100644 --- a/src/ble/battery_service_client.c +++ b/src/ble/gatt-service/battery_service_client.c @@ -43,7 +43,7 @@ #include -#include "battery_service_client.h" +#include "ble/gatt-service/battery_service_client.h" #include "btstack_memory.h" diff --git a/src/ble/battery_service_client.h b/src/ble/gatt-service/battery_service_client.h similarity index 100% rename from src/ble/battery_service_client.h rename to src/ble/gatt-service/battery_service_client.h diff --git a/src/ble/device_information_service_client.c b/src/ble/gatt-service/device_information_service_client.c similarity index 99% rename from src/ble/device_information_service_client.c rename to src/ble/gatt-service/device_information_service_client.c index 5bdd99555..8bd8f7027 100644 --- a/src/ble/device_information_service_client.c +++ b/src/ble/gatt-service/device_information_service_client.c @@ -43,7 +43,7 @@ #include -#include "device_information_service_client.h" +#include "ble/gatt-service/device_information_service_client.h" #include "btstack_memory.h" #include "ble/att_db.h" diff --git a/src/ble/device_information_service_client.h b/src/ble/gatt-service/device_information_service_client.h similarity index 100% rename from src/ble/device_information_service_client.h rename to src/ble/gatt-service/device_information_service_client.h diff --git a/src/btstack.h b/src/btstack.h index d140a8357..c8066aacc 100644 --- a/src/btstack.h +++ b/src/btstack.h @@ -76,16 +76,16 @@ #include "l2cap_signaling.h" #ifdef ENABLE_BLE -#include "ble/ancs_client.h" #include "ble/att_db.h" #include "ble/att_db_util.h" #include "ble/att_dispatch.h" #include "ble/att_server.h" -#include "ble/battery_service_client.h" -#include "ble/device_information_service_client.h" +#include "ble/gatt-service/ancs_client.h" +#include "ble/gatt-service/battery_service_client.h" #include "ble/gatt-service/battery_service_server.h" #include "ble/gatt-service/cycling_power_service_server.h" #include "ble/gatt-service/cycling_speed_and_cadence_service_server.h" +#include "ble/gatt-service/device_information_service_client.h" #include "ble/gatt-service/device_information_service_server.h" #include "ble/gatt-service/heart_rate_service_server.h" #include "ble/gatt-service/hids_device.h" diff --git a/src/btstack_memory.c b/src/btstack_memory.c index 20a030fbd..f002b9a9c 100644 --- a/src/btstack_memory.c +++ b/src/btstack_memory.c @@ -55,11 +55,6 @@ #include -#ifdef ENABLE_MALLOC_TEST -extern "C" void * test_malloc(size_t size); -#define malloc test_malloc -#endif - #ifdef HAVE_MALLOC typedef struct btstack_memory_buffer { struct btstack_memory_buffer * next; diff --git a/src/btstack_memory.h b/src/btstack_memory.h index 9e2a3691c..7ced45e4b 100644 --- a/src/btstack_memory.h +++ b/src/btstack_memory.h @@ -52,12 +52,11 @@ extern "C" { #endif #include "btstack_config.h" - + // Core #include "hci.h" #include "l2cap.h" - // Classic #include "classic/avdtp_sink.h" #include "classic/avdtp_source.h" @@ -70,11 +69,10 @@ extern "C" { #include "classic/rfcomm.h" #include "classic/sdp_server.h" - // BLE #ifdef ENABLE_BLE #include "ble/gatt_client.h" -#include "ble/battery_service_client.h" +#include "ble/gatt-service/battery_service_client.h" #include "ble/sm.h" #endif diff --git a/test/gatt_client/Makefile b/test/gatt_client/Makefile index 0a728825c..f0e5c122a 100644 --- a/test/gatt_client/Makefile +++ b/test/gatt_client/Makefile @@ -8,6 +8,7 @@ CFLAGS = -DUNIT_TEST -x c++ -g -Wall -Wnarrowing -Wconversion-null -I. -Ibuild- VPATH += ${BTSTACK_ROOT}/src VPATH += ${BTSTACK_ROOT}/src/ble +VPATH += ${BTSTACK_ROOT}/src/ble/gatt-service VPATH += ${BTSTACK_ROOT}/platform/posix COMMON = \ diff --git a/test/pts/Makefile b/test/pts/Makefile index 8ee08058d..9622b57dc 100644 --- a/test/pts/Makefile +++ b/test/pts/Makefile @@ -155,13 +155,13 @@ all: ${EXAMPLES} cycling_power_server_test.h: cycling_power_server_test.gatt python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ -cycling_power_server_test: cycling_power_server_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} cycling_power_server_test.c +cycling_power_server_test: cycling_power_server_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} gatt_client.o cycling_power_server_test.c ${CC} $(filter-out cycling_power_server_test.h,$^) ${CFLAGS} ${LDFLAGS} -o $@ csc_server_test.h: csc_server_test.gatt python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ -csc_server_test: csc_server_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} csc_server_test.c +csc_server_test: csc_server_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} gatt_client.o csc_server_test.c ${CC} $(filter-out csc_server_test.h,$^) ${CFLAGS} ${LDFLAGS} -o $@ csc_client_test: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_CLIENT_OBJ} ${SM_OBJ} csc_client_test.c @@ -173,7 +173,7 @@ hid_host_test: ${CORE_OBJ} ${COMMON_OBJ} ${CLASSIC_OBJ} ${SDP_CLIENT} btstack_hi hid_device_test: ${CORE_OBJ} ${COMMON_OBJ} ${CLASSIC_OBJ} ${SDP_CLIENT} btstack_hid_parser.o btstack_ring_buffer.o hid_device.o hid_device_test.o ${CC} $^ ${CFLAGS} ${LDFLAGS} -o $@ -hog_demo_test: hog_demo_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} btstack_ring_buffer.o hog_demo_test.c +hog_demo_test: hog_demo_test.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} gatt_client.o btstack_ring_buffer.o hog_demo_test.c ${CC} $(filter-out hog_demo_test.h,$^) ${CFLAGS} ${LDFLAGS} -o $@ hrp_server_test.h: hrp_server_test.gatt @@ -233,7 +233,7 @@ iopt: ${CORE_OBJ} ${COMMON_OBJ} pan.o hsp_ag.o hsp_hs.o hfp_ag.o hfp_hf.o hfp_gs gatt_profiles.h: gatt_profiles.gatt python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@ -gatt_profiles: gatt_profiles.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} gatt_profiles.o +gatt_profiles: gatt_profiles.h ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_SERVER_OBJ} ${SM_OBJ} ${SRC_BLE_GATT_SERVICE_FILES_OBJ} gatt_client.c gatt_profiles.o ${CC} $(filter-out gatt_profiles.h,$^) ${CFLAGS} ${LDFLAGS} -o $@ myclean: diff --git a/tool/btstack_memory_generator.py b/tool/btstack_memory_generator.py index 35703700e..57b2c04f2 100755 --- a/tool/btstack_memory_generator.py +++ b/tool/btstack_memory_generator.py @@ -80,7 +80,7 @@ extern "C" { // BLE #ifdef ENABLE_BLE #include "ble/gatt_client.h" -#include "ble/battery_service_client.h" +#include "ble/gatt-service/battery_service_client.h" #include "ble/sm.h" #endif