att_server: move att_server_eatt_bearer_t to header, document att_server_eatt_init

This commit is contained in:
Matthias Ringwald 2024-09-19 14:04:19 +02:00
parent 370c8b58f8
commit 29f2ca2149
2 changed files with 16 additions and 13 deletions

View File

@ -60,7 +60,6 @@
#include "btstack_memory.h"
#include "btstack_run_loop.h"
#include "gap.h"
#include "hci.h"
#include "hci_dump.h"
#include "l2cap.h"
#include "btstack_tlv.h"
@ -118,13 +117,6 @@ static hci_con_handle_t att_server_last_can_send_now = HCI_CON_HANDLE_INVALID;
static uint8_t att_server_flags;
#ifdef ENABLE_GATT_OVER_EATT
typedef struct {
btstack_linked_item_t item;
att_server_t att_server;
att_connection_t att_connection;
uint8_t * receive_buffer;
uint8_t * send_buffer;
} att_server_eatt_bearer_t;
static att_server_eatt_bearer_t * att_server_eatt_bearer_for_con_handle(hci_con_handle_t con_handle);
static btstack_linked_list_t att_server_eatt_bearer_pool;
static btstack_linked_list_t att_server_eatt_bearer_active;
@ -1684,8 +1676,6 @@ uint8_t att_server_eatt_init(uint8_t num_eatt_bearers, uint8_t * storage_buffer,
eatt_bearer++;
}
// TODO: define minimum EATT MTU
l2cap_ecbm_register_service(att_server_eatt_handler, BLUETOOTH_PSM_EATT, 64, LEVEL_2, false);
return 0;
return l2cap_ecbm_register_service(att_server_eatt_handler, BLUETOOTH_PSM_EATT, 64, LEVEL_2, false);
}
#endif

View File

@ -44,6 +44,7 @@
#define ATT_SERVER_H
#include <stdint.h>
#include "hci.h"
#include "ble/att_db.h"
#include "btstack_defines.h"
#include "btstack_config.h"
@ -52,6 +53,16 @@
extern "C" {
#endif
#ifdef ENABLE_GATT_OVER_EATT
typedef struct {
btstack_linked_item_t item;
att_server_t att_server;
att_connection_t att_connection;
uint8_t * receive_buffer;
uint8_t * send_buffer;
} att_server_eatt_bearer_t;
#endif
/* API_START */
/*
* @brief setup ATT server
@ -66,8 +77,10 @@ void att_server_init(uint8_t const * db, att_read_callback_t read_callback, att_
* @note Requires ENABLE_GATT_OVER_EATT
* @param num_eatt_bearers
* @param storage_buffer
* @param storage_size
* @return
* @param storage_size must be >= num_eatt_bearers * sizeof(att_server_eatt_bearer_t)
* @return status ERROR_CODE_SUCCESS
* ERROR_CODE_MEMORY_CAPACITY_EXCEEDED if buffer too small or no entry in l2cap service pool
* L2CAP_SERVICE_ALREADY_REGISTERED if called twice
*/
uint8_t att_server_eatt_init(uint8_t num_eatt_bearers, uint8_t * storage_buffer, uint16_t storage_size);