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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user