// SPDX-License-Identifier: Apache-2.0 // Copyright (c) 2012-2024 Scott Penrose and WII5 Buoy contributors // // This file is part of WII5 Buoy firmware. // See LICENSE for full terms. /** * @file WII5RadioLoRa.cpp * @brief LoRa radio driver (RFM95) — optional, gated on WII5_RADIO_LORA. */ /* WII5RadioLoRa */ #include #include #ifdef WII5_RADIO_LORA #include void WII5RadioLoRa::begin() { powerSetPin(POWER_RADIO_PIN, POWER_RADIO_ON); powerOn(true); running = true; // sh3dNodeRadio.begin(wii5BufferRadio, WII5_BUFFER_RADIO, &wii5RadioRF95); // sh3dNodeNetwork.begin(); sh3dNodeBroadcast.begin(); } // start / stop — currently no-ops. Radio power is managed in begin(); modes // don't (yet) toggle the radio on demand. Kept as overrides of the WII5Power // virtuals so callers can still invoke them safely. void WII5RadioLoRa::start(bool force) { (void)force; } void WII5RadioLoRa::stop(bool force) { (void)force; } void WII5RadioLoRa::loop() { sh3dNodeRadio.loop(); if (passthrough && sh3dNodeRadio.lastValid) { console.printf(F("Radio:record - yay. Length = %d. RSSI = %d."), sh3dNodeRadio.lastLength, sh3dNodeRadio.lastRadio.rssi, sh3dNodeRadio.lastRadio.snr ); console.printf("DATA: "); console.printf((char*)sh3dNodeRadio.buffer); console.printf("\r\n"); sh3dNodeRadio.lastClear(); } sh3dNodeNetwork.loop(); if (sh3dNodeNetwork.lastValid) { console.printf(F("Radio:packet: type=%d\r\n"),(int(sh3dNodeNetwork.lastPacketType))); } } // No disable ATM void WII5RadioLoRa::setPassthrough(bool in) { passthrough = in; } bool WII5RadioLoRa::getPassthrough() { return passthrough; } void WII5RadioLoRa::setDebug(bool in) { debug = in; } bool WII5RadioLoRa::getDebug() { return debug; } WII5RadioLoRa wii5RadioLoRa; #endif