Skip to content

[Bugfix] Stream available for write / Arduino memory release - #434

Merged
h2zero merged 2 commits into
masterfrom
bugfix/stream-availableForWrite-signature
Aug 1, 2026
Merged

[Bugfix] Stream available for write / Arduino memory release#434
h2zero merged 2 commits into
masterfrom
bugfix/stream-availableForWrite-signature

Conversation

@h2zero

@h2zero h2zero commented Aug 1, 2026

Copy link
Copy Markdown
Owner

Fixes #432
Fixes #433

Summary by CodeRabbit

  • Bug Fixes
    • Improved compatibility with supported ESP32 Arduino environments.
    • Updated stream buffer availability reporting to use the standard integer format.
    • Safely reports zero available write space when no transmission buffer is present.
    • Improved consistency for applications checking whether data can be written to a Bluetooth stream.

@h2zero h2zero changed the title Bugfix/stream available for write / arduino memory relese Bugfix/stream available for write / arduino memory release Aug 1, 2026
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Arrr, NimBLEStream::availableForWrite() now matches the base stream interface with a non-const int return type. ESP Arduino builds conditionally include esp32-hal-bt-mem.h when available.

Changes

Stream and ESP32 compatibility

Layer / File(s) Summary
Stream write availability override
src/NimBLEStream.h, src/NimBLEStream.cpp
The non-Arduino Stream stub now defines availableForWrite(). NimBLEStream overrides it with a non-const int return type and casts the TX buffer space.
Optional ESP32 Bluetooth memory include
src/NimBLEDevice.cpp
When the header exists under ESP Arduino builds, the code includes esp32-hal-bt-mem.h.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Poem

Arrr, the stream reports space anew,
With int returned and const cast away.
The ESP header joins the crew,
When the header is available.
Four small changes sail today.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #432 with the Arduino Bluetooth memory header and issue #433 with the matching availableForWrite() signature.
Out of Scope Changes check ✅ Passed All changes are limited to NimBLE Arduino integration and NimBLEStream API compatibility required by issues #432 and #433.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies both main fixes: Stream write availability and Arduino memory release.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/stream-availableForWrite-signature

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This makes the availableForWrite signature override compatible with Arduino Print.
@h2zero
h2zero force-pushed the bugfix/stream-availableForWrite-signature branch from f480049 to 733c996 Compare August 1, 2026 01:40
@h2zero
h2zero force-pushed the bugfix/stream-availableForWrite-signature branch from 733c996 to 4b29215 Compare August 1, 2026 14:33
@h2zero h2zero changed the title Bugfix/stream available for write / arduino memory release [Bugfix] Stream available for write / Arduino memory release Aug 1, 2026
@h2zero
h2zero merged commit 3413bf9 into master Aug 1, 2026
66 checks passed
@h2zero
h2zero deleted the bugfix/stream-availableForWrite-signature branch August 1, 2026 14:45
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

Successfully merging this pull request may close these issues.

size_t availableForWrite() is hidding the virtual method BLE_INIT: controller init failed error with ESP-IDF and Arduino component

1 participant