mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/fix_gatt_svc_attrs_count' into 'master'
Bluedroid: Configurable option to modify max gatt service attributes count Closes IDFGH-7861 See merge request espressif/esp-idf!19313
This commit is contained in:
commit
e2d488cf4b
@ -173,6 +173,13 @@ config BT_GATT_MAX_SR_PROFILES
|
||||
help
|
||||
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
|
||||
|
@ -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_gatt_if_t gatts_if,
|
||||
uint8_t max_nb_attr,
|
||||
uint16_t max_nb_attr,
|
||||
uint8_t srvc_inst_id)
|
||||
{
|
||||
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);
|
||||
|
||||
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.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CREATE_ATTR_TAB;
|
||||
|
@ -18,7 +18,7 @@ extern "C" {
|
||||
/// GATT INVALID HANDLE
|
||||
#define ESP_GATT_ILLEGAL_HANDLE 0
|
||||
/// 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 */
|
||||
|
||||
|
||||
|
@ -351,7 +351,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_gatt_if_t gatts_if,
|
||||
uint8_t max_nb_attr,
|
||||
uint16_t max_nb_attr,
|
||||
uint8_t srvc_inst_id);
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
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)) {
|
||||
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) {
|
||||
@ -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,
|
||||
esp_gatt_if_t gatts_if,
|
||||
uint8_t max_nb_attr,
|
||||
uint16_t max_nb_attr,
|
||||
uint8_t srvc_inst_id)
|
||||
{
|
||||
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
|
||||
//the attribute table method to creat a service
|
||||
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.handles[index] = p_data->create.service_id;
|
||||
break;
|
||||
}
|
||||
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;
|
||||
break;
|
||||
}
|
||||
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+1] = p_data->add_result.attr_id;
|
||||
break;
|
||||
}
|
||||
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;
|
||||
break;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ typedef union {
|
||||
struct create_attr_tab_args{
|
||||
esp_gatt_if_t gatts_if;
|
||||
uint8_t srvc_inst_id;
|
||||
uint8_t max_nb_attr;
|
||||
uint16_t max_nb_attr;
|
||||
esp_gatts_attr_db_t *gatts_attr_db;
|
||||
}create_attr_tab;
|
||||
|
||||
@ -149,8 +149,8 @@ typedef struct {
|
||||
esp_bt_uuid_t svc_uuid;
|
||||
bool is_tab_creat_svc;
|
||||
bool is_use_svc;
|
||||
uint8_t num_handle;
|
||||
uint8_t handle_idx;
|
||||
uint16_t num_handle;
|
||||
uint16_t handle_idx;
|
||||
uint16_t handles[ESP_GATT_ATTR_HANDLE_MAX];
|
||||
} esp_btc_creat_tab_t;
|
||||
|
||||
|
@ -258,6 +258,11 @@
|
||||
#define UC_CONFIG_BT_GATT_MAX_SR_PROFILES 8
|
||||
#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
|
||||
#define UC_BT_GATTS_SEND_SERVICE_CHANGE_MODE CONFIG_BT_GATTS_SEND_SERVICE_CHANGE_MODE
|
||||
|
Loading…
Reference in New Issue
Block a user