Skip to content

Add generic pyMC modem telemetry support and preserve modem GPS satellite details#294

Open
yellowcooln wants to merge 11 commits into
pyMC-dev:devfrom
yellowcooln:fix/repeater-pymc-modem-stats
Open

Add generic pyMC modem telemetry support and preserve modem GPS satellite details#294
yellowcooln wants to merge 11 commits into
pyMC-dev:devfrom
yellowcooln:fix/repeater-pymc-modem-stats

Conversation

@yellowcooln

Copy link
Copy Markdown
Collaborator

PR Summary

Overview

This PR adds first-class support for consuming diagnostics from a networked pyMC modem HTTP API, including GPS, battery, and solar telemetry.

It also fixes GPS diagnostics for modem-backed GPS sources by preserving detailed satellites.in_view[] records so the UI can correctly plot satellite azimuth, elevation, and SNR data.

The implementation is intentionally modem-generic. New sensor and source names use pymc_modem and modem_http rather than board-specific naming, allowing support for current and future pyMC modem hardware exposing the same /api/stats API.

Changes

Modem HTTP GPS Source

Adds a new GPS source type:

gps:
  source: modem_http

Supported aliases:

  • modem_http
  • pymc_modem
  • http

Features:

  • Polls GPS data directly from a pyMC modem HTTP API.
  • Supports HTTP Basic Authentication.
  • Accepts either a full /api/stats payload or a nested GPS payload.
  • Normalizes modem GPS data into the existing repeater GPS diagnostics format.
  • Reports modem HTTP failures as GPS source errors without crashing the GPS service.

GPS Satellite Detail Preservation

Preserves detailed modem satellite visibility records:

satellites.in_view[]

Normalizes:

  • prn
  • elevation_degrees
  • azimuth_degrees
  • snr_db

Also supports alternate field names:

  • elevation
  • azimuth
  • snr

This fixes an issue where modem-backed GPS sources could report a valid fix and satellite counts while the diagnostics UI displayed zero plottable satellites due to missing azimuth/elevation/SNR data.

New pymc_modem Sensor

Adds a new sensor type:

type: pymc_modem

The sensor reads modem telemetry from the HTTP /api/stats endpoint and exposes:

  • GPS enabled state
  • GPS fix status
  • Latitude / longitude / altitude
  • Satellites used and in view
  • Date/time
  • Speed and course
  • Battery voltage
  • Solar charging telemetry

The sensor tolerates missing GPS coordinates and optional telemetry fields, allowing use on non-GPS or GPS-disabled modem deployments.

CRC Counter Handling

Improves CRC statistics handling for pyMC modem transports:

  • pymc_usb
  • pymc_tcp

The repeater now treats modem CRC counts as device-owned cumulative counters and baselines the first observed value rather than recording it as a startup CRC spike.

Existing CRC behavior remains unchanged for:

  • sx1262
  • sx1262_ch341
  • kiss

Configuration Updates

Updated config.yaml.example to document:

  • gps.source: modem_http
  • Modem HTTP GPS configuration
  • Generic pymc_modem sensor configuration examples

Files Changed

  • config.yaml.example
  • repeater/config.py
  • repeater/data_acquisition/gps_service.py
  • repeater/engine.py
  • repeater/sensors/pymc_modem.py
  • tests/test_engine.py
  • tests/test_gps_service.py
  • tests/test_sensors.py

Validation

Targeted test suite:

.venv/bin/python -m pytest \
  tests/test_gps_service.py \
  tests/test_sensors.py \
  tests/test_engine.py -q

Result:

359 passed in 2.35s

Additional coverage added for:

  • Modem HTTP GPS ingestion
  • Satellite detail preservation
  • Satellite SNR summary generation
  • pymc_modem sensor operation
  • Missing-coordinate modem payloads
  • CRC counter baselining
  • Existing non-pyMC CRC behavior

Operational Verification

Verified on a live repeater deployment:

  • Service restarted successfully.
  • Modem HTTP GPS ingestion functioning.
  • GPS fix status preserved.
  • Satellite visibility records stored correctly.
  • Azimuth, elevation, and SNR values available for UI plotting.
  • Satellite SNR summary generated correctly.

Observed live modem data:

State: valid_fix
Fix: true
Satellites used: 19
Satellites in view: 7
Plottable satellites: 7
SNR summary: present

Backwards Compatibility

  • Existing serial GPS sources remain supported.
  • Existing file GPS sources remain supported.
  • Existing non-pyMC radio CRC behavior is unchanged.
  • The pymc_modem sensor is additive.
  • The modem_http GPS source is opt-in via configuration.
  • Payload normalization tolerates missing GPS and telemetry fields.

Why This Matters

Before this change, pyMC modem deployments could expose a valid GPS fix and satellite counts while losing detailed GSV-style satellite visibility data during ingestion. As a result, the GPS diagnostics UI could show zero plotted satellites despite the modem having complete azimuth, elevation, and SNR information.

This PR preserves and normalizes those satellite records end-to-end, allowing the repeater UI to display the same GPS diagnostic detail available on the modem itself.

@yellowcooln yellowcooln added enhancement New feature or request pyMC_Modem related to pymc modem Sensors related to sensors for Repeater labels Jun 14, 2026
@yellowcooln yellowcooln marked this pull request as ready for review June 15, 2026 00:09
@yellowcooln yellowcooln requested a review from rightup June 15, 2026 00:10
@yellowcooln

yellowcooln commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator Author

pyMC_Modem now has this in the firmware.

image image

@yellowcooln yellowcooln marked this pull request as draft June 16, 2026 00:02
@yellowcooln yellowcooln marked this pull request as ready for review June 16, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request pyMC_Modem related to pymc modem Sensors related to sensors for Repeater

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant