Skip to content

Commit

Permalink
fix(bt/bluedroid): Fix BLE prepare write
Browse files Browse the repository at this point in the history
  • Loading branch information
esp-zhp authored and espressif-bot committed Dec 23, 2023
1 parent 2e482b8 commit 412ea9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
13 changes: 8 additions & 5 deletions components/bt/host/bluedroid/stack/gatt/gatt_db.c
Original file line number Diff line number Diff line change
Expand Up @@ -1241,15 +1241,18 @@ tGATT_STATUS gatts_write_attr_perm_check (tGATT_SVC_DB *p_db, UINT8 op_code,
// btla-specific ++
else if ( (p_attr->uuid_type == GATT_ATTR_UUID_TYPE_16) &&
(p_attr->uuid == GATT_UUID_CHAR_CLIENT_CONFIG ||
p_attr->uuid == GATT_UUID_CHAR_SRVR_CONFIG) )
p_attr->uuid == GATT_UUID_CHAR_SRVR_CONFIG ||
p_attr->uuid == GATT_UUID_CLIENT_SUP_FEAT ||
p_attr->uuid == GATT_UUID_GAP_ICON
) )
// btla-specific --
{
if (op_code == GATT_REQ_PREPARE_WRITE && offset != 0) { /* does not allow write blob */
status = GATT_NOT_LONG;
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_NOT_LONG,handle:0x%04x",handle);
if (op_code == GATT_REQ_PREPARE_WRITE) { /* does not allow write blob */
status = GATT_REQ_NOT_SUPPORTED;
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_REQ_NOT_SUPPORTED,handle:0x%04x",handle);
} else if (len != max_size) { /* data does not match the required format */
status = GATT_INVALID_ATTR_LEN;
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INVALID_PDU,handle:0x%04x",handle);
GATT_TRACE_ERROR( "gatts_write_attr_perm_check - GATT_INVALID_ATTR_LEN,handle:0x%04x",handle);
} else {
status = GATT_SUCCESS;
}
Expand Down
5 changes: 3 additions & 2 deletions components/bt/host/bluedroid/stack/gatt/gatt_sr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,8 +1448,9 @@ void gatt_attr_process_prepare_write (tGATT_TCB *p_tcb, UINT8 i_rcb, UINT16 hand
}

if ((prepare_record->error_code_app == GATT_SUCCESS)
&& ((status == GATT_INVALID_OFFSET) || (status == GATT_INVALID_ATTR_LEN))){
prepare_record->error_code_app = status;
// update prepare write status for excute write request
&& (status == GATT_INVALID_OFFSET || status == GATT_INVALID_ATTR_LEN || status == GATT_REQ_NOT_SUPPORTED)) {
prepare_record->error_code_app = status;
}

}
Expand Down

0 comments on commit 412ea9d

Please sign in to comment.