mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-18 23:42:39 +00:00
gatt-service/bas-server: provide service id on registration
This commit is contained in:
parent
f849ede793
commit
f368eb91f4
@ -95,7 +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 uint16_t bas_service_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
|
||||||
@ -571,7 +571,7 @@ void battery_service_v1_server_init(void){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void battery_service_v1_server_register(battery_service_v1_t *service, battery_service_v1_server_connection_t *connections, uint8_t connection_max_num){
|
void battery_service_v1_server_register(battery_service_v1_t *service, battery_service_v1_server_connection_t *connections, uint8_t connection_max_num, uint16_t * out_service_id){
|
||||||
btstack_assert(service != NULL);
|
btstack_assert(service != NULL);
|
||||||
btstack_assert(connections != NULL);
|
btstack_assert(connections != NULL);
|
||||||
btstack_assert(connection_max_num > 0u);
|
btstack_assert(connection_max_num > 0u);
|
||||||
@ -594,8 +594,11 @@ void battery_service_v1_server_register(battery_service_v1_t *service, battery_s
|
|||||||
UNUSED(service_found);
|
UNUSED(service_found);
|
||||||
|
|
||||||
// get next service id
|
// get next service id
|
||||||
bas_id_counter = btstack_next_cid_ignoring_zero(bas_id_counter);
|
bas_service_id_counter = btstack_next_cid_ignoring_zero(bas_service_id_counter);
|
||||||
service->service_id = bas_id_counter;
|
service->service_id = bas_service_id_counter;
|
||||||
|
if (out_service_id != NULL) {
|
||||||
|
*out_service_id = bas_service_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;
|
||||||
|
@ -297,8 +297,19 @@ typedef struct battery_service_v1 {
|
|||||||
*/
|
*/
|
||||||
void battery_service_v1_server_init(void);
|
void battery_service_v1_server_init(void);
|
||||||
|
|
||||||
void battery_service_v1_server_register(battery_service_v1_t * service, battery_service_v1_server_connection_t * connections, uint8_t connection_max_num);
|
/**
|
||||||
|
* @brief Register Battery Service
|
||||||
|
* @param service
|
||||||
|
* @param connections array of battery_service_v1_server_connection_t for storage
|
||||||
|
* @param connection_max_num
|
||||||
|
* @param out_service_id
|
||||||
|
*/
|
||||||
|
void battery_service_v1_server_register(battery_service_v1_t * service, battery_service_v1_server_connection_t * connections, uint8_t connection_max_num, uint16_t * out_service_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Deregister Battery Service Server
|
||||||
|
* @param service
|
||||||
|
*/
|
||||||
void battery_service_v1_server_deregister(battery_service_v1_t * service);
|
void battery_service_v1_server_deregister(battery_service_v1_t * service);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user