mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/btdm_minor_misc' into 'master'
component/bt : fix gatt server table bugs 1. fix gatt server table bugs 2. fix blufi a minor bugs 3. fix example minor mistakes See merge request !438
This commit is contained in:
commit
6e2e456d62
@ -198,7 +198,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
|||||||
|
|
||||||
BTA_GATTS_AddCharacteristic(blufi_env.handle_srvc, &blufi_char_uuid_e2p,
|
BTA_GATTS_AddCharacteristic(blufi_env.handle_srvc, &blufi_char_uuid_e2p,
|
||||||
(GATT_PERM_READ),
|
(GATT_PERM_READ),
|
||||||
(GATT_PERM_READ | GATT_CHAR_PROP_BIT_NOTIFY),
|
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_NOTIFY),
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
break;
|
break;
|
||||||
case BLUFI_CHAR_E2P_UUID: /* ESP32 to Phone */
|
case BLUFI_CHAR_E2P_UUID: /* ESP32 to Phone */
|
||||||
|
@ -448,7 +448,7 @@ static void btc_gattc_unreg_for_notify(btc_ble_gattc_args_t *arg)
|
|||||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||||
param.unreg_for_notify.status = status;
|
param.unreg_for_notify.status = status;
|
||||||
memcpy(¶m.unreg_for_notify.srvc_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_srvc_id_t));
|
memcpy(¶m.unreg_for_notify.srvc_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_srvc_id_t));
|
||||||
memcpy(¶m.unreg_for_notify.char_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_id_t));
|
memcpy(¶m.unreg_for_notify.char_id, &arg->unreg_for_notify.char_id, sizeof(esp_gatt_id_t));
|
||||||
btc_gattc_cb_to_app(ESP_GATTC_UNREG_FOR_NOTIFY_EVT, arg->unreg_for_notify.gattc_if, ¶m);
|
btc_gattc_cb_to_app(ESP_GATTC_UNREG_FOR_NOTIFY_EVT, arg->unreg_for_notify.gattc_if, ¶m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,27 +651,28 @@ tGATT_STATUS gatts_set_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||||||
case GATT_UUID_INCLUDE_SERVICE:
|
case GATT_UUID_INCLUDE_SERVICE:
|
||||||
return GATT_NOT_FOUND;
|
return GATT_NOT_FOUND;
|
||||||
default:
|
default:
|
||||||
if (p_cur->p_value->attr_val.attr_max_len < length) {
|
if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len < length) {
|
||||||
GATT_TRACE_ERROR("gatts_set_attribute_vaule failt:Invalid value length");
|
GATT_TRACE_ERROR("gatts_set_attribute_vaule failt:Invalid value length");
|
||||||
return GATT_INVALID_ATTR_LEN;
|
return GATT_INVALID_ATTR_LEN;
|
||||||
} else {
|
} else if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len > 0) {
|
||||||
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
|
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
|
||||||
p_cur->p_value->attr_val.attr_len = length;
|
p_cur->p_value->attr_val.attr_len = length;
|
||||||
|
} else {
|
||||||
|
return GATT_INVALID_ATTR_LEN;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (p_cur->p_value->attr_val.attr_max_len < length) {
|
if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len < length) {
|
||||||
GATT_TRACE_ERROR("gatts_set_attribute_vaule failt:Invalid value length");
|
GATT_TRACE_ERROR("gatts_set_attribute_vaule failt:Invalid value length");
|
||||||
} else {
|
} else if (p_cur->p_value != NULL && p_cur->p_value->attr_val.attr_max_len > 0) {
|
||||||
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
|
memcpy(p_cur->p_value->attr_val.attr_val, value, length);
|
||||||
p_cur->p_value->attr_val.attr_len = length;
|
p_cur->p_value->attr_val.attr_len = length;
|
||||||
|
} else {
|
||||||
|
return GATT_INVALID_ATTR_LEN;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cur = p_cur->p_next;
|
p_cur = p_cur->p_next;
|
||||||
@ -699,8 +700,9 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||||||
UINT16 *length, UINT8 **value)
|
UINT16 *length, UINT8 **value)
|
||||||
{
|
{
|
||||||
tGATT_ATTR16 *p_cur;
|
tGATT_ATTR16 *p_cur;
|
||||||
GATT_TRACE_DEBUG("***********%s*************\n", __func__);
|
|
||||||
GATT_TRACE_DEBUG("attr_handle = %x\n", attr_handle);
|
GATT_TRACE_DEBUG("attr_handle = %x\n", attr_handle);
|
||||||
|
|
||||||
if (p_db == NULL) {
|
if (p_db == NULL) {
|
||||||
GATT_TRACE_ERROR("gatts_get_attribute_value Fail:p_db is NULL.\n");
|
GATT_TRACE_ERROR("gatts_get_attribute_value Fail:p_db is NULL.\n");
|
||||||
return GATT_INVALID_PDU;
|
return GATT_INVALID_PDU;
|
||||||
@ -713,7 +715,6 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||||||
p_cur = (tGATT_ATTR16 *) p_db->p_attr_list;
|
p_cur = (tGATT_ATTR16 *) p_db->p_attr_list;
|
||||||
|
|
||||||
while (p_cur != NULL) {
|
while (p_cur != NULL) {
|
||||||
LOG_ERROR("p_ur->handle = %x\n", p_cur->handle);
|
|
||||||
if (p_cur->handle == attr_handle) {
|
if (p_cur->handle == attr_handle) {
|
||||||
|
|
||||||
if (p_cur->uuid_type == GATT_ATTR_UUID_TYPE_16) {
|
if (p_cur->uuid_type == GATT_ATTR_UUID_TYPE_16) {
|
||||||
@ -722,7 +723,7 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||||||
case GATT_UUID_INCLUDE_SERVICE:
|
case GATT_UUID_INCLUDE_SERVICE:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (p_cur->p_value->attr_val.attr_len != 0) {
|
if (p_cur->p_value && p_cur->p_value->attr_val.attr_len != 0) {
|
||||||
*length = p_cur->p_value->attr_val.attr_len;
|
*length = p_cur->p_value->attr_val.attr_len;
|
||||||
*value = p_cur->p_value->attr_val.attr_val;
|
*value = p_cur->p_value->attr_val.attr_val;
|
||||||
return GATT_SUCCESS;
|
return GATT_SUCCESS;
|
||||||
@ -748,7 +749,6 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
p_cur = p_cur->p_next;
|
p_cur = p_cur->p_next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1159,7 +1159,7 @@ static void gatts_process_read_req(tGATT_TCB *p_tcb, tGATT_SR_REG *p_rcb, UINT8
|
|||||||
gatt_send_error_rsp (p_tcb, reason, op_code, handle, FALSE);
|
gatt_send_error_rsp (p_tcb, reason, op_code, handle, FALSE);
|
||||||
gatt_dequeue_sr_cmd(p_tcb);
|
gatt_dequeue_sr_cmd(p_tcb);
|
||||||
}
|
}
|
||||||
} else {
|
} else if (reason == GATT_SUCCESS || reason == GATT_STACK_RSP) {
|
||||||
attp_send_sr_msg(p_tcb, p_msg);
|
attp_send_sr_msg(p_tcb, p_msg);
|
||||||
gatt_dequeue_sr_cmd(p_tcb);
|
gatt_dequeue_sr_cmd(p_tcb);
|
||||||
}
|
}
|
||||||
|
@ -247,15 +247,15 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
case ESP_GATTS_REG_EVT:
|
case ESP_GATTS_REG_EVT:
|
||||||
ESP_LOGI(GATTS_TAG, "REGISTER_APP_EVT, status %d, app_id %d\n", param->reg.status, param->reg.app_id);
|
ESP_LOGI(GATTS_TAG, "REGISTER_APP_EVT, status %d, app_id %d\n", param->reg.status, param->reg.app_id);
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].service_id.is_primary = true;
|
gl_profile_tab[PROFILE_B_APP_ID].service_id.is_primary = true;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].service_id.id.inst_id = 0x00;
|
gl_profile_tab[PROFILE_B_APP_ID].service_id.id.inst_id = 0x00;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].service_id.id.uuid.len = ESP_UUID_LEN_16;
|
gl_profile_tab[PROFILE_B_APP_ID].service_id.id.uuid.len = ESP_UUID_LEN_16;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].service_id.id.uuid.uuid.uuid16 = GATTS_SERVICE_UUID_TEST_B;
|
gl_profile_tab[PROFILE_B_APP_ID].service_id.id.uuid.uuid.uuid16 = GATTS_SERVICE_UUID_TEST_B;
|
||||||
|
|
||||||
esp_ble_gap_set_device_name(TEST_DEVICE_NAME);
|
esp_ble_gap_set_device_name(TEST_DEVICE_NAME);
|
||||||
esp_ble_gap_config_adv_data(&test_adv_data);
|
esp_ble_gap_config_adv_data(&test_adv_data);
|
||||||
|
|
||||||
esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_A_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_B);
|
esp_ble_gatts_create_service(gatts_if, &gl_profile_tab[PROFILE_B_APP_ID].service_id, GATTS_NUM_HANDLE_TEST_B);
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_READ_EVT: {
|
case ESP_GATTS_READ_EVT: {
|
||||||
ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle);
|
ESP_LOGI(GATTS_TAG, "GATT_READ_EVT, conn_id %d, trans_id %d, handle %d\n", param->read.conn_id, param->read.trans_id, param->read.handle);
|
||||||
@ -284,13 +284,13 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
|||||||
break;
|
break;
|
||||||
case ESP_GATTS_CREATE_EVT:
|
case ESP_GATTS_CREATE_EVT:
|
||||||
ESP_LOGI(GATTS_TAG, "CREATE_SERVICE_EVT, status %d, service_handle %d\n", param->create.status, param->create.service_handle);
|
ESP_LOGI(GATTS_TAG, "CREATE_SERVICE_EVT, status %d, service_handle %d\n", param->create.status, param->create.service_handle);
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].service_handle = param->create.service_handle;
|
gl_profile_tab[PROFILE_B_APP_ID].service_handle = param->create.service_handle;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].char_uuid.len = ESP_UUID_LEN_16;
|
gl_profile_tab[PROFILE_B_APP_ID].char_uuid.len = ESP_UUID_LEN_16;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].char_uuid.uuid.uuid16 = GATTS_CHAR_UUID_TEST_B;
|
gl_profile_tab[PROFILE_B_APP_ID].char_uuid.uuid.uuid16 = GATTS_CHAR_UUID_TEST_B;
|
||||||
|
|
||||||
esp_ble_gatts_start_service(gl_profile_tab[PROFILE_A_APP_ID].service_handle);
|
esp_ble_gatts_start_service(gl_profile_tab[PROFILE_B_APP_ID].service_handle);
|
||||||
|
|
||||||
esp_ble_gatts_add_char(gl_profile_tab[PROFILE_A_APP_ID].service_handle, &gl_profile_tab[PROFILE_A_APP_ID].char_uuid,
|
esp_ble_gatts_add_char(gl_profile_tab[PROFILE_B_APP_ID].service_handle, &gl_profile_tab[PROFILE_B_APP_ID].char_uuid,
|
||||||
ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
|
ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
|
||||||
ESP_GATT_CHAR_PROP_BIT_READ | ESP_GATT_CHAR_PROP_BIT_WRITE | ESP_GATT_CHAR_PROP_BIT_NOTIFY,
|
ESP_GATT_CHAR_PROP_BIT_READ | ESP_GATT_CHAR_PROP_BIT_WRITE | ESP_GATT_CHAR_PROP_BIT_NOTIFY,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
@ -301,10 +301,10 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
|||||||
ESP_LOGI(GATTS_TAG, "ADD_CHAR_EVT, status %d, attr_handle %d, service_handle %d\n",
|
ESP_LOGI(GATTS_TAG, "ADD_CHAR_EVT, status %d, attr_handle %d, service_handle %d\n",
|
||||||
param->add_char.status, param->add_char.attr_handle, param->add_char.service_handle);
|
param->add_char.status, param->add_char.attr_handle, param->add_char.service_handle);
|
||||||
|
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].char_handle = param->add_char.attr_handle;
|
gl_profile_tab[PROFILE_B_APP_ID].char_handle = param->add_char.attr_handle;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].descr_uuid.len = ESP_UUID_LEN_16;
|
gl_profile_tab[PROFILE_B_APP_ID].descr_uuid.len = ESP_UUID_LEN_16;
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].descr_uuid.uuid.uuid16 = ESP_GATT_UUID_CHAR_CLIENT_CONFIG;
|
gl_profile_tab[PROFILE_B_APP_ID].descr_uuid.uuid.uuid16 = ESP_GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||||
esp_ble_gatts_add_char_descr(gl_profile_tab[PROFILE_A_APP_ID].service_handle, &gl_profile_tab[PROFILE_A_APP_ID].descr_uuid,
|
esp_ble_gatts_add_char_descr(gl_profile_tab[PROFILE_B_APP_ID].service_handle, &gl_profile_tab[PROFILE_B_APP_ID].descr_uuid,
|
||||||
ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
|
ESP_GATT_PERM_READ | ESP_GATT_PERM_WRITE,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
break;
|
break;
|
||||||
@ -326,7 +326,7 @@ static void gatts_profile_b_event_handler(esp_gatts_cb_event_t event, esp_gatt_i
|
|||||||
param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2],
|
param->connect.remote_bda[0], param->connect.remote_bda[1], param->connect.remote_bda[2],
|
||||||
param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5],
|
param->connect.remote_bda[3], param->connect.remote_bda[4], param->connect.remote_bda[5],
|
||||||
param->connect.is_connected);
|
param->connect.is_connected);
|
||||||
gl_profile_tab[PROFILE_A_APP_ID].conn_id = param->connect.conn_id;
|
gl_profile_tab[PROFILE_B_APP_ID].conn_id = param->connect.conn_id;
|
||||||
break;
|
break;
|
||||||
case ESP_GATTS_DISCONNECT_EVT:
|
case ESP_GATTS_DISCONNECT_EVT:
|
||||||
case ESP_GATTS_OPEN_EVT:
|
case ESP_GATTS_OPEN_EVT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user