mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 18:57:19 +02:00
Bluedroid: Configurable option to modify max gatt service attributes count
This commit is contained in:
@ -151,6 +151,13 @@ config BT_GATT_MAX_SR_PROFILES
|
|||||||
help
|
help
|
||||||
Maximum GATT Server Profiles Count
|
Maximum GATT Server Profiles Count
|
||||||
|
|
||||||
|
config BT_GATT_MAX_SR_ATTRIBUTES
|
||||||
|
int "Max GATT Service Attributes"
|
||||||
|
depends on BT_GATTS_ENABLE && BT_BLUEDROID_ENABLED
|
||||||
|
range 1 500
|
||||||
|
default 100
|
||||||
|
help
|
||||||
|
Maximum GATT Service Attributes Count
|
||||||
|
|
||||||
|
|
||||||
choice BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
choice BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
||||||
|
@ -85,7 +85,7 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
|
|||||||
|
|
||||||
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
|
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
|
||||||
esp_gatt_if_t gatts_if,
|
esp_gatt_if_t gatts_if,
|
||||||
uint8_t max_nb_attr,
|
uint16_t max_nb_attr,
|
||||||
uint8_t srvc_inst_id)
|
uint8_t srvc_inst_id)
|
||||||
{
|
{
|
||||||
btc_msg_t msg = {0};
|
btc_msg_t msg = {0};
|
||||||
@ -93,6 +93,11 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
|
|||||||
|
|
||||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||||
|
|
||||||
|
if (max_nb_attr > ESP_GATT_ATTR_HANDLE_MAX) {
|
||||||
|
LOG_ERROR("%s the number of attribute should not be greater than CONFIG_BT_GATT_MAX_SR_ATTRIBUTES\n");
|
||||||
|
return ESP_ERR_INVALID_ARG;
|
||||||
|
}
|
||||||
|
|
||||||
msg.sig = BTC_SIG_API_CALL;
|
msg.sig = BTC_SIG_API_CALL;
|
||||||
msg.pid = BTC_PID_GATTS;
|
msg.pid = BTC_PID_GATTS;
|
||||||
msg.act = BTC_GATTS_ACT_CREATE_ATTR_TAB;
|
msg.act = BTC_GATTS_ACT_CREATE_ATTR_TAB;
|
||||||
|
@ -26,7 +26,7 @@ extern "C" {
|
|||||||
/// GATT INVALID HANDLE
|
/// GATT INVALID HANDLE
|
||||||
#define ESP_GATT_ILLEGAL_HANDLE 0
|
#define ESP_GATT_ILLEGAL_HANDLE 0
|
||||||
/// GATT attribute max handle
|
/// GATT attribute max handle
|
||||||
#define ESP_GATT_ATTR_HANDLE_MAX 100
|
#define ESP_GATT_ATTR_HANDLE_MAX UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
|
||||||
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
|
#define ESP_GATT_MAX_READ_MULTI_HANDLES 10 /* Max attributes to read in one request */
|
||||||
|
|
||||||
|
|
||||||
|
@ -359,7 +359,7 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
|
|||||||
*/
|
*/
|
||||||
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
|
esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db,
|
||||||
esp_gatt_if_t gatts_if,
|
esp_gatt_if_t gatts_if,
|
||||||
uint8_t max_nb_attr,
|
uint16_t max_nb_attr,
|
||||||
uint8_t srvc_inst_id);
|
uint8_t srvc_inst_id);
|
||||||
/**
|
/**
|
||||||
* @brief This function is called to add an included service. This function have to be called between
|
* @brief This function is called to add an included service. This function have to be called between
|
||||||
|
@ -127,7 +127,7 @@ void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTC_GATTS_ACT_CREATE_ATTR_TAB: {
|
case BTC_GATTS_ACT_CREATE_ATTR_TAB: {
|
||||||
uint8_t num_attr = src->create_attr_tab.max_nb_attr;
|
uint16_t num_attr = src->create_attr_tab.max_nb_attr;
|
||||||
if (src->create_attr_tab.gatts_attr_db && (num_attr > 0)) {
|
if (src->create_attr_tab.gatts_attr_db && (num_attr > 0)) {
|
||||||
dst->create_attr_tab.gatts_attr_db = (esp_gatts_attr_db_t *) osi_malloc(sizeof(esp_gatts_attr_db_t) * num_attr);
|
dst->create_attr_tab.gatts_attr_db = (esp_gatts_attr_db_t *) osi_malloc(sizeof(esp_gatts_attr_db_t) * num_attr);
|
||||||
if (dst->create_attr_tab.gatts_attr_db) {
|
if (dst->create_attr_tab.gatts_attr_db) {
|
||||||
@ -217,7 +217,7 @@ void btc_gatts_arg_deep_free(btc_msg_t *msg)
|
|||||||
|
|
||||||
static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||||
esp_gatt_if_t gatts_if,
|
esp_gatt_if_t gatts_if,
|
||||||
uint8_t max_nb_attr,
|
uint16_t max_nb_attr,
|
||||||
uint8_t srvc_inst_id)
|
uint8_t srvc_inst_id)
|
||||||
{
|
{
|
||||||
uint16_t uuid = 0;
|
uint16_t uuid = 0;
|
||||||
@ -568,24 +568,24 @@ static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
//save the service handle to the btc module after used
|
//save the service handle to the btc module after used
|
||||||
//the attribute table method to creat a service
|
//the attribute table method to creat a service
|
||||||
bta_to_btc_uuid(&btc_creat_tab_env.svc_uuid, &p_data->create.uuid);
|
bta_to_btc_uuid(&btc_creat_tab_env.svc_uuid, &p_data->create.uuid);
|
||||||
uint8_t index = btc_creat_tab_env.handle_idx;
|
uint16_t index = btc_creat_tab_env.handle_idx;
|
||||||
btc_creat_tab_env.svc_start_hdl = p_data->create.service_id;
|
btc_creat_tab_env.svc_start_hdl = p_data->create.service_id;
|
||||||
btc_creat_tab_env.handles[index] = p_data->create.service_id;
|
btc_creat_tab_env.handles[index] = p_data->create.service_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_GATTS_ADD_INCL_SRVC_EVT: {
|
case BTA_GATTS_ADD_INCL_SRVC_EVT: {
|
||||||
uint8_t index = btc_creat_tab_env.handle_idx;
|
uint16_t index = btc_creat_tab_env.handle_idx;
|
||||||
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id;
|
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_GATTS_ADD_CHAR_EVT: {
|
case BTA_GATTS_ADD_CHAR_EVT: {
|
||||||
uint8_t index = btc_creat_tab_env.handle_idx;
|
uint16_t index = btc_creat_tab_env.handle_idx;
|
||||||
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id - 1;
|
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id - 1;
|
||||||
btc_creat_tab_env.handles[index+1] = p_data->add_result.attr_id;
|
btc_creat_tab_env.handles[index+1] = p_data->add_result.attr_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT: {
|
case BTA_GATTS_ADD_CHAR_DESCR_EVT: {
|
||||||
uint8_t index = btc_creat_tab_env.handle_idx;
|
uint16_t index = btc_creat_tab_env.handle_idx;
|
||||||
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id;
|
btc_creat_tab_env.handles[index] = p_data->add_result.attr_id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ typedef union {
|
|||||||
struct create_attr_tab_args{
|
struct create_attr_tab_args{
|
||||||
esp_gatt_if_t gatts_if;
|
esp_gatt_if_t gatts_if;
|
||||||
uint8_t srvc_inst_id;
|
uint8_t srvc_inst_id;
|
||||||
uint8_t max_nb_attr;
|
uint16_t max_nb_attr;
|
||||||
esp_gatts_attr_db_t *gatts_attr_db;
|
esp_gatts_attr_db_t *gatts_attr_db;
|
||||||
}create_attr_tab;
|
}create_attr_tab;
|
||||||
|
|
||||||
@ -157,8 +157,8 @@ typedef struct {
|
|||||||
esp_bt_uuid_t svc_uuid;
|
esp_bt_uuid_t svc_uuid;
|
||||||
bool is_tab_creat_svc;
|
bool is_tab_creat_svc;
|
||||||
bool is_use_svc;
|
bool is_use_svc;
|
||||||
uint8_t num_handle;
|
uint16_t num_handle;
|
||||||
uint8_t handle_idx;
|
uint16_t handle_idx;
|
||||||
uint16_t handles[ESP_GATT_ATTR_HANDLE_MAX];
|
uint16_t handles[ESP_GATT_ATTR_HANDLE_MAX];
|
||||||
} esp_btc_creat_tab_t;
|
} esp_btc_creat_tab_t;
|
||||||
|
|
||||||
|
@ -245,6 +245,11 @@
|
|||||||
#define UC_CONFIG_BT_GATT_MAX_SR_PROFILES 8
|
#define UC_CONFIG_BT_GATT_MAX_SR_PROFILES 8
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
|
||||||
|
#define UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES CONFIG_BT_GATT_MAX_SR_ATTRIBUTES
|
||||||
|
#else
|
||||||
|
#define UC_CONFIG_BT_GATT_MAX_SR_ATTRIBUTES 100
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
#ifdef CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
||||||
#define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
#define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
||||||
|
Reference in New Issue
Block a user