* add noise floor * Sliding window noise floor * Add getCurrentRSSI() to SimRadio for noise floor support * Remove sendLocalStatsToPhone call from runOnce * Change noise floor to int32_t type * Use int32_t for RSSI sample storage in noise floor * Remove float cast from noise floor assignment * Fix Copilot review issues: fix noise floor logic, types, and null pointer - Use robust busyTx/busyRx checks instead of simple isReceiving check - Initialize noiseFloorSamples to NOISE_FLOOR_MIN instead of 0 - Move noise_floor assignment inside null check to prevent potential crash - Change getNoiseFloor() and getAverageNoiseFloor() to return int32_t - Fix RSSI validation to check for positive values (rssi > 0) - Fix format specifier from %.1f to %d for int32_t - Update comments to accurately reflect the sampling logic * Fix RSSI condition to include zero value * Change noise floor initialization to zero * Disable noise floor for LR11x0 chips: getRSSI(bool) unsupported * Remove updateNoiseFloor call from onNotify to avoid radio queue overflow Per PR review feedback, calling updateNoiseFloor() in onNotify() for every ISR event (ISR_TX, ISR_RX, TRANSMIT_DELAY_COMPLETED) can cause the LoRa radio queue to get full. The noise floor sampling still happens in startReceive() and after transmitting. * fix lr11x0 current rssi * Address noise floor review comments * Address Copilot SimRadio noise floor comments * Fix RadioLibInterface formatting --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com> Co-authored-by: Jonathan Bennett <jbennett@incomsystems.biz>
77 lines
2.5 KiB
C++
77 lines
2.5 KiB
C++
#pragma once
|
|
#if RADIOLIB_EXCLUDE_SX127X != 1
|
|
#include "MeshRadio.h" // kinda yucky, but we need to know which region we are in
|
|
#include "RadioLibInterface.h"
|
|
#include "RadioLibRF95.h"
|
|
|
|
/**
|
|
* Our new not radiohead adapter for RF95 style radios
|
|
*/
|
|
class RF95Interface : public RadioLibInterface
|
|
{
|
|
RadioLibRF95 *lora = NULL; // Either a RFM95 or RFM96 depending on what was stuffed on this board
|
|
|
|
public:
|
|
RF95Interface(LockingArduinoHal *hal, RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst,
|
|
RADIOLIB_PIN_TYPE busy);
|
|
|
|
// TODO: Verify that this irq flag works with RFM95 / SX1276 radios the way it used to
|
|
bool isIRQPending() override { return lora->getIRQFlags() & RADIOLIB_SX127X_MASK_IRQ_FLAG_VALID_HEADER; }
|
|
|
|
/// Initialise the Driver transport hardware and software.
|
|
/// Make sure the Driver is properly configured before calling init().
|
|
/// \return true if initialisation succeeded.
|
|
virtual bool init() override;
|
|
|
|
/// Apply any radio provisioning changes
|
|
/// Make sure the Driver is properly configured before calling init().
|
|
/// \return true if initialisation succeeded.
|
|
virtual bool reconfigure() override;
|
|
|
|
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
|
virtual bool sleep() override;
|
|
|
|
protected:
|
|
/**
|
|
* Glue functions called from ISR land
|
|
*/
|
|
virtual void disableInterrupt() override;
|
|
|
|
int16_t getCurrentRSSI() override;
|
|
|
|
/**
|
|
* Enable a particular ISR callback glue function
|
|
*/
|
|
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback, RISING); }
|
|
|
|
/** can we detect a LoRa preamble on the current channel? */
|
|
virtual bool isChannelActive() override;
|
|
|
|
/** are we actively receiving a packet (only called during receiving state) */
|
|
virtual bool isActivelyReceiving() override;
|
|
|
|
/**
|
|
* Start waiting to receive a message
|
|
*/
|
|
virtual void startReceive() override;
|
|
|
|
/**
|
|
* Add SNR data to received messages
|
|
*/
|
|
virtual void addReceiveMetadata(meshtastic_MeshPacket *mp) override;
|
|
|
|
virtual void setStandby() override;
|
|
|
|
/**
|
|
* We override to turn on transmitter power as needed.
|
|
*/
|
|
virtual void configHardwareForSend() override;
|
|
|
|
uint32_t getPacketTime(uint32_t pl, bool received) override { return computePacketTime(*lora, pl, received); }
|
|
|
|
private:
|
|
/** Some boards require GPIO control of tx vs rx paths */
|
|
void setTransmitEnable(bool txon);
|
|
};
|
|
#endif
|