Passthrough version
This commit is contained in:
@@ -0,0 +1,76 @@
|
|||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// Copyright (c) 2012-2024 Scott Penrose <scottp@dd.com.au> and WII5 Buoy contributors
|
||||||
|
//
|
||||||
|
// This file is part of WII5 Buoy firmware.
|
||||||
|
// See LICENSE for full terms.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file wii5_passthrough.ino
|
||||||
|
* @brief Minimal firmware: keeps the Maths CPU powered on and provides
|
||||||
|
* bidirectional raw serial passthrough to the Iridium modem.
|
||||||
|
*
|
||||||
|
* The AVR becomes a transparent bridge between the USB console and the
|
||||||
|
* Iridium 9602/9603 modem (Serial3 @ 19200 baud). AT commands typed on
|
||||||
|
* the console go directly to the modem; modem responses are echoed back.
|
||||||
|
*
|
||||||
|
* Maths CPU (Raspberry Pi) is kept alive indefinitely via the hold timer
|
||||||
|
* and the MATHS_RETURNLINE hardware signal.
|
||||||
|
*
|
||||||
|
* Build (PlatformIO):
|
||||||
|
* pio run -e wii5_passthrough
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include <WII5.h>
|
||||||
|
|
||||||
|
elapsedMillis wdtWait;
|
||||||
|
elapsedMillis holdCheckWait;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
wii5Setup.beginSafe();
|
||||||
|
wii5Setup.setupConsole();
|
||||||
|
|
||||||
|
// Maths CPU — start and hold on indefinitely
|
||||||
|
wii5Maths.begin();
|
||||||
|
wii5Maths.start(WII5MATHSMODE_COMMS);
|
||||||
|
wii5Maths.setHold(MATHS_MAXHOLD);
|
||||||
|
wii5Maths.setReturnLine();
|
||||||
|
|
||||||
|
// Iridium modem — initialise, then power on with passthrough
|
||||||
|
wii5Iridium.begin();
|
||||||
|
wii5Iridium.setPassthrough(true);
|
||||||
|
wii5Iridium.powerOn(true);
|
||||||
|
|
||||||
|
wdtWait = 0;
|
||||||
|
holdCheckWait = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// ---- external watchdog ----
|
||||||
|
#ifdef WDT_RESET
|
||||||
|
if (wdtWait > 5100) {
|
||||||
|
digitalWrite(WDT_RESET, LOW);
|
||||||
|
wdtWait = 0;
|
||||||
|
} else if (wdtWait > 5000) {
|
||||||
|
digitalWrite(WDT_RESET, HIGH);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ---- Maths CPU keep-alive ----
|
||||||
|
wii5Maths.loop();
|
||||||
|
if (holdCheckWait > 30000) {
|
||||||
|
holdCheckWait = 0;
|
||||||
|
if (wii5Maths.remainingHold() < 600) {
|
||||||
|
wii5Maths.setHold(MATHS_MAXHOLD);
|
||||||
|
}
|
||||||
|
wii5Maths.setReturnLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- Modem → Console (passthrough echo) ----
|
||||||
|
wii5Iridium.WII5SerialManager::loop();
|
||||||
|
|
||||||
|
// ---- Console → Modem (raw forwarding) ----
|
||||||
|
while (SerialConsole.available()) {
|
||||||
|
SerialComms.write(SerialConsole.read());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
// Copyright (c) 2012-2024 Scott Penrose <scottp@dd.com.au> and WII5 Buoy contributors
|
||||||
|
//
|
||||||
|
// This file is part of WII5 Buoy firmware.
|
||||||
|
// See LICENSE for full terms.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file pio_main_passthrough.cpp
|
||||||
|
* @brief PlatformIO entry shim for the wii5_passthrough sketch.
|
||||||
|
*
|
||||||
|
* PlatformIO only auto-detects a sketch at the top level of its source
|
||||||
|
* directory. This shim pulls wii5_passthrough.ino into the PlatformIO
|
||||||
|
* build (where setup() / loop() are defined).
|
||||||
|
*
|
||||||
|
* It is gated on PLATFORMIO so that the arduino-cli build never sees a
|
||||||
|
* second definition of setup() / loop().
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(PLATFORMIO)
|
||||||
|
#include "app/wii5_passthrough/wii5_passthrough.ino"
|
||||||
|
#endif
|
||||||
@@ -36,6 +36,7 @@ monitor_speed = 230400
|
|||||||
; The entry sketch (app/wii5_buoy/wii5_buoy.ino) is pulled in by pio_main.cpp.
|
; The entry sketch (app/wii5_buoy/wii5_buoy.ino) is pulled in by pio_main.cpp.
|
||||||
build_src_filter =
|
build_src_filter =
|
||||||
+<*.cpp>
|
+<*.cpp>
|
||||||
|
-<pio_main_passthrough.cpp>
|
||||||
|
|
||||||
; The project's own headers are included with angle brackets (<WII5.h>, ...),
|
; The project's own headers are included with angle brackets (<WII5.h>, ...),
|
||||||
; so the repo root must be on the include path. Software version/commit are
|
; so the repo root must be on the include path. Software version/commit are
|
||||||
@@ -65,6 +66,16 @@ lib_deps =
|
|||||||
arduino-libraries/SD
|
arduino-libraries/SD
|
||||||
adafruit/RTClib
|
adafruit/RTClib
|
||||||
|
|
||||||
|
; Lean pass-through variant: keeps the Maths CPU powered on and provides
|
||||||
|
; bidirectional raw serial passthrough to the Iridium modem from the USB
|
||||||
|
; console. Excludes the full wii5_buoy main (pio_main.cpp) so setup()/loop()
|
||||||
|
; come from pio_main_passthrough.cpp instead.
|
||||||
|
[env:wii5_passthrough]
|
||||||
|
extends = env:wii5_buoy
|
||||||
|
build_src_filter =
|
||||||
|
+<*.cpp>
|
||||||
|
-<pio_main.cpp>
|
||||||
|
|
||||||
; LoRa-enabled variant (experimental). This path additionally depends on the
|
; LoRa-enabled variant (experimental). This path additionally depends on the
|
||||||
; Sh3dNode networking stack (sh3dNodeNetwork / SH3D_NODE_Packet_* / RH_RF95),
|
; Sh3dNode networking stack (sh3dNodeNetwork / SH3D_NODE_Packet_* / RH_RF95),
|
||||||
; which is NOT bundled in this repository, so the env does not build as-is.
|
; which is NOT bundled in this repository, so the env does not build as-is.
|
||||||
|
|||||||
Reference in New Issue
Block a user