extmod/nimble: Fail read if the characteristic is too big.
Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
b505971069
commit
f2a9a0ac41
|
@ -608,7 +608,9 @@ static int characteristic_access_cb(uint16_t conn_handle, uint16_t value_handle,
|
||||||
return BLE_ATT_ERR_ATTR_NOT_FOUND;
|
return BLE_ATT_ERR_ATTR_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
os_mbuf_append(ctxt->om, entry->data, entry->data_len);
|
if (os_mbuf_append(ctxt->om, entry->data, entry->data_len)) {
|
||||||
|
return BLE_ATT_ERR_INSUFFICIENT_RES;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
case BLE_GATT_ACCESS_OP_WRITE_CHR:
|
case BLE_GATT_ACCESS_OP_WRITE_CHR:
|
||||||
|
@ -625,6 +627,8 @@ static int characteristic_access_cb(uint16_t conn_handle, uint16_t value_handle,
|
||||||
entry->data_len = MIN(entry->data_alloc, OS_MBUF_PKTLEN(ctxt->om) + offset);
|
entry->data_len = MIN(entry->data_alloc, OS_MBUF_PKTLEN(ctxt->om) + offset);
|
||||||
os_mbuf_copydata(ctxt->om, 0, entry->data_len - offset, entry->data + offset);
|
os_mbuf_copydata(ctxt->om, 0, entry->data_len - offset, entry->data + offset);
|
||||||
|
|
||||||
|
// TODO: Consider failing with BLE_ATT_ERR_INSUFFICIENT_RES if the buffer is full.
|
||||||
|
|
||||||
mp_bluetooth_gatts_on_write(conn_handle, value_handle);
|
mp_bluetooth_gatts_on_write(conn_handle, value_handle);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue