mirror of
https://github.com/smittix/intercept.git
synced 2026-07-14 20:48:11 -07:00
fix: Add serial port discovery for Meshtastic multi-port systems
When multiple serial ports are detected (e.g., /dev/ttyACM0 and /dev/ttyUSB0), the Meshtastic SDK's auto-detect fails. This adds a /meshtastic/ports endpoint to list available ports and populates the device dropdown, auto-selecting the first port when multiple exist. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,6 +57,38 @@ def _message_callback(msg: MeshtasticMessage) -> None:
|
||||
pass
|
||||
|
||||
|
||||
@meshtastic_bp.route('/ports')
|
||||
def list_ports():
|
||||
"""
|
||||
List available serial ports that may have Meshtastic devices.
|
||||
|
||||
Returns:
|
||||
JSON with list of available serial ports.
|
||||
"""
|
||||
if not is_meshtastic_available():
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'ports': [],
|
||||
'message': 'Meshtastic SDK not installed'
|
||||
})
|
||||
|
||||
try:
|
||||
from meshtastic.util import findPorts
|
||||
ports = findPorts()
|
||||
return jsonify({
|
||||
'status': 'ok',
|
||||
'ports': ports,
|
||||
'count': len(ports)
|
||||
})
|
||||
except Exception as e:
|
||||
logger.error(f"Error listing ports: {e}")
|
||||
return jsonify({
|
||||
'status': 'error',
|
||||
'ports': [],
|
||||
'message': str(e)
|
||||
})
|
||||
|
||||
|
||||
@meshtastic_bp.route('/status')
|
||||
def get_status():
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user