Add NUS two-characteristic support to NimBLEStream for terminal app compatibility#1140
Draft
Add NUS two-characteristic support to NimBLEStream for terminal app compatibility#1140
Conversation
…pport Agent-Logs-Url: https://github.com/h2zero/NimBLE-Arduino/sessions/07db667d-a538-4e10-93a5-e30616f1f6a9 Co-authored-by: h2zero <32826625+h2zero@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix NimBLE_Stream_Server compatibility with NUS terminal software
Add NUS two-characteristic support to NimBLEStream for terminal app compatibility
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
NimBLE_Stream_Serverexample used NUS UUIDs but a single characteristic for both notify (TX) and write (RX), which is non-standard and breaks compatibility with NUS terminal apps (nRF UART, Serial Bluetooth Terminal, etc.). Standard NUS requires separate TX (6E400003, notify) and RX (6E400002, write) characteristics.Core library changes
NimBLEStreamServerRxChrCallbacksinner struct to handle writes on a dedicated RX characteristicm_pRxChrmember; single-char mode is fully backward-compatible (m_pRxChr == nullptr)begin(pTxChr, pRxChr, ...)overload for externally-created characteristicsbegin(svcUuid, txChrUuid, rxChrUuid, ...)convenience overload — creates a proper two-characteristic NUS service internallyend()restores callbacks and clearsm_pRxChrNimBLEStreamClientm_pRxChrfor the dedicated subscription characteristicbegin(pTxChr, pRxChr, ...)overload —pTxChris written to,pRxChris subscribedend()unsubscribes from the correct characteristic in two-char modeExample updates
Both
NimBLE_Stream_ServerandNimBLE_Stream_Clientexamples updated to use proper NUS two-characteristic layout.NimBLE_Stream_Echo(custom UUIDs, single char) is unchanged.Server setup now:
bleStream.begin(NimBLEUUID(SERVICE_UUID), NimBLEUUID(TX_CHAR_UUID), // 6E400003 — notify NimBLEUUID(RX_CHAR_UUID), // 6E400002 — write 1024, 1024, false);Client setup now:
// pRxChar = 6E400002 (we write here); pTxChar = 6E400003 (we subscribe here) bleStream.begin(pRxChar, pTxChar);