Skip to content

feat(settings): find and pair RNodes instead of typing ble:// - #5

Merged
Sidpatchy merged 13 commits into
Sidpatchy:mainfrom
zvx-echo6:feat/rnode-ble-picker
Nov 24, 2026
Merged

Sidpatchy merged 13 commits into
Sidpatchy:mainfrom
zvx-echo6:feat/rnode-ble-picker

Conversation

@zvx-echo6

Copy link
Copy Markdown
Collaborator

Builds on #2 (Bluetooth-off fix). Until #2 merges, this PR also shows its commits; the picker changes are the last 12 commits. #3 touches some of the same files, so whichever merges second needs a rebase.

The RNode card used to need a typed ble://device name. It now lets you pick the connection and the device.

What it does

  • Connect over: Bluetooth / Wi-Fi. Wi-Fi keeps a host field. Desktop keeps a serial port field.
  • Find RNode: scans and lists only devices named like an RNode ("RNode …"). Other Nordic UART devices, such as MeshCore companions, are hidden. Each row shows signal strength in bars plus words, a Paired mark, and the last two address bytes when two RNodes share a name.
  • Pairing: picking an unpaired RNode starts pairing. The dialog title becomes "Pair with RNode 1F2E", and Android shows its own PIN prompt.
    • On failure: Try again / Skip pairing / Cancel. Pairing is optional, because some RNode firmware doesn't require it.
    • Error text: plain words, never Android reason codes. On LE, Android reports a wrong PIN, a cancel and a dropped link all as UNBOND_REASON_AUTH_FAILED, so they share one message.
  • Saved RNode: the card shows name, address, Paired / Not paired, and Pair / Change / Forget. The bond state is checked again when the app returns to the foreground and on ACTION_BOND_STATE_CHANGED, so a pairing removed in Android settings shows as Not paired.
  • Connecting: the saved RNode is connected by address (Android) or peripheral identifier (iOS), with no name scan.
  • Old configs: a saved ble://name still works. A bare ble:// now only ever picks a device named "RNode …".
  • Scan errors: plain wording ("Bluetooth search failed. Turn Bluetooth off and on, then try again.").
  • Permissions: public APIs only. No reflection, no hidden removeBond.

Tested on a device

Pixel 8 (Android 16):

  • Stock RNode 1.86 (LilyGO T3S3 SX1280): scan, PIN pairing, pairing timeout then Try again, Paired card, node online at 2.4 GHz, announces both ways over LoRa, an LXMF message delivered through an R2G transport node, and the echo back.
  • R2G companion firmware, same board: scan (only the RNode listed), permission prompt, cancelled pairing, PIN pairing, node online, message and echo, Bluetooth off and on with reconnect (with fix(android): keep a BLE RNode working when Bluetooth turns off #2), board power cycle with reconnect, and unpairing in Android settings showing Not paired.

desktopTest 170, debug APK, and the iOS Kotlin compiles (compileKotlinIosArm64, compileKotlinIosSimulatorArm64) all pass.

Screenshots

01-scan 02-render-scan-three-results 03-render-pairing 04-paired-node-online 05-not-paired-after-unpair

Not verified

  • iOS: the Swift scanner (StarlingRNodeBluetoothScanner.swift) has not been compiled or run. Only the Kotlin side compiles.
  • Wi-Fi RNode and desktop serial: not tested on hardware, only in renders.
  • While Bluetooth is off, the saved RNode shows "Not paired", because Android reports no bonds while the adapter is off. Pairing is intact, and the card corrects itself when Bluetooth returns.

zvx-echo6 and others added 13 commits November 24, 2026 12:14
Derive an RNode's connection type from its saved value, tell a device id
from a device name by format, and keep the chosen device's name and
whether Starling paired it in two optional fields appended to the
interface record. Older six-field records still load.

A name saved by an older version is upgraded to the device id after a
successful connection. A bare ble:// is never pinned to a device.
Covers prefix-derived connection types, id and name detection, the
legacy-name upgrade, persistence with and without the appended fields,
scan-row sorting, de-duplication and freezing, signal labels and the
validation and picker messages.
Replace the free-text connection field with Connect over choices:
Bluetooth or Wi-Fi on phones, Serial port or Wi-Fi on desktop. A
Bluetooth RNode is chosen from a search dialog that also walks through
pairing; the card shows the chosen device with Change and Forget.

The editor is read-only while the node is running or starting. A
Bluetooth RNode is shown by name in status and diagnostics.
Search for devices advertising the Nordic UART service, report why a
search cannot run (permission, Bluetooth off, Location off on Android 11
and older) and hold back search starts before Android throttles them.

Pair with createBond and follow ACTION_BOND_STATE_CHANGED. A device that
Android knows as dual-mode or classic is paired from an LE connection
instead, since createBond cannot name a transport. Permission requests
now report granted, denied or permanently denied.
With a saved device address the bridge connects directly instead of
scanning, and reconnects the same way. A pairing Starling created that
has since been removed fails the start before connecting, and GATT
authentication failures are reported as a missing pairing. Saved names
and a bare ble:// keep the scan path.

The service reports the connected device so a saved name can be
upgraded to its address.
Add a CoreBluetooth scanner that reports signal strength and makes a
trial connection to the picked RNode: subscribing to the UART service is
when iOS pairs if the RNode requires it. The peripheral identifier is
saved and the bridge connects through retrievePeripherals, scanning only
to find the same identifier again.

The Swift sources have not been compiled; the Kotlin side builds for
iosArm64.
- Tell same-name RNodes apart by the last two bytes of their id, written
  like the end of a Bluetooth address (77:10).
- Show "Choose an RNode..." in the card only after a start was tried
  without one, not as soon as the card is empty.
- Title the pairing steps "Pair with {name}".
- Show "Not paired" and "Forget" in the muted colour; pairing is
  optional, so neither is an error.
- Stack the buttons of the failed-pairing step so they fit narrow
  screens and large fonts.
- Keep each example serial port path on one line.
List only devices named like an RNode in the search dialog, on Android and iOS; other radios offer the same UART service. Replace the pairing failure message that showed a raw reason code. Check the saved RNode pairing again when the app returns to the front or Android reports a pairing change, so a pairing removed in Bluetooth settings shows as Not paired.
The search-failed message no longer shows the Android error code; the code goes to the debug log. A saved ble:// port with no name now takes only a device named like an RNode, the rule the picker uses. A typed name or address is still matched exactly.
…ys so

Android gives the same reason, authentication failed, for a PIN that did not match, a cancelled PIN prompt and a link that dropped during pairing, so that reason now shows the general pairing message. The timeout reason is unchanged. The reason is written to the info log.
A saved ble:// port with no name now takes only a device whose name starts with RNode and a space, the rule the picker and Android use. A typed name is still matched exactly.
@Sidpatchy
Sidpatchy merged commit 80d2553 into Sidpatchy:main Nov 24, 2026
14 checks passed
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