Skip to content

pb-service: keep the spaces that belong to a hub's name - #7

Merged
dlech merged 1 commit into
mainfrom
rfcomm-hub-name-spaces
Oct 18, 2026
Merged

dlech merged 1 commit into
mainfrom
rfcomm-hub-name-spaces

Conversation

@dlech

@dlech dlech commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Stacked on #6, which adds split_hub_name. GitHub will retarget this to main when #6 merges.

The firmware builds a hub's Bluetooth name as its own name, one space, then (MINDSTORMS EV3) or (MINDSTORMS NXT). That's pbsys_host_get_hub_display_name in pybricks-micropython's lib/pbio/sys/host.c. split_hub_name took the type off with strip(), which also removed spaces belonging to the name itself. So a hub named " Bumblebee " was listed as "Bumblebee", while the hub reports its name with the spaces, and a name filter, which matches exactly, could not find it.

Now only the one separating space is removed. A new test case covers a name with leading and trailing spaces.

Found by Copilot's review of #6.

Base automatically changed from rfcomm-ev3 to main October 18, 2026 15:56
The firmware builds its Bluetooth name as the hub's name, one space and
"(MINDSTORMS EV3)" or "(MINDSTORMS NXT)" (pbsys_host_get_hub_display_name).
Taking the type off stripped every space around the name, so a hub named
" Bumblebee " was listed as "Bumblebee", and a name filter, which matches
exactly, could not find it. Only the one separating space goes now.
@dlech
dlech force-pushed the rfcomm-hub-name-spaces branch from 805ad45 to b7be025 Compare October 18, 2026 16:04
@dlech
dlech requested a balanced review from Copilot October 18, 2026 16:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused fix preserves name whitespace and includes regression coverage, with no unresolved findings.

No open issues 🎉

What changed in this PR

Preserves spaces belonging to RFCOMM hub names so discovery names remain compatible with exact-name filters.

Changes:

  • Removes only the firmware’s single separating space before the hub-type suffix.
  • Adds regression coverage for leading and trailing spaces in a hub name.
File Description
packages/​pb-service/​tests/​test_rfcomm_naming.py Tests preservation of spaces in hub names.
packages/​pb-service/​src/​pb_service/​hub/​rfcomm/​port.py Replaces whitespace stripping with single-space suffix removal.

Review effort: Balanced

@dlech
dlech merged commit 2d9306c into main Oct 18, 2026
24 checks passed
@dlech
dlech deleted the rfcomm-hub-name-spaces branch October 18, 2026 16:10
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.

2 participants