Skip to content

Add NUS two-characteristic support to NimBLEStream for terminal app compatibility#1140

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-nimble-stream-server-compatibility
Draft

Add NUS two-characteristic support to NimBLEStream for terminal app compatibility#1140
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-nimble-stream-server-compatibility

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 31, 2026

The NimBLE_Stream_Server example 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

NimBLEStreamServer

  • Added RxChrCallbacks inner struct to handle writes on a dedicated RX characteristic
  • Added m_pRxChr member; single-char mode is fully backward-compatible (m_pRxChr == nullptr)
  • New begin(pTxChr, pRxChr, ...) overload for externally-created characteristics
  • New begin(svcUuid, txChrUuid, rxChrUuid, ...) convenience overload — creates a proper two-characteristic NUS service internally
  • end() restores callbacks and clears m_pRxChr

NimBLEStreamClient

  • Added m_pRxChr for the dedicated subscription characteristic
  • New begin(pTxChr, pRxChr, ...) overload — pTxChr is written to, pRxChr is subscribed
  • end() unsubscribes from the correct characteristic in two-char mode

Example updates

Both NimBLE_Stream_Server and NimBLE_Stream_Client examples 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);

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
Copilot AI requested a review from h2zero March 31, 2026 23:58
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.

The new example, NimBLE_Stream_Server, is incompatible with some NUS terminal software.

2 participants