att_db: fix spelling, update API docu

This commit is contained in:
Milanka Ringwald 2021-06-01 11:28:19 +02:00
parent 60589707ee
commit c436b76054
16 changed files with 149 additions and 77 deletions

View File

@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
### Fixed
- ATT DB: fix spelling `gatt_server_get_handle_range_for_service_with_uuid128`, `gatt_server_get_handle_range_for_service_with_uuid16`
### Changed
## Release v1.4

View File

@ -1244,7 +1244,7 @@ uint16_t att_handle_request(att_connection_t * att_connection,
}
// returns 1 if service found. only primary service.
bool gatt_server_get_get_handle_range_for_service_with_uuid16(uint16_t uuid16, uint16_t * start_handle, uint16_t * end_handle){
bool gatt_server_get_handle_range_for_service_with_uuid16(uint16_t uuid16, uint16_t * start_handle, uint16_t * end_handle){
uint16_t in_group = 0;
uint16_t prev_handle = 0;
@ -1328,7 +1328,7 @@ uint16_t gatt_server_get_server_configuration_handle_for_characteristic_with_uui
}
// returns 1 if service found. only primary service.
int gatt_server_get_get_handle_range_for_service_with_uuid128(const uint8_t * uuid128, uint16_t * start_handle, uint16_t * end_handle){
int gatt_server_get_handle_range_for_service_with_uuid128(const uint8_t * uuid128, uint16_t * start_handle, uint16_t * end_handle){
uint16_t in_group = 0;
uint16_t prev_handle = 0;

View File

@ -94,14 +94,6 @@ extern "C" {
#define ATT_WRITE_COMMAND 0x52
#define ATT_SIGNED_WRITE_COMMAND 0xD2
// map ATT ERROR CODES on to att_read_callback length
#define ATT_READ_ERROR_CODE_OFFSET 0xfe00
// custom BTstack ATT Response Pending for att_read_callback
#define ATT_READ_RESPONSE_PENDING 0xffff
// internally used to signal write response pending
#define ATT_INTERNAL_WRITE_RESPONSE_PENDING 0xfffe
// internal additions
// 128 bit UUID used
@ -126,34 +118,49 @@ typedef struct att_connection {
uint8_t secure_connection;
} att_connection_t;
// ATT Client Read Callback for Dynamic Data
// - if buffer == NULL, don't copy data, just return size of value
// - if buffer != NULL, copy data and return number bytes copied
// If ENABLE_ATT_DELAYED_READ_RESPONSE is defined, you may return ATT_READ_RESPONSE_PENDING if data isn't available yet
// @param con_handle of hci le connection
// @param attribute_handle to be read
// @param offset defines start of attribute value
// @param buffer
// @param buffer_size
/* API_START */
// map ATT ERROR CODES on to att_read_callback length
#define ATT_READ_ERROR_CODE_OFFSET 0xfe00
// custom BTstack ATT Response Pending for att_read_callback
#define ATT_READ_RESPONSE_PENDING 0xffff
// internally used to signal write response pending
#define ATT_INTERNAL_WRITE_RESPONSE_PENDING 0xfffe
/**
* @brief ATT Client Read Callback for Dynamic Data
* - if buffer == NULL, don't copy data, just return size of value
* - if buffer != NULL, copy data and return number bytes copied
* If ENABLE_ATT_DELAYED_READ_RESPONSE is defined, you may return ATT_READ_RESPONSE_PENDING if data isn't available yet
* @param con_handle of hci le connection
* @param attribute_handle to be read
* @param offset defines start of attribute value
* @param buffer
* @param buffer_size
* @return size of value if buffer is NULL, otherwise number of bytes copied
*/
typedef uint16_t (*att_read_callback_t)(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
// ATT Client Write Callback for Dynamic Data
// @param con_handle of hci le connection
// @param attribute_handle to be written
// @param transaction - ATT_TRANSACTION_MODE_NONE for regular writes. For prepared writes: ATT_TRANSACTION_MODE_ACTIVE, ATT_TRANSACTION_MODE_VALIDATE, ATT_TRANSACTION_MODE_EXECUTE, ATT_TRANSACTION_MODE_CANCEL
// @param offset into the value - used for queued writes and long attributes
// @param buffer
// @param buffer_size
// @param signature used for signed write commmands
// @returns 0 if write was ok, ATT_ERROR_PREPARE_QUEUE_FULL if no space in queue, ATT_ERROR_INVALID_OFFSET if offset is larger than max buffer
//
// Each Prepared Write Request triggers a callback with transaction mode ATT_TRANSACTION_MODE_ACTIVE.
// On Execute Write, the callback will be called with ATT_TRANSACTION_MODE_VALIDATE and allows to validate all queued writes and return an application error.
// If none of the registered callbacks return an error for ATT_TRANSACTION_MODE_VALIDATE and the callback will be called with ATT_TRANSACTION_MODE_EXECUTE.
// Otherwise, all callbacks will be called with ATT_TRANSACTION_MODE_CANCEL.
//
// If the additional validation step is not needed, just return 0 for all callbacks with transaction mode ATT_TRANSACTION_MODE_VALIDATE.
//
/**
* @brief ATT Client Write Callback for Dynamic Data
* Each Prepared Write Request triggers a callback with transaction mode ATT_TRANSACTION_MODE_ACTIVE.
* On Execute Write, the callback will be called with ATT_TRANSACTION_MODE_VALIDATE and allows to validate all queued writes and return an application error.
* If none of the registered callbacks return an error for ATT_TRANSACTION_MODE_VALIDATE and the callback will be called with ATT_TRANSACTION_MODE_EXECUTE.
* Otherwise, all callbacks will be called with ATT_TRANSACTION_MODE_CANCEL.
*
* If the additional validation step is not needed, just return 0 for all callbacks with transaction mode ATT_TRANSACTION_MODE_VALIDATE.
*
* @param con_handle of hci le connection
* @param attribute_handle to be written
* @param transaction - ATT_TRANSACTION_MODE_NONE for regular writes. For prepared writes: ATT_TRANSACTION_MODE_ACTIVE, ATT_TRANSACTION_MODE_VALIDATE, ATT_TRANSACTION_MODE_EXECUTE, ATT_TRANSACTION_MODE_CANCEL
* @param offset into the value - used for queued writes and long attributes
* @param buffer
* @param buffer_size
* @param signature used for signed write commmands
* @return 0 if write was ok, ATT_ERROR_PREPARE_QUEUE_FULL if no space in queue, ATT_ERROR_INVALID_OFFSET if offset is larger than max buffer
*/
typedef int (*att_write_callback_t)(hci_con_handle_t con_handle, uint16_t attribute_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
// Read & Write Callbacks for handle range
@ -168,8 +175,9 @@ typedef struct att_service_handler {
// MARK: ATT Operations
/*
/**
* @brief setup ATT database
* @param db
*/
void att_set_db(uint8_t const * db);
@ -179,23 +187,23 @@ void att_set_db(uint8_t const * db);
*/
void att_set_read_callback(att_read_callback_t callback);
/*
/**
* @brief set callback for write of dynamic attributes
* @param callback
*/
void att_set_write_callback(att_write_callback_t callback);
/*
/**
* @brief debug helper, dump ATT database to stdout using log_info
*/
void att_dump_attributes(void);
/*
/**
* @brief process ATT request against database and put response into response buffer
* @param att_connection used for mtu and security properties
* @param request_buffer, request_len: ATT request from clinet
* @param response_buffer for result
* @returns len of data in response buffer. 0 = no response,
* @return len of data in response buffer. 0 = no response,
* ATT_READ_RESPONSE_PENDING if it was returned at least once for dynamic data (requires ENABLE_ATT_DELAYED_READ_RESPONSE)
*/
uint16_t att_handle_request(att_connection_t * att_connection,
@ -203,7 +211,7 @@ uint16_t att_handle_request(att_connection_t * att_connection,
uint16_t request_len,
uint8_t * response_buffer);
/*
/**
* @brief setup value notification in response buffer for a given handle and value
* @param att_connection
* @param attribute_handle
@ -217,7 +225,7 @@ uint16_t att_prepare_handle_value_notification(att_connection_t * att_connection
uint16_t value_len,
uint8_t * response_buffer);
/*
/**
* @brief setup value indication in response buffer for a given handle and value
* @param att_connection
* @param attribute_handle
@ -231,92 +239,154 @@ uint16_t att_prepare_handle_value_indication(att_connection_t * att_connection,
uint16_t value_len,
uint8_t * response_buffer);
/*
/**
* @brief transcation queue of prepared writes, e.g., after disconnect
* @return att_connection
*/
void att_clear_transaction_queue(att_connection_t * att_connection);
// att_read_callback helpers for a various data types
/*
/**
* @brief Handle read of blob like data for att_read_callback
* @param blob of data
* @param blob_size of blob
* @param offset from att_read_callback
* @param buffer from att_read_callback
* @param buffer_size from att_read_callback
* @returns value size for buffer == 0 and num bytes copied otherwise
* @return value size for buffer == 0 and num bytes copied otherwise
*/
uint16_t att_read_callback_handle_blob(const uint8_t * blob, uint16_t blob_size, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
/*
/**
* @brief Handle read of little endian unsigned 32 bit value for att_read_callback
* @param value
* @param offset from att_read_callback
* @param buffer from att_read_callback
* @param buffer_size from att_read_callback
* @returns value size for buffer == 0 and num bytes copied otherwise
* @return value size for buffer == 0 and num bytes copied otherwise
*/
uint16_t att_read_callback_handle_little_endian_32(uint32_t value, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
/*
/**
* @brief Handle read of little endian unsigned 16 bit value for att_read_callback
* @param value
* @param offset from att_read_callback
* @param buffer from att_read_callback
* @param buffer_size from att_read_callback
* @returns value size for buffer == 0 and num bytes copied otherwise
* @return value size for buffer == 0 and num bytes copied otherwise
*/
uint16_t att_read_callback_handle_little_endian_16(uint16_t value, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
/*
/**
* @brief Handle read of single byte for att_read_callback
* @param blob of data
* @param blob_size of blob
* @param offset from att_read_callback
* @param buffer from att_read_callback
* @param buffer_size from att_read_callback
* @returns value size for buffer == 0 and num bytes copied otherwise
* @return value size for buffer == 0 and num bytes copied otherwise
*/
uint16_t att_read_callback_handle_byte(uint8_t value, uint16_t offset, uint8_t * buffer, uint16_t buffer_size);
// experimental client API
/**
* @brief Get UUID for handle
* @param attribute_handle
* @return 0 if not found
*/
uint16_t att_uuid_for_handle(uint16_t attribute_handle);
// experimental GATT Server API
// returns true if service found. only primary service.
bool gatt_server_get_get_handle_range_for_service_with_uuid16(uint16_t uuid16, uint16_t * start_handle, uint16_t * end_handle);
/**
* @brief Get handle range for primary service.
* @param uuid16
* @param start_handle
* @param end_handle
* @return false if not found
*/
bool gatt_server_get_handle_range_for_service_with_uuid16(uint16_t uuid16, uint16_t * start_handle, uint16_t * end_handle);
// returns 0 if not found
/**
* @brief Get value handle for characteristic.
* @param start_handle
* @param end_handle
* @param uuid16
* @return 0 if not found
*/
uint16_t gatt_server_get_value_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t uuid16);
// returns 0 if not found
/**
* @brief Get descriptor handle for characteristic.
* @param start_handle
* @param end_handle
* @param characteristic_uuid16
* @param descriptor_uuid16
* @return 0 if not found
*/
uint16_t gatt_server_get_descriptor_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16, uint16_t descriptor_uuid16);
/**
* @brief Get client configuration handle for characteristic.
* @param start_handle
* @param end_handle
* @param characteristic_uuid16
* @return 0 if not found
*/
uint16_t gatt_server_get_client_configuration_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16);
/**
* @brief Get server configuration handle for characteristic.
* @param start_handle
* @param end_handle
* @param characteristic_uuid16
* @param descriptor_uuid16
* @return 0 if not found
*/
uint16_t gatt_server_get_server_configuration_handle_for_characteristic_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t characteristic_uuid16);
/**
* @brief Get handle range for primary service.
* @param uuid128
* @param start_handle
* @param end_handle
* @return 0 if not found
*/
int gatt_server_get_handle_range_for_service_with_uuid128(const uint8_t * uuid128, uint16_t * start_handle, uint16_t * end_handle);
// returns 1 if service found. only primary service.
int gatt_server_get_get_handle_range_for_service_with_uuid128(const uint8_t * uuid128, uint16_t * start_handle, uint16_t * end_handle);
// returns 0 if not found
/**
* @brief Get value handle.
* @param start_handle
* @param end_handle
* @param uuid128
* @return 0 if not found
*/
uint16_t gatt_server_get_value_handle_for_characteristic_with_uuid128(uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128);
// returns 0 if not found
/**
* @brief Get client configuration handle.
* @param start_handle
* @param end_handle
* @param uuid128
* @return 0 if not found
*/
uint16_t gatt_server_get_client_configuration_handle_for_characteristic_with_uuid128(uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128);
/* API_END */
// non-user functionality for att_server
/*
/**
* @brief Check if writes to handle should be persistent
* @param handle
* @returns 1 if persistent
* @return 1 if persistent
*/
bool att_is_persistent_ccc(uint16_t handle);
// auto-pts testing, returns response size
#ifdef ENABLE_BTP
uint16_t btp_att_get_attributes_by_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t uuid16, uint8_t * response_buffer, uint16_t response_buffer_size);

View File

@ -99,7 +99,7 @@ void battery_service_server_init(uint8_t value){
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xfff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_BATTERY_SERVICE, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_BATTERY_SERVICE, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -1017,7 +1017,7 @@ void cycling_power_service_server_init(uint32_t feature_flags,
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_CYCLING_POWER, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_CYCLING_POWER, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -291,7 +291,7 @@ void cycling_speed_and_cadence_service_server_init(uint32_t supported_sensor_loc
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_CYCLING_SPEED_AND_CADENCE, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_CYCLING_SPEED_AND_CADENCE, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -117,7 +117,7 @@ void device_information_service_server_init(void){
// get service handle range
uint16_t start_handle;
uint16_t end_handle;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_DEVICE_INFORMATION, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_DEVICE_INFORMATION, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -148,7 +148,7 @@ void heart_rate_service_server_init(heart_rate_service_body_sensor_location_t lo
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_HEART_RATE, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_HEART_RATE, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -287,7 +287,7 @@ void hids_device_init(uint8_t country_code, const uint8_t * descriptor, uint16_t
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xfff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_HUMAN_INTERFACE_DEVICE, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_HUMAN_INTERFACE_DEVICE, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -196,7 +196,7 @@ void mesh_provisioning_service_server_init(void){
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_MESH_PROVISIONING, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_MESH_PROVISIONING, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -159,7 +159,7 @@ void mesh_proxy_service_server_init(void){
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_MESH_PROXY, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_MESH_PROXY, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -123,7 +123,7 @@ void nordic_spp_service_server_init(btstack_packet_handler_t packet_handler){
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid128(nordic_spp_profile_uuid128, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid128(nordic_spp_profile_uuid128, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -152,7 +152,7 @@ void scan_parameters_service_server_init(btstack_packet_handler_t packet_handler
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xfff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_SCAN_PARAMETERS, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_SCAN_PARAMETERS, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -228,7 +228,7 @@ void ublox_spp_service_server_init(btstack_packet_handler_t packet_handler){
// get service handle range
uint16_t start_handle = 0;
uint16_t end_handle = 0xfff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid128(ublox_spp_profile_uuid128, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid128(ublox_spp_profile_uuid128, &start_handle, &end_handle);
btstack_assert(service_found != 0);
UNUSED(service_found);

View File

@ -1234,7 +1234,7 @@ int btstack_main(int argc, const char * argv[]){
// report gatt service handle range for SDP tests
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_GENERIC_ATTRIBUTE, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_GENERIC_ATTRIBUTE, &start_handle, &end_handle);
btstack_assert(service_found != 0);
printf("GATT Service range: 0x%04x - 0x%04x\n", start_handle, end_handle);

View File

@ -1047,7 +1047,7 @@ int btstack_main(int argc, const char * argv[]){
// report gatt service handle range for SDP tests
uint16_t start_handle = 0;
uint16_t end_handle = 0xffff;
int service_found = gatt_server_get_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_GENERIC_ATTRIBUTE, &start_handle, &end_handle);
int service_found = gatt_server_get_handle_range_for_service_with_uuid16(ORG_BLUETOOTH_SERVICE_GENERIC_ATTRIBUTE, &start_handle, &end_handle);
btstack_assert(service_found != 0);
printf("GATT Service range: 0x%04x - 0x%04x\n", start_handle, end_handle);