New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extmod/modbluetooth: Enable configuration of rx buffer. #5268
Conversation
extmod/modbluetooth_nimble.c
Outdated
return MP_EINVAL; | ||
} | ||
gatts_db_entry_t *entry = MP_OBJ_TO_PTR(elem->value); | ||
entry->data = m_new(uint8_t, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be better to use m_renew(uint8_t, entry->data, entry->data_alloc, len)
, to reuseresize memory where possible
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I considered using m_renew (and truncating data_len to the new data_alloc) to preserve existing data, but scrapped that because the intention is that it's only called once at registration.
But just for the purpose of possible reusing the allocation, makes sense. Done.
Great, it's very clean! Just to play devil's advocate: why not put this buffer configuration in the services/chars structure passed to |
- Adds an explicit way to set the size of a value's internal buffer, replacing `ble.gatts_write(handle, bytes(size))` (although that still works). - Add an "append" mode for values, which means that remote writes will append to the buffer.
f53ba26
to
08d9ece
Compare
Because that structure is complicated and ordinal-based, I'm very hesitant to add additional fields to it that only apply to a very small number of chars/descs. i.e. if we later add another field, then now everything has to provide defaults for the buffer params. (A named tuple or dict would address that, but much more complexity). |
Update tinyusb for USB Compliance Verification test
Enables a straightforward way to use the NUS without worrying about losing writes if there's a delay calling gatts_read before the next write appears.
Thanks to @mirko for the suggestion.