Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/pb-service/src/pb_service/hub/rfcomm/port.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ def split_hub_name(name: str | None) -> tuple[str | None, HubType | None]:
if kind is None:
return name, None

return name[:start].strip() or None, kind
# The firmware joins the two with exactly one space (name, then
# " (" PBSYS_CONFIG_HUB_TYPE_STR ")", in pbsys_host_get_hub_display_name),
# so only that one goes. Any other spaces are the owner's, and the hub
# reports its name with them, which is what a name filter is matched on.
bare = name[:start].removesuffix(" ")

return bare or None, kind


class ChannelPipe:
Expand Down
3 changes: 3 additions & 0 deletions packages/pb-service/tests/test_rfcomm_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
("Pybricks (MINDSTORMS NXT)", "Pybricks", HubType.NXT),
# The whole name can be the suffix if the hub was never named.
("(MINDSTORMS EV3)", None, HubType.EV3),
# Only the firmware's one separating space goes. The rest belongs to
# the name, which the hub reports with them, and filters match it.
(" Bumblebee (MINDSTORMS EV3)", " Bumblebee ", HubType.EV3),
],
)
def test_the_firmware_suffix_names_the_brick(
Expand Down
Loading