From 68a70b347ecf276dc287baab35ef04c1eb1f2e96 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 29 Aug 2023 19:18:09 +0200 Subject: [PATCH] example/hog_host_demo: setup GATT DB --- example/Makefile.inc | 3 +++ example/hog_host_demo.c | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/example/Makefile.inc b/example/Makefile.inc index 2f2eafb62..eb110d086 100644 --- a/example/Makefile.inc +++ b/example/Makefile.inc @@ -263,6 +263,7 @@ EXAMPLES_GATT_FILES = \ gatt_counter.gatt \ gatt_device_information_query.gatt \ gatt_streamer_server.gatt \ + hog_host_demo.gatt \ hog_keyboard_demo.gatt \ hog_mouse_demo.gatt \ le_credit_based_flow_control_mode_server.gatt \ @@ -346,6 +347,8 @@ hog_boot_host_demo: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_CLIENT_OBJ} hog_ ${CC} $^ ${LDFLAGS} -o $@ +hog_host_demo.o: hog_host_demo.h hog_host_demo.c + ${CC} ${CFLAGS} -c $(filter-out hog_host_demo.h,$^) -o $@ hog_host_demo: ${CORE_OBJ} ${COMMON_OBJ} ${ATT_OBJ} ${GATT_CLIENT_OBJ} btstack_hid_parser.o btstack_hid.o hog_host_demo.o ${CC} $^ ${LDFLAGS} -o $@ diff --git a/example/hog_host_demo.c b/example/hog_host_demo.c index 203d68e5e..eae6a29cd 100644 --- a/example/hog_host_demo.c +++ b/example/hog_host_demo.c @@ -55,6 +55,12 @@ #include "btstack_config.h" #include "btstack.h" +// hog_host_demo.gatt contains the declaration of the provided GATT Services + Characteristics +// hog_host_demo.h contains the binary representation of gatt_browser.gatt +// it is generated by the build system by calling: $BTSTACK_ROOT/tool/compile_gatt.py hog_host_demo.gatt hog_host_demo.h +// it needs to be regenerated when the GATT Database declared in gatt_browser.gatt file is modified +#include "hog_host_demo.h" + // TAG to store remote device address and type in TLV #define TLV_TAG_HOGD ((((uint32_t) 'H') << 24 ) | (((uint32_t) 'O') << 16) | (((uint32_t) 'G') << 8) | 'D') @@ -512,6 +518,9 @@ int btstack_main(int argc, const char * argv[]){ sm_init(); gatt_client_init(); + // setup ATT server - only needed if LE Peripheral does ATT queries on its own, e.g. Android and iOS + att_server_init(profile_data, NULL, NULL); + hids_client_init(hid_descriptor_storage, sizeof(hid_descriptor_storage)); /* LISTING_END */