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 and serial 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

BLE Error Handling

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

Serial Error Handling

Handle MeshInterface.MeshInterfaceError for connection timeouts:

  • Connection timed out — device rebooting, firmware updating, serial interrupted

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
  • Test serial connection during device reboot — should show timeout message

@lexfrei lexfrei marked this pull request as ready for review January 25, 2026 15:36
lexfrei and others added 2 commits January 26, 2026 11:07
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>
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>
@lexfrei lexfrei force-pushed the fix/ble-error-handling branch from a8eaa10 to 1fc2407 Compare January 26, 2026 08:07
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