[EXT] Implemented direct transmit (#646)
This commit is contained in:
parent
01917ad0c2
commit
b139767559
2 changed files with 83 additions and 6 deletions
|
@ -1,15 +1,47 @@
|
|||
#include "ExternalRadio.h"
|
||||
|
||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||
ExternalRadio::ExternalRadio() : PhysicalLayer(1, 0) {
|
||||
mod = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
|
||||
ExternalRadio::ExternalRadio(uint32_t pin) : PhysicalLayer(1, 0) {
|
||||
mod = new Module(RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, pin);
|
||||
mod->hal->pinMode(pin, mod->hal->GpioModeOutput);
|
||||
this->prevFrf = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
ExternalRadio::ExternalRadio(RadioLibHal *hal) : PhysicalLayer(1, 0) {
|
||||
mod = new Module(hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC);
|
||||
ExternalRadio::ExternalRadio(RadioLibHal *hal, uint32_t pin) : PhysicalLayer(1, 0) {
|
||||
mod = new Module(hal, RADIOLIB_NC, RADIOLIB_NC, RADIOLIB_NC, pin);
|
||||
mod->hal->pinMode(pin, mod->hal->GpioModeOutput);
|
||||
this->prevFrf = 0;
|
||||
}
|
||||
|
||||
Module* ExternalRadio::getMod() {
|
||||
return(mod);
|
||||
}
|
||||
|
||||
int16_t ExternalRadio::setFrequencyDeviation(float freqDev) {
|
||||
(void)freqDev;
|
||||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t ExternalRadio::setDataShaping(uint8_t sh) {
|
||||
(void)sh;
|
||||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t ExternalRadio::setEncoding(uint8_t encoding) {
|
||||
(void)encoding;
|
||||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
||||
|
||||
int16_t ExternalRadio::transmitDirect(uint32_t frf) {
|
||||
if(frf != this->prevFrf) {
|
||||
uint32_t val = this->mod->hal->GpioLevelLow;
|
||||
if(frf > this->prevFrf) {
|
||||
val = this->mod->hal->GpioLevelHigh;
|
||||
}
|
||||
this->prevFrf = frf;
|
||||
this->mod->hal->digitalWrite(this->mod->getGpio(), val);
|
||||
}
|
||||
|
||||
return(RADIOLIB_ERR_NONE);
|
||||
}
|
|
@ -12,13 +12,58 @@
|
|||
class ExternalRadio: public PhysicalLayer {
|
||||
public:
|
||||
#if defined(RADIOLIB_BUILD_ARDUINO)
|
||||
ExternalRadio();
|
||||
/*!
|
||||
\brief Default constructor.
|
||||
\param pin Output pin when using direct transmission, defaults to unused pin.
|
||||
*/
|
||||
ExternalRadio(uint32_t pin = RADIOLIB_NC);
|
||||
#endif
|
||||
ExternalRadio(RadioLibHal *hal);
|
||||
|
||||
/*!
|
||||
\brief Default constructor.
|
||||
\param hal Pointer to the hardware abstraction layer to use.
|
||||
\param pin Output pin when using direct transmission, defaults to unused pin.
|
||||
*/
|
||||
ExternalRadio(RadioLibHal *hal, uint32_t pin = RADIOLIB_NC);
|
||||
|
||||
/*!
|
||||
\brief Method to retrieve pointer to the underlying Module instance.
|
||||
\returns Pointer to the Module instance.
|
||||
*/
|
||||
Module* getMod();
|
||||
|
||||
/*!
|
||||
\brief Dummy implementation overriding PhysicalLayer.
|
||||
\param freqDev Ignored.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setFrequencyDeviation(float freqDev) override;
|
||||
|
||||
/*!
|
||||
\brief Dummy implementation overriding PhysicalLayer.
|
||||
\param sh Ignored.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setDataShaping(uint8_t sh) override;
|
||||
|
||||
/*!
|
||||
\brief Dummy implementation overriding PhysicalLayer.
|
||||
\param encoding Ignored.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t setEncoding(uint8_t encoding) override;
|
||||
|
||||
/*!
|
||||
\brief Direct transmission to drive external radio.
|
||||
\param frf "Frequency" to control the output pin. If the frequency is higher than the one sent previously,
|
||||
the output pin will be set to logic high. Otherwise it will be set to logic low.
|
||||
\returns \ref status_codes
|
||||
*/
|
||||
int16_t transmitDirect(uint32_t frf = 0);
|
||||
|
||||
private:
|
||||
Module* mod;
|
||||
uint32_t prevFrf;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue