2020-05-01 00:43:29 +00:00
|
|
|
#include "RF95Interface.h"
|
|
|
|
#include "MeshRadio.h" // kinda yucky, but we need to know which region we are in
|
2020-05-01 04:11:03 +00:00
|
|
|
#include "RadioLibRF95.h"
|
2023-01-21 13:34:29 +00:00
|
|
|
#include "configuration.h"
|
2020-12-27 05:09:20 +00:00
|
|
|
#include "error.h"
|
2020-05-01 00:43:29 +00:00
|
|
|
|
2024-01-12 08:00:31 +00:00
|
|
|
#if ARCH_PORTDUINO
|
|
|
|
#include "PortduinoGlue.h"
|
|
|
|
#endif
|
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
#ifndef RF95_MAX_POWER
|
|
|
|
#define RF95_MAX_POWER 20
|
|
|
|
#endif
|
|
|
|
|
2020-05-03 02:52:37 +00:00
|
|
|
// if we use 20 we are limited to 1% duty cycle or hw might overheat. For continuous operation set a limit of 17
|
2020-10-08 01:57:59 +00:00
|
|
|
// In theory up to 27 dBm is possible, but the modules installed in most radios can cope with a max of 20. So BIG WARNING
|
|
|
|
// if you set power to something higher than 17 or 20 you might fry your board.
|
2020-05-03 02:52:37 +00:00
|
|
|
|
2020-09-16 00:55:33 +00:00
|
|
|
#define POWER_DEFAULT 17 // How much power to use if the user hasn't set a power level
|
2024-06-09 21:03:39 +00:00
|
|
|
#ifdef RADIOMASTER_900_BANDIT_NANO
|
|
|
|
// Structure to hold DAC and DB values
|
|
|
|
typedef struct {
|
|
|
|
uint8_t dac;
|
|
|
|
uint8_t db;
|
|
|
|
} DACDB;
|
|
|
|
|
|
|
|
// Interpolation function
|
2024-07-03 23:02:20 +00:00
|
|
|
DACDB interpolate(uint8_t dbm, uint8_t dbm1, uint8_t dbm2, DACDB val1, DACDB val2)
|
|
|
|
{
|
2024-06-09 21:03:39 +00:00
|
|
|
DACDB result;
|
|
|
|
double fraction = (double)(dbm - dbm1) / (dbm2 - dbm1);
|
|
|
|
result.dac = (uint8_t)(val1.dac + fraction * (val2.dac - val1.dac));
|
|
|
|
result.db = (uint8_t)(val1.db + fraction * (val2.db - val1.db));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function to find the correct DAC and DB values based on dBm using interpolation
|
2024-07-03 23:02:20 +00:00
|
|
|
DACDB getDACandDB(uint8_t dbm)
|
|
|
|
{
|
2024-06-09 21:03:39 +00:00
|
|
|
// Predefined values
|
|
|
|
static const struct {
|
|
|
|
uint8_t dbm;
|
|
|
|
DACDB values;
|
|
|
|
} dbmToDACDB[] = {
|
2024-07-03 23:02:20 +00:00
|
|
|
{20, {168, 2}}, // 100mW
|
|
|
|
{24, {148, 6}}, // 250mW
|
|
|
|
{27, {128, 9}}, // 500mW
|
|
|
|
{30, {90, 12}} // 1000mW
|
2024-06-09 21:03:39 +00:00
|
|
|
};
|
|
|
|
const int numValues = sizeof(dbmToDACDB) / sizeof(dbmToDACDB[0]);
|
|
|
|
|
|
|
|
// Find the interval dbm falls within and interpolate
|
|
|
|
for (int i = 0; i < numValues - 1; i++) {
|
|
|
|
if (dbm >= dbmToDACDB[i].dbm && dbm <= dbmToDACDB[i + 1].dbm) {
|
|
|
|
return interpolate(dbm, dbmToDACDB[i].dbm, dbmToDACDB[i + 1].dbm, dbmToDACDB[i].values, dbmToDACDB[i + 1].values);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Return a default value if no match is found and default to 100mW
|
|
|
|
DACDB defaultValue = {168, 2};
|
|
|
|
return defaultValue;
|
|
|
|
}
|
|
|
|
#endif
|
2020-09-16 00:55:33 +00:00
|
|
|
|
2023-05-08 11:18:28 +00:00
|
|
|
RF95Interface::RF95Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst,
|
|
|
|
RADIOLIB_PIN_TYPE busy)
|
|
|
|
: RadioLibInterface(hal, cs, irq, rst, busy)
|
2020-05-01 00:43:29 +00:00
|
|
|
{
|
2024-03-22 01:45:48 +00:00
|
|
|
LOG_DEBUG("RF95Interface(cs=%d, irq=%d, rst=%d, busy=%d)\n", cs, irq, rst, busy);
|
2020-05-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 20:18:32 +00:00
|
|
|
/** Some boards require GPIO control of tx vs rx paths */
|
|
|
|
void RF95Interface::setTransmitEnable(bool txon)
|
|
|
|
{
|
|
|
|
#ifdef RF95_TXEN
|
|
|
|
digitalWrite(RF95_TXEN, txon ? 1 : 0);
|
2024-01-12 08:00:31 +00:00
|
|
|
#elif ARCH_PORTDUINO
|
|
|
|
if (settingsMap[txen] != RADIOLIB_NC) {
|
|
|
|
digitalWrite(settingsMap[txen], txon ? 1 : 0);
|
|
|
|
}
|
2020-07-13 20:18:32 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef RF95_RXEN
|
|
|
|
digitalWrite(RF95_RXEN, txon ? 0 : 1);
|
2024-01-12 08:00:31 +00:00
|
|
|
#elif ARCH_PORTDUINO
|
|
|
|
if (settingsMap[rxen] != RADIOLIB_NC) {
|
|
|
|
digitalWrite(settingsMap[rxen], txon ? 0 : 1);
|
|
|
|
}
|
2020-07-13 20:18:32 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
/// Initialise the Driver transport hardware and software.
|
|
|
|
/// Make sure the Driver is properly configured before calling init().
|
|
|
|
/// \return true if initialisation succeeded.
|
|
|
|
bool RF95Interface::init()
|
|
|
|
{
|
2020-05-01 19:11:04 +00:00
|
|
|
RadioLibInterface::init();
|
2020-05-03 02:52:37 +00:00
|
|
|
|
2024-06-09 21:03:39 +00:00
|
|
|
#ifdef RADIOMASTER_900_BANDIT_NANO
|
|
|
|
// DAC and DB values based on dBm using interpolation
|
|
|
|
DACDB dacDbValues = getDACandDB(power);
|
|
|
|
int8_t powerDAC = dacDbValues.dac;
|
|
|
|
power = dacDbValues.db;
|
|
|
|
#endif
|
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
if (power > RF95_MAX_POWER) // This chip has lower power limits than some
|
|
|
|
power = RF95_MAX_POWER;
|
2024-07-03 23:02:20 +00:00
|
|
|
|
2020-09-16 01:54:50 +00:00
|
|
|
limitPower();
|
SX1262: fix serious bug with detecting if we have a rx packet in progress
Could cause hangs on the way into sleep (and enormous power consumption).
Instead of checking for rx packet length (which only changes at completion)
check if we've received preamble bits but haven't yet received a completed
packet interrupt.
notes:
wait to sleep loop problem
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
Can not send yet, busyRx
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
vs normal run
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
Starting low level send (id=0x53fe1dd0 Fr0xe5 To0xff, WantAck0, HopLim3 encrypted)
Completed sending (id=0x53fe1dd0 Fr0xe5 To0xff, WantAck0, HopLim3 encrypted)
2020-10-07 05:43:51 +00:00
|
|
|
|
2020-05-01 04:29:51 +00:00
|
|
|
iface = lora = new RadioLibRF95(&module);
|
2020-07-10 21:37:01 +00:00
|
|
|
|
|
|
|
#ifdef RF95_TCXO
|
|
|
|
pinMode(RF95_TCXO, OUTPUT);
|
|
|
|
digitalWrite(RF95_TCXO, 1);
|
|
|
|
#endif
|
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
// enable PA
|
|
|
|
#ifdef RF95_PA_EN
|
|
|
|
#if defined(RF95_PA_DAC_EN)
|
2024-07-03 23:02:20 +00:00
|
|
|
#ifdef RADIOMASTER_900_BANDIT_NANO
|
|
|
|
// Use calculated DAC value
|
|
|
|
dacWrite(RF95_PA_EN, powerDAC);
|
|
|
|
#else
|
|
|
|
// Use Value set in /*/variant.h
|
|
|
|
dacWrite(RF95_PA_EN, RF95_PA_LEVEL);
|
|
|
|
#endif
|
2024-05-31 15:56:04 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2020-07-13 20:18:32 +00:00
|
|
|
/*
|
|
|
|
#define RF95_TXEN (22) // If defined, this pin should be set high prior to transmit (controls an external analog switch)
|
|
|
|
#define RF95_RXEN (23) // If defined, this pin should be set high prior to receive (controls an external analog switch)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef RF95_TXEN
|
|
|
|
pinMode(RF95_TXEN, OUTPUT);
|
|
|
|
digitalWrite(RF95_TXEN, 0);
|
|
|
|
#endif
|
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
#ifdef RF95_FAN_EN
|
|
|
|
pinMode(RF95_FAN_EN, OUTPUT);
|
|
|
|
digitalWrite(RF95_FAN_EN, 1);
|
|
|
|
#endif
|
|
|
|
|
2020-07-13 20:18:32 +00:00
|
|
|
#ifdef RF95_RXEN
|
|
|
|
pinMode(RF95_RXEN, OUTPUT);
|
|
|
|
digitalWrite(RF95_RXEN, 1);
|
2024-01-12 08:00:31 +00:00
|
|
|
#endif
|
|
|
|
#if ARCH_PORTDUINO
|
|
|
|
if (settingsMap[txen] != RADIOLIB_NC) {
|
|
|
|
pinMode(settingsMap[txen], OUTPUT);
|
|
|
|
digitalWrite(settingsMap[txen], 0);
|
|
|
|
}
|
|
|
|
if (settingsMap[rxen] != RADIOLIB_NC) {
|
|
|
|
pinMode(settingsMap[rxen], OUTPUT);
|
|
|
|
digitalWrite(settingsMap[rxen], 0);
|
|
|
|
}
|
2020-07-13 20:18:32 +00:00
|
|
|
#endif
|
|
|
|
setTransmitEnable(false);
|
|
|
|
|
2023-02-16 19:58:10 +00:00
|
|
|
int res = lora->begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength);
|
2022-12-30 16:27:07 +00:00
|
|
|
LOG_INFO("RF95 init result %d\n", res);
|
2023-01-21 13:34:29 +00:00
|
|
|
LOG_INFO("Frequency set to %f\n", getFreq());
|
|
|
|
LOG_INFO("Bandwidth set to %f\n", bw);
|
|
|
|
LOG_INFO("Power output set to %d\n", power);
|
2024-06-09 21:03:39 +00:00
|
|
|
#ifdef RADIOMASTER_900_BANDIT_NANO
|
|
|
|
LOG_INFO("DAC output set to %d\n", powerDAC);
|
|
|
|
#endif
|
2022-06-22 04:51:45 +00:00
|
|
|
|
2022-05-30 00:30:20 +00:00
|
|
|
if (res == RADIOLIB_ERR_NONE)
|
|
|
|
res = lora->setCRC(RADIOLIB_SX126X_LORA_CRC_ON);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
2022-05-30 00:30:20 +00:00
|
|
|
if (res == RADIOLIB_ERR_NONE)
|
2020-05-01 00:43:29 +00:00
|
|
|
startReceive(); // start receiving
|
|
|
|
|
2022-05-30 00:30:20 +00:00
|
|
|
return res == RADIOLIB_ERR_NONE;
|
2020-05-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 00:56:30 +00:00
|
|
|
void INTERRUPT_ATTR RF95Interface::disableInterrupt()
|
|
|
|
{
|
|
|
|
lora->clearDio0Action();
|
|
|
|
}
|
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
bool RF95Interface::reconfigure()
|
|
|
|
{
|
2021-03-30 15:34:13 +00:00
|
|
|
RadioLibInterface::reconfigure();
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
// set mode to standby
|
|
|
|
setStandby();
|
|
|
|
|
|
|
|
// configure publicly accessible settings
|
|
|
|
int err = lora->setSpreadingFactor(sf);
|
2022-05-30 00:30:20 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
2023-01-21 17:22:19 +00:00
|
|
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
err = lora->setBandwidth(bw);
|
2022-05-30 00:30:20 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
2023-01-21 17:22:19 +00:00
|
|
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
err = lora->setCodingRate(cr);
|
2022-05-30 00:30:20 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
2023-01-21 17:22:19 +00:00
|
|
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
err = lora->setSyncWord(syncWord);
|
2024-04-14 05:29:42 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
|
|
|
LOG_ERROR("Radiolib error %d when attempting RF95 setSyncWord!\n", err);
|
2022-05-30 00:30:20 +00:00
|
|
|
assert(err == RADIOLIB_ERR_NONE);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
err = lora->setCurrentLimit(currentLimit);
|
2024-04-14 05:29:42 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
|
|
|
LOG_ERROR("Radiolib error %d when attempting RF95 setCurrentLimit!\n", err);
|
2022-05-30 00:30:20 +00:00
|
|
|
assert(err == RADIOLIB_ERR_NONE);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
err = lora->setPreambleLength(preambleLength);
|
2024-04-14 05:29:42 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
|
|
|
LOG_ERROR("Radiolib error %d when attempting RF95 setPreambleLength!\n", err);
|
2022-05-30 00:30:20 +00:00
|
|
|
assert(err == RADIOLIB_ERR_NONE);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
2021-09-13 19:13:51 +00:00
|
|
|
err = lora->setFrequency(getFreq());
|
2022-05-30 00:30:20 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
2023-01-21 17:22:19 +00:00
|
|
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
if (power > RF95_MAX_POWER) // This chip has lower power limits than some
|
|
|
|
power = RF95_MAX_POWER;
|
2023-01-21 13:34:29 +00:00
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
#ifdef USE_RF95_RFO
|
|
|
|
err = lora->setOutputPower(power, true);
|
|
|
|
#else
|
2020-05-01 00:43:29 +00:00
|
|
|
err = lora->setOutputPower(power);
|
2024-05-31 15:56:04 +00:00
|
|
|
#endif
|
2022-05-30 00:30:20 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
2023-01-21 17:22:19 +00:00
|
|
|
RECORD_CRITICALERROR(meshtastic_CriticalErrorCode_INVALID_RADIO_SETTING);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
startReceive(); // restart receiving
|
|
|
|
|
2022-05-30 00:30:20 +00:00
|
|
|
return RADIOLIB_ERR_NONE;
|
2020-05-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 02:58:10 +00:00
|
|
|
/**
|
|
|
|
* Add SNR data to received messages
|
|
|
|
*/
|
2023-01-21 17:22:19 +00:00
|
|
|
void RF95Interface::addReceiveMetadata(meshtastic_MeshPacket *mp)
|
2020-05-01 02:58:10 +00:00
|
|
|
{
|
|
|
|
mp->rx_snr = lora->getSNR();
|
2022-03-01 01:07:31 +00:00
|
|
|
mp->rx_rssi = lround(lora->getRSSI());
|
2020-05-01 02:58:10 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
void RF95Interface::setStandby()
|
|
|
|
{
|
|
|
|
int err = lora->standby();
|
2024-04-14 05:29:42 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
|
|
|
LOG_ERROR("Radiolib error %d when attempting RF95 standby!\n", err);
|
2022-05-30 00:30:20 +00:00
|
|
|
assert(err == RADIOLIB_ERR_NONE);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
isReceiving = false; // If we were receiving, not any more
|
|
|
|
disableInterrupt();
|
2020-05-01 05:53:21 +00:00
|
|
|
completeSending(); // If we were sending, not anymore
|
2024-07-03 23:02:20 +00:00
|
|
|
RadioLibInterface::setStandby();
|
2020-05-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
2020-07-13 20:18:32 +00:00
|
|
|
/** We override to turn on transmitter power as needed.
|
|
|
|
*/
|
|
|
|
void RF95Interface::configHardwareForSend()
|
|
|
|
{
|
|
|
|
setTransmitEnable(true);
|
|
|
|
|
|
|
|
RadioLibInterface::configHardwareForSend();
|
|
|
|
}
|
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
void RF95Interface::startReceive()
|
|
|
|
{
|
2020-07-13 20:18:32 +00:00
|
|
|
setTransmitEnable(false);
|
2020-05-01 00:43:29 +00:00
|
|
|
setStandby();
|
|
|
|
int err = lora->startReceive();
|
2024-04-14 05:29:42 +00:00
|
|
|
if (err != RADIOLIB_ERR_NONE)
|
|
|
|
LOG_ERROR("Radiolib error %d when attempting RF95 startReceive!\n", err);
|
2022-05-30 00:30:20 +00:00
|
|
|
assert(err == RADIOLIB_ERR_NONE);
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
isReceiving = true;
|
|
|
|
|
SX1262: fix serious bug with detecting if we have a rx packet in progress
Could cause hangs on the way into sleep (and enormous power consumption).
Instead of checking for rx packet length (which only changes at completion)
check if we've received preamble bits but haven't yet received a completed
packet interrupt.
notes:
wait to sleep loop problem
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
Can not send yet, busyRx
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
vs normal run
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
radio wait to sleep, txEmpty=0
Starting low level send (id=0x53fe1dd0 Fr0xe5 To0xff, WantAck0, HopLim3 encrypted)
Completed sending (id=0x53fe1dd0 Fr0xe5 To0xff, WantAck0, HopLim3 encrypted)
2020-10-07 05:43:51 +00:00
|
|
|
// Must be done AFTER, starting receive, because startReceive clears (possibly stale) interrupt pending register bits
|
2020-05-01 00:43:29 +00:00
|
|
|
enableInterrupt(isrRxLevel0);
|
|
|
|
}
|
|
|
|
|
2022-04-20 18:04:44 +00:00
|
|
|
bool RF95Interface::isChannelActive()
|
|
|
|
{
|
|
|
|
// check if we can detect a LoRa preamble on the current channel
|
|
|
|
int16_t result;
|
|
|
|
setTransmitEnable(false);
|
2023-01-21 13:34:29 +00:00
|
|
|
setStandby(); // needed for smooth transition
|
2022-04-20 18:04:44 +00:00
|
|
|
result = lora->scanChannel();
|
2023-01-21 13:34:29 +00:00
|
|
|
|
2022-05-30 00:30:20 +00:00
|
|
|
if (result == RADIOLIB_PREAMBLE_DETECTED) {
|
2022-12-30 02:41:37 +00:00
|
|
|
// LOG_DEBUG("Channel is busy!\n");
|
2022-04-20 18:04:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
2024-04-16 22:47:56 +00:00
|
|
|
if (result != RADIOLIB_CHANNEL_FREE)
|
2024-04-14 05:29:42 +00:00
|
|
|
LOG_ERROR("Radiolib error %d when attempting RF95 isChannelActive!\n", result);
|
2022-05-30 00:30:20 +00:00
|
|
|
assert(result != RADIOLIB_ERR_WRONG_MODEM);
|
2023-01-21 13:34:29 +00:00
|
|
|
|
2022-12-30 02:41:37 +00:00
|
|
|
// LOG_DEBUG("Channel is free!\n");
|
2022-04-20 18:04:44 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2023-07-14 21:25:20 +00:00
|
|
|
/** Could we send right now (i.e. either not actively receiving or transmitting)? */
|
2020-05-01 15:32:16 +00:00
|
|
|
bool RF95Interface::isActivelyReceiving()
|
2020-05-01 00:43:29 +00:00
|
|
|
{
|
2020-05-01 15:32:16 +00:00
|
|
|
return lora->isReceiving();
|
2020-05-01 00:43:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool RF95Interface::sleep()
|
|
|
|
{
|
|
|
|
// put chipset into sleep mode
|
2023-07-14 21:25:20 +00:00
|
|
|
setStandby(); // First cancel any active receiving/sending
|
2020-05-01 00:43:29 +00:00
|
|
|
lora->sleep();
|
|
|
|
|
2024-05-31 15:56:04 +00:00
|
|
|
#ifdef RF95_FAN_EN
|
|
|
|
digitalWrite(RF95_FAN_EN, 0);
|
|
|
|
#endif
|
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
return true;
|
2024-06-09 21:03:39 +00:00
|
|
|
}
|