Skip to content

onRead() Callback Fails After setValue() with Data Exceeding MTU #332

Open
@x-radio

Description

@x-radio

Hi folks,

I've stumbled upon an interesting issue with NimBLE. When calling setValue() with data larger than 21 bytes (e.g., setValue("abcdefghijklmnopqrstu")), the onRead() callback stops being triggered. This happens before any MTU change request, when the MTU is still at its default of 23. The characteristic remains readable (e.g., via nRF Connect), but the onRead() callback is no longer called.

Interestingly, if I increase the MTU via a request, everything starts working again. I suspect the issue lies in the append() method, specifically when it sets m_attr_len to a value greater than MTU-2. I’ve confirmed that commenting out the append() call in setValue() prevents the issue entirely.

Here’s a quick repro:

Call setValue("abcdefghijklmnopqrstu") (22 bytes) with default MTU=23.
Try reading the characteristic — the value is returned, but onRead() isn’t triggered.
Increase MTU (e.g., to 100), and onRead() starts working again.
I think adding an MTU check in append() to reject values larger than MTU-2 could fix this.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions