Component/bt: fix get attr value API error
This commit is contained in:
parent
b650d19c6b
commit
950fe25120
3 changed files with 11 additions and 6 deletions
|
@ -321,6 +321,7 @@ esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *l
|
|||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (attr_handle == ESP_GATT_ILLEGAL_HANDLE) {
|
||||
*length = 0;
|
||||
return ESP_GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -767,6 +767,7 @@ tGATT_STATUS GATTS_GetAttributeValue(UINT16 attr_handle, UINT16 *length, UINT8 *
|
|||
|
||||
if ((p_decl = gatt_find_hdl_buffer_by_attr_handle(attr_handle)) == NULL) {
|
||||
GATT_TRACE_ERROR("Service not created\n");
|
||||
*length = 0;
|
||||
return GATT_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
|
|
|
@ -783,10 +783,12 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||
|
||||
if (p_db == NULL) {
|
||||
GATT_TRACE_ERROR("gatts_get_attribute_value Fail:p_db is NULL.\n");
|
||||
*length = 0;
|
||||
return GATT_INVALID_PDU;
|
||||
}
|
||||
if (p_db->p_attr_list == NULL) {
|
||||
GATT_TRACE_ERROR("gatts_get_attribute_value Fail:p_db->p_attr_list is NULL.\n");
|
||||
*length = 0;
|
||||
return GATT_INVALID_PDU;
|
||||
}
|
||||
if (length == NULL){
|
||||
|
@ -795,6 +797,7 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||
}
|
||||
if (value == NULL){
|
||||
GATT_TRACE_ERROR("gatts_get_attribute_value Fail:value is NULL.\n");
|
||||
*length = 0;
|
||||
return GATT_INVALID_PDU;
|
||||
}
|
||||
|
||||
|
@ -814,19 +817,19 @@ tGATT_STATUS gatts_get_attribute_value(tGATT_SVC_DB *p_db, UINT16 attr_handle,
|
|||
*value = p_cur->p_value->attr_val.attr_val;
|
||||
return GATT_SUCCESS;
|
||||
} else {
|
||||
GATT_TRACE_ERROR("gatts_get_attribute_value failed:the value length is 0");
|
||||
return GATT_INVALID_ATTR_LEN;
|
||||
*length = 0;
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
*value = p_cur->p_value->attr_val.attr_val;
|
||||
return GATT_SUCCESS;
|
||||
} else {
|
||||
GATT_TRACE_ERROR("gatts_get_attribute_value failed:the value length is 0");
|
||||
return GATT_INVALID_ATTR_LEN;
|
||||
*length = 0;
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue