gatt-service/bas-server: assign service id

This commit is contained in:
Matthias Ringwald 2024-11-13 09:31:09 +01:00
parent 0498a0a319
commit f849ede793
2 changed files with 7 additions and 0 deletions

View File

@ -95,6 +95,7 @@ static const char * bas_uuid16_name[BAS_CHARACTERISTIC_INDEX_NUM] = {
"SERIAL_NUMBER_STRING", "SERIAL_NUMBER_STRING",
}; };
static uint16_t bas_id_counter = 0;
static btstack_linked_list_t battery_services; static btstack_linked_list_t battery_services;
#define MEDFLOAT16_POSITIVE_INFINITY 0x07FE #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); btstack_assert(service_found != 0);
UNUSED(service_found); 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.start_handle = start_handle;
service->service_handler.end_handle = end_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); printf("start handle 0x%04X, end0x%04X\n", service->service_handler.start_handle , service->service_handler.end_handle);

View File

@ -244,6 +244,8 @@ typedef struct battery_service_v1 {
att_service_handler_t service_handler; att_service_handler_t service_handler;
uint16_t service_id;
bas_characteristic_t characteristics[BAS_CHARACTERISTIC_INDEX_NUM]; bas_characteristic_t characteristics[BAS_CHARACTERISTIC_INDEX_NUM];
uint16_t battery_level_status_broadcast_configuration_handle; uint16_t battery_level_status_broadcast_configuration_handle;
uint16_t battery_level_status_broadcast_configuration; uint16_t battery_level_status_broadcast_configuration;