Skip to content

mpble: the P4 reports MTU 23 to a Windows central that negotiated more #80

Closed

Description

@bdbarnett

Found while proving bledev.webble (PR stacked on #78): when Chrome on Windows connects to the P4 panel, the P4's connection.mtu stays at 23 for the whole link, even though the link negotiated more. The P4 received 244-byte writes without response intact, which a 23-byte MTU can't carry.

What you'd see. nus.serve() on the P4 splits what it sends to mtu - 3 = 20 bytes, so notifications to Windows run at 4-7 KB/s instead of 15-20. Nothing fails; it's just slow, and the MTU the board reports is wrong.

Evidence, 2026-09-24, Chrome 153 on Windows 11 to the P4 (MicroPython 1.29 kitchen-sink + speaker-usermod image with micropython-pydevices#10, aioble 0.6.2): in 11 connections, nus_gate_server.py logged connected, mtu 23, answered the page's MTU query with 23, and logged UP OK ... mtu 23 after receiving 16 KB as 244-byte writes, byte for byte. From Chrome on Android (which asks for 517 right after connecting), the same board reported 247 every time.

Likely cause, not verified: Windows exchanges the MTU immediately on connect, and aioble only records _IRQ_MTU_EXCHANGED for a connection it already knows. If the event beats aioble's _IRQ_CENTRAL_CONNECT handling, it's dropped. The check is to log every _IRQ_MTU_EXCHANGED with its handle beside the connect event.

If that's it, mpble can fix it without forking aioble, by recording the MTU in its own IRQ handler and applying it when the connection appears, or by reading it back once connected.

Activity

  1. bdbarnett commented on Sep 25, 2026

    @bdbarnett
    ContributorAuthor

    This doesn't happen with current bledev. The P4 reported MTU 247 on all 26 connections from Windows (bleak 3.0.2) on 2026-09-24, with /lib/bledev from bledev-hid. That branch carries #81's mpble fix, which records the MTU exchange MicroPython reports before the connect event. Windows exchanges the MTU at once, so this issue was that same bug.

    Not checked: Chrome on Windows through webble, the path this issue was found on. The webble branch (#82) is stacked on #78, not #81, so it doesn't have the fix until the stack is merged. Close this when #81 merges and a Chrome run shows 247.

  2. bdbarnett commented on Sep 25, 2026

    @bdbarnett
    ContributorAuthor

    Not a P4 bug. It's MicroPython 1.29 delivering the MTU exchange before the connect event, which mpble now handles (#81, merged 2026-09-25, released in 0.5.4). The P4 reported 247 on all 26 connections from bleak on Windows. The upstream draft is micropython-pydevices#11.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions