From 2c1f269918331a50678119410219e965fcdb822e Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Tue, 22 Oct 2019 01:03:17 +1100 Subject: [PATCH] extmod/modbluetooth_nimble: Use `data_alloc` length to truncate writes. This allows the maximum size of a characteristic/descriptor to be increased by locally writing to it first. --- extmod/modbluetooth_nimble.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/modbluetooth_nimble.c b/extmod/modbluetooth_nimble.c index d873368581..6287ca89ee 100644 --- a/extmod/modbluetooth_nimble.c +++ b/extmod/modbluetooth_nimble.c @@ -430,7 +430,7 @@ static int characteristic_access_cb(uint16_t conn_handle, uint16_t value_handle, return BLE_ATT_ERR_ATTR_NOT_FOUND; } entry = MP_OBJ_TO_PTR(elem->value); - entry->data_len = MIN(MP_BLUETOOTH_MAX_ATTR_SIZE, OS_MBUF_PKTLEN(ctxt->om)); + entry->data_len = MIN(entry->data_alloc, OS_MBUF_PKTLEN(ctxt->om)); os_mbuf_copydata(ctxt->om, 0, entry->data_len, entry->data); mp_bluetooth_gatts_on_write(conn_handle, value_handle);