2020-05-01 00:43:29 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "MeshRadio.h" // kinda yucky, but we need to know which region we are in
|
|
|
|
#include "RadioLibInterface.h"
|
2020-05-01 04:29:51 +00:00
|
|
|
#include "RadioLibRF95.h"
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Our new not radiohead adapter for RF95 style radios
|
|
|
|
*/
|
|
|
|
class RF95Interface : public RadioLibInterface
|
|
|
|
{
|
2022-01-24 07:00:14 +00:00
|
|
|
RadioLibRF95 *lora = NULL; // Either a RFM95 or RFM96 depending on what was stuffed on this board
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass &spi);
|
2022-05-30 00:30:20 +00:00
|
|
|
|
|
|
|
//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; }
|
2021-01-02 04:38:18 +00:00
|
|
|
|
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.
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual bool init() override;
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
/// Apply any radio provisioning changes
|
|
|
|
/// Make sure the Driver is properly configured before calling init().
|
|
|
|
/// \return true if initialisation succeeded.
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual bool reconfigure() override;
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual bool sleep() override;
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Glue functions called from ISR land
|
|
|
|
*/
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual void disableInterrupt() override;
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable a particular ISR callback glue function
|
|
|
|
*/
|
|
|
|
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
|
|
|
|
|
2022-04-20 18:04:44 +00:00
|
|
|
/** can we detect a LoRa preamble on the current channel? */
|
|
|
|
virtual bool isChannelActive() override;
|
|
|
|
|
2020-05-01 15:32:16 +00:00
|
|
|
/** are we actively receiving a packet (only called during receiving state) */
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual bool isActivelyReceiving() override;
|
2020-05-03 02:51:25 +00:00
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
/**
|
|
|
|
* Start waiting to receive a message
|
|
|
|
*/
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual void startReceive() override;
|
2020-05-01 00:43:29 +00:00
|
|
|
|
2020-05-01 02:58:10 +00:00
|
|
|
/**
|
|
|
|
* Add SNR data to received messages
|
|
|
|
*/
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual void addReceiveMetadata(MeshPacket *mp) override;
|
2020-05-03 02:51:25 +00:00
|
|
|
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual void setStandby() override;
|
2020-07-13 20:18:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* We override to turn on transmitter power as needed.
|
|
|
|
*/
|
2022-01-24 17:24:40 +00:00
|
|
|
virtual void configHardwareForSend() override;
|
2020-07-13 20:18:32 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
/** Some boards require GPIO control of tx vs rx paths */
|
|
|
|
void setTransmitEnable(bool txon);
|
2022-01-24 07:00:14 +00:00
|
|
|
};
|