From 29ba805bf804a369b711c5444b092f62d65c2182 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Tue, 26 Jan 2021 21:00:34 +0100 Subject: [PATCH] tool/compile_gatt: support multiple instances of the same service --- CHANGELOG.md | 1 + tool/compile_gatt.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eed659aa3..330f6f2b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ HFP: `ENABLE_HFP_AT_MESSAGES` lets HFP emit `HFP_SUBEVENT_AT_MESSAGE_SENT` and L2CAP: fix packet size check for incoming classic basic channels (regression introduced in v1.2.1) A2DP Source: emit codec configure event with reconfigure flag set on reconfigure HCI: keep `le connecting request` on command complete, fixes gap_auto_connection_stop() + gap_auto_connection_start() +GATT Compiler: support multiple instances of the same service ### Changed HFP/GOEP Client/AVDTP/A2DP: return `SDP_SERVICE_NOT_FOUND` if no suitable SDP record is found diff --git a/tool/compile_gatt.py b/tool/compile_gatt.py index c50c6ddc2..bc1583b40 100755 --- a/tool/compile_gatt.py +++ b/tool/compile_gatt.py @@ -143,6 +143,7 @@ defines_for_characteristics = [] defines_for_services = [] include_paths = [] database_hash_message = bytearray() +service_counter = {} handle = 1 total_size = 0 @@ -356,10 +357,20 @@ def serviceDefinitionComplete(fout): global services if current_service_uuid_string: fout.write("\n") - # print("append service %s = [%d, %d]" % (current_characteristic_uuid_string, current_service_start_handle, handle-1)) - defines_for_services.append('#define ATT_SERVICE_%s_START_HANDLE 0x%04x' % (current_service_uuid_string, current_service_start_handle)) - defines_for_services.append('#define ATT_SERVICE_%s_END_HANDLE 0x%04x' % (current_service_uuid_string, handle-1)) - services[current_service_uuid_string] = [current_service_start_handle, handle-1] + # update num instances for this service + count = 1 + if current_service_uuid_string in service_counter: + count = service_counter[current_service_uuid_string] + 1 + service_counter[current_service_uuid_string] = count + # add old defines without service counter for first instance + if count == 1: + defines_for_services.append('#define ATT_SERVICE_%s_START_HANDLE 0x%04x' % (current_service_uuid_string, current_service_start_handle)) + defines_for_services.append('#define ATT_SERVICE_%s_END_HANDLE 0x%04x' % (current_service_uuid_string, handle-1)) + services[current_service_uuid_string] = [current_service_start_handle, handle-1] + # unified defines indicating instance + defines_for_services.append('#define ATT_SERVICE_%s_%02x_START_HANDLE 0x%04x' % (current_service_uuid_string, count, current_service_start_handle)) + defines_for_services.append('#define ATT_SERVICE_%s_%02x_END_HANDLE 0x%04x' % (current_service_uuid_string, count, handle-1)) + def dump_flags(fout, flags): global security_permsission