Skip to content

Please increase buffers size for Nordic UART Service from 64 to 256 bytes #127

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

Closed
box8 opened this issue Jul 4, 2021 · 3 comments
Closed

Comments

@box8
Copy link

box8 commented Jul 4, 2021

In nRF5 SDK 17.0.2 in ble_nus.h BLE_NUS_MAX_DATA_LEN defined as:

#define OPCODE_LENGTH 1
#define HANDLE_LENGTH 2
...
#define BLE_NUS_MAX_DATA_LEN (NRF_SDH_BLE_GATT_MAX_MTU_SIZE - OPCODE_LENGTH - HANDLE_LENGTH)

BLE 4.2 allows 247 bytes for NRF_SDH_BLE_GATT_MAX_MTU_SIZE, so BLE_NUS_MAX_DATA_LEN = 244

Current version of UARTService just drops extra bytes (64+) from received packet.

@dhalbert
Copy link
Collaborator

dhalbert commented Jul 6, 2021

We would be happy to entertain a PR, if you feel up to it.

@tannewt BTW, do you see dropping of bytes in the REPL serial, when, say, pasting a long string into the REPl?

@box8
Copy link
Author

box8 commented Jul 6, 2021

I'm currently working on nRF52832 firmware, NUS transfer implemented as described in https://www.programmersought.com/article/17621618211/ Method 2+ -- burst of ble_nus_data_send when BLE_NUS_EVT_TX_RDY event received.
The amount of data sent in one burst is ~950 bytes, so 256 byte buffer is not enough anyway. Implementing #37 would be better.

@tannewt
Copy link
Member

tannewt commented Jul 8, 2021

First, we aren't using BLE_NUS_MAX_DATA_LEN internally at all.

For the serial BLE in CircuitPython, I'm creating my own incoming characteristic buffer and outgoing packet buffer. I haven't tested it extensively so I'm not sure if we'll see reliability issues. I imagine we will in extreme cases but the nordic uart service doesn't manage control flow. So, I'm not sure how you improve that. The file transfer service does its own control flow to make sure peripheral side buffers aren't overrun.

The Method 2+ thing looks to be managing the outgoing buffer, NOT the incoming buffer on the receiver. In CircuitPython, PacketBuffer will do this for you already.

#37 is the better long term fix but it's low priority for us. @box8 I'd recommend copying the definitions and changing the buffer size for yourself. That'll be simplest and doable now.

@tannewt tannewt closed this as completed Jul 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants