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
|
|
|
|
{
|
2020-05-01 04:29:51 +00:00
|
|
|
RadioLibRF95 *lora; // 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);
|
|
|
|
|
|
|
|
/// 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();
|
|
|
|
|
|
|
|
/// Apply any radio provisioning changes
|
|
|
|
/// Make sure the Driver is properly configured before calling init().
|
|
|
|
/// \return true if initialisation succeeded.
|
|
|
|
virtual bool reconfigure();
|
|
|
|
|
|
|
|
/// Prepare hardware for sleep. Call this _only_ for deep sleep, not needed for light sleep.
|
|
|
|
virtual bool sleep();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/**
|
|
|
|
* Glue functions called from ISR land
|
|
|
|
*/
|
2020-05-01 00:56:30 +00:00
|
|
|
virtual void disableInterrupt();
|
2020-05-01 00:43:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable a particular ISR callback glue function
|
|
|
|
*/
|
|
|
|
virtual void enableInterrupt(void (*callback)()) { lora->setDio0Action(callback); }
|
|
|
|
|
2020-05-01 15:32:16 +00:00
|
|
|
/** are we actively receiving a packet (only called during receiving state) */
|
|
|
|
virtual bool isActivelyReceiving();
|
2020-05-03 02:51:25 +00:00
|
|
|
|
2020-05-01 00:43:29 +00:00
|
|
|
/**
|
|
|
|
* Start waiting to receive a message
|
|
|
|
*/
|
|
|
|
virtual void startReceive();
|
|
|
|
|
2020-05-01 02:58:10 +00:00
|
|
|
/**
|
|
|
|
* Add SNR data to received messages
|
|
|
|
*/
|
|
|
|
virtual void addReceiveMetadata(MeshPacket *mp);
|
2020-05-03 02:51:25 +00:00
|
|
|
|
|
|
|
virtual void setStandby();
|
2020-07-13 20:18:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* We override to turn on transmitter power as needed.
|
|
|
|
*/
|
|
|
|
virtual void configHardwareForSend();
|
|
|
|
|
|
|
|
private:
|
|
|
|
/** Some boards require GPIO control of tx vs rx paths */
|
|
|
|
void setTransmitEnable(bool txon);
|
2020-05-01 00:43:29 +00:00
|
|
|
};
|