diff --git a/src/ble/gatt-service/battery_service_v1_server.c b/src/ble/gatt-service/battery_service_v1_server.c index ac29f5538..b25a11386 100644 --- a/src/ble/gatt-service/battery_service_v1_server.c +++ b/src/ble/gatt-service/battery_service_v1_server.c @@ -95,6 +95,7 @@ static const char * bas_uuid16_name[BAS_CHARACTERISTIC_INDEX_NUM] = { "SERIAL_NUMBER_STRING", }; +static uint16_t bas_id_counter = 0; static btstack_linked_list_t battery_services; #define MEDFLOAT16_POSITIVE_INFINITY 0x07FE @@ -592,6 +593,10 @@ void battery_service_v1_server_register(battery_service_v1_t *service, battery_s btstack_assert(service_found != 0); UNUSED(service_found); + // get next service id + bas_id_counter = btstack_next_cid_ignoring_zero(bas_id_counter); + service->service_id = bas_id_counter; + service->service_handler.start_handle = start_handle; service->service_handler.end_handle = end_handle; printf("start handle 0x%04X, end0x%04X\n", service->service_handler.start_handle , service->service_handler.end_handle); diff --git a/src/ble/gatt-service/battery_service_v1_server.h b/src/ble/gatt-service/battery_service_v1_server.h index c4b2c5c60..fbb16f24e 100644 --- a/src/ble/gatt-service/battery_service_v1_server.h +++ b/src/ble/gatt-service/battery_service_v1_server.h @@ -244,6 +244,8 @@ typedef struct battery_service_v1 { att_service_handler_t service_handler; + uint16_t service_id; + bas_characteristic_t characteristics[BAS_CHARACTERISTIC_INDEX_NUM]; uint16_t battery_level_status_broadcast_configuration_handle; uint16_t battery_level_status_broadcast_configuration;