Skip to content

Add ability to set custom MTU via connect options#75

Merged
stoprocent merged 1 commit into
mainfrom
claude/add-custom-mtu-KDQjg
Mar 31, 2026
Merged

Add ability to set custom MTU via connect options#75
stoprocent merged 1 commit into
mainfrom
claude/add-custom-mtu-KDQjg

Conversation

@stoprocent
Copy link
Copy Markdown
Owner

Summary

  • Allows users to specify a desired MTU per-connection via peripheral.connect({ mtu: 512 }), resolving the hardcoded 256-byte limit
  • Defaults to 256 when not specified, preserving existing behavior
  • Only affects the HCI socket binding (Mac/Win handle MTU at the OS level)

Usage

// Before (hardcoded to 256)
await peripheral.connectAsync();

// After (custom MTU)
await peripheral.connectAsync({ mtu: 512 });

Changes

  • lib/hci-socket/gatt.js: Accept optional desiredMtu parameter in Gatt constructor, used as _desired_mtu (falls back to 256)
  • lib/hci-socket/bindings.js: Extract mtu from connection parameters and pass it to the Gatt constructor

Test plan

  • Connect to a peripheral without mtu option — should negotiate MTU of 256 (unchanged behavior)
  • Connect with { mtu: 512 } — should negotiate up to 512 with the remote device
  • Verify peripheral.mtu reflects the negotiated value after connection

Closes #71

https://claude.ai/code/session_014RCJBatLRdZ3pqdSFaAgkv

Allow users to specify a desired MTU per-connection by passing an `mtu`
option to `peripheral.connect({ mtu: 512 })`. Defaults to 256 if not
specified, preserving existing behavior.

Closes #71

https://claude.ai/code/session_014RCJBatLRdZ3pqdSFaAgkv
@stoprocent stoprocent merged commit 4de67d9 into main Mar 31, 2026
28 of 29 checks passed
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 2.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add ability to set custom mtu

2 participants