Muzi Base SuperIO: GPS mode switch ignored at boot

Aperta Adatta ai principianti
#3,760 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
70/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp
Ambito
embedded-iot

Direzione di ricerca

Inizia da MuziBaseSensorManager::begin() e loop() in variants/muzi_base/target.cpp, poi controlla l'ordine di avvio del companion intorno a applyGpsPrefs() in examples/companion_radio/main.cpp. La modifica proposta lascia _last_gps_sw a -1, così il primo loop() applica la posizione dell'interruttore dopo che le preferenze sono state impostate. Il lavoro è completo quando la pagina GPS mostra gps on dopo un riavvio con l'interruttore in posizione centrale, e hai verificato se variants/thinknode_m1/target.cpp presenta lo stesso problema di ordinamento. Per confermare la correzione serve dell'hardware.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Description

On the Muzi Base (Uno/Duo) with the SuperIO, the companion firmware ignores the 3-position mode switch when the device boots. If the switch is already in the GPS position (Mode 2, middle) at power-on, GPS stays off. It only turns on after the switch is moved away and back.

Meshtastic uses the same switch for GPS on/off: SWITCH_MODE2 (P0.12, middle position) is defined as PIN_GPS_SWITCH[^1]. The SuperIO docs list the GPS module as part of the board[^2].

Cause

MuziBaseSensorManager::begin() reads the switch and calls start_gps()/stop_gps()[^3]. But in the companion, sensors.begin() is followed right away by the_mesh.applyGpsPrefs()[^4], which sets GPS from the saved gps_enabled pref (off by default). That overrides the switch state.

After that, loop() only reacts when the switch changes[^5], so the initial position is never applied again.

Steps to reproduce
  1. Flash muzi_base_uno_superIO_companion_radio_ble (or the Duo equivalent).
  2. Set the mode switch to the middle position (GPS on).
  3. Power cycle the device.
  4. Open the GPS page on the display: it shows gps off(sw) instead of gps on.
  5. Move the switch away and back: GPS turns on.
Proposed fix

Let the first loop() apply the switch position, so it runs after applyGpsPrefs():

--- a/variants/muzi_base/target.cpp
+++ b/variants/muzi_base/target.cpp
@@ bool MuziBaseSensorManager::begin() {
   pinMode(PIN_GPS_SWITCH, INPUT);
-  _last_gps_sw = digitalRead(PIN_GPS_SWITCH);   // initial gps state from the switch
-  if (_last_gps_sw == HIGH) start_gps(); else stop_gps();
+  // leave _last_gps_sw at -1 so the first loop() applies the switch position.
+  // applying it here would be overridden by applyGpsPrefs(), which the
+  // companion runs right after sensors.begin().
+  _last_gps_sw = -1;

The ThinkNode M1 uses the same pattern (variants/thinknode_m1/target.cpp) and may have the same problem.

Environment
  • Board: Muzi Base Uno + SuperIO
  • Firmware: main @ 81dbae5 (v1.18.0), env muzi_base_uno_superIO_companion_radio_ble

[^1]: Meshtastic muzi_base variant, mode switch pins: https://github.com/meshtastic/firmwa6fdd4cd659498d28d8bd153/variants/nrf52840/muzi_base/variant.h#L64-L66
[^2]: Meshtastic docs, muzi ᴡᴏʀᴋꜱ Super IO: https://meshtastic.org/docs/hardware/devices/muziworks/muzi-base/super-io/
[^3]: https://github.com/meshcore-dev/MeshCore/blob/81dbae592ffad40b4212bc0b37e82b38da08f4bct.cpp#L44-L45
[^4]: https://github.com/meshcore-dev/MeshCore/blob/81dbae592ffad40b4212bc0b37e82b38da08f4bc/examples/companion_radio/main.cpp#L278-L281
[^5]: https://github.com/meshcore-dev/MeshCore/blob/81dbae592ffad40b4212bc0b37e82b38da08f4bc/variants/muzi_base/target.cpp#L63-L65

Lingua principale
C
Stelle
3.9k
Fork
1.5k
Merge medio
2g 20h
PR unite (30g)
36

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di meshcore-dev/MeshCore

Tutte le issue di meshcore-dev/MeshCore

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.