Skip to content

Conversation

@lexfrei
Copy link
Contributor

@lexfrei lexfrei commented Jan 25, 2026

Summary

Replace raw Python tracebacks with helpful error messages when BLE operations fail.

Before:

Traceback (most recent call last):
  File "meshtastic/__main__.py", line 1368, in common
    client = BLEInterface(...)
  ...
meshtastic.ble_interface.BLEInterface.BLEError: No Meshtastic BLE peripheral with identifier...

After:

BLE device not found.

Possible causes:
  - Bluetooth is disabled on the Meshtastic device
  - Device is in deep sleep mode
  - Device is out of range

Try:
  - Press the reset button on your device
  - Run 'meshtastic --ble-scan' to see available devices

Changes

Wrap BLEInterface() constructor in try/except and provide context-aware error messages for:

  • Device not found — BLE disabled, sleep mode, out of range
  • Multiple devices found — need to specify which one
  • Write errors — pairing PIN required, Linux bluetooth group
  • Read errors — device disconnected unexpectedly

Important Note

⚠️ This PR is based on #893 (BLE macOS fix). The diff against master will show more changes than this PR actually introduces because it includes commits from the base branch.

Without #893, BLE doesn't work on macOS at all, so this error handling improvement builds on top of that fix.

Test Plan

  • Run meshtastic --ble nonexistent — should show "device not found" message
  • Test with device in sleep mode — should show helpful suggestions
  • Test on Linux without bluetooth group membership

Replace raw tracebacks with helpful error messages that explain:
- What went wrong
- Possible causes
- How to fix it

Covers all BLEError cases:
- Device not found (BLE disabled, sleep mode, out of range)
- Multiple devices found (need to specify which one)
- Write errors (pairing PIN, Linux bluetooth group)
- Read errors (device disconnected)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
@lexfrei lexfrei marked this pull request as ready for review January 25, 2026 15:36
Handle MeshInterface.MeshInterfaceError when device is rebooting
or connection times out, with user-friendly error message.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
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.

1 participant