kopia lustrzana https://github.com/meshtastic/firmware
add back the old code that checked if the radio was actvively receiving
rodzic
a8f64c3cc8
commit
1f1d683f4f
|
@ -18,9 +18,8 @@ bool RF95Interface::init()
|
|||
if (power > 20) // This chip has lower power limits than some
|
||||
power = 20;
|
||||
|
||||
auto dev = new RadioLibRF95(&module);
|
||||
iface = lora = dev;
|
||||
int res = dev->begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength);
|
||||
iface = lora = new RadioLibRF95(&module);
|
||||
int res = lora->begin(freq, bw, sf, cr, syncWord, power, currentLimit, preambleLength);
|
||||
DEBUG_MSG("LORA init result %d\n", res);
|
||||
|
||||
if (res == ERR_NONE)
|
||||
|
@ -113,7 +112,7 @@ bool RF95Interface::canSendImmediately()
|
|||
// To do otherwise would be doubly bad because not only would we drop the packet that was on the way in,
|
||||
// we almost certainly guarantee no one outside will like the packet we are sending.
|
||||
bool busyTx = sendingPacket != NULL;
|
||||
bool busyRx = false; // FIXME - use old impl. isReceiving && lora->getPacketLength() > 0;
|
||||
bool busyRx = isReceiving && lora->isReceiving();
|
||||
|
||||
if (busyTx || busyRx)
|
||||
DEBUG_MSG("Can not set now, busyTx=%d, busyRx=%d\n", busyTx, busyRx);
|
||||
|
|
|
@ -2,13 +2,14 @@
|
|||
|
||||
#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
|
||||
{
|
||||
SX1278 *lora; // Either a RFM95 or RFM96 depending on what was stuffed on this board
|
||||
RadioLibRF95 *lora; // Either a RFM95 or RFM96 depending on what was stuffed on this board
|
||||
|
||||
public:
|
||||
RF95Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, SPIClass &spi);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "RadioLibRF95.h"
|
||||
|
||||
#define RFM95_CHIP_VERSION 0x12
|
||||
#define RFM95_ALT_VERSION 0x11 // Supposedly some versions of the chip have id 0x11
|
||||
#define RF95_CHIP_VERSION 0x12
|
||||
#define RF95_ALT_VERSION 0x11 // Supposedly some versions of the chip have id 0x11
|
||||
|
||||
RadioLibRF95::RadioLibRF95(Module *mod) : SX1278(mod) {}
|
||||
|
||||
|
@ -9,9 +9,9 @@ int16_t RadioLibRF95::begin(float freq, float bw, uint8_t sf, uint8_t cr, uint8_
|
|||
uint16_t preambleLength, uint8_t gain)
|
||||
{
|
||||
// execute common part
|
||||
int16_t state = SX127x::begin(RFM95_CHIP_VERSION, syncWord, currentLimit, preambleLength);
|
||||
int16_t state = SX127x::begin(RF95_CHIP_VERSION, syncWord, currentLimit, preambleLength);
|
||||
if (state != ERR_NONE)
|
||||
state = SX127x::begin(RFM95_ALT_VERSION, syncWord, currentLimit, preambleLength);
|
||||
state = SX127x::begin(RF95_ALT_VERSION, syncWord, currentLimit, preambleLength);
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// configure settings not accessible by API
|
||||
|
@ -46,3 +46,18 @@ int16_t RadioLibRF95::setFrequency(float freq)
|
|||
// set frequency
|
||||
return (SX127x::setFrequencyRaw(freq));
|
||||
}
|
||||
|
||||
#define RH_RF95_MODEM_STATUS_CLEAR 0x10
|
||||
#define RH_RF95_MODEM_STATUS_HEADER_INFO_VALID 0x08
|
||||
#define RH_RF95_MODEM_STATUS_RX_ONGOING 0x04
|
||||
#define RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED 0x02
|
||||
#define RH_RF95_MODEM_STATUS_SIGNAL_DETECTED 0x01
|
||||
|
||||
bool RadioLibRF95::isReceiving()
|
||||
{
|
||||
// 0x0b == Look for header info valid, signal synchronized or signal detected
|
||||
uint8_t reg = _mod->SPIreadRegister(SX127X_REG_MODEM_STAT) & 0x1f;
|
||||
// Serial.printf("reg %x\n", reg);
|
||||
return (reg & (RH_RF95_MODEM_STATUS_SIGNAL_DETECTED | RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED |
|
||||
RH_RF95_MODEM_STATUS_HEADER_INFO_VALID)) != 0;
|
||||
}
|
||||
|
|
|
@ -59,6 +59,9 @@ class RadioLibRF95: public SX1278 {
|
|||
*/
|
||||
int16_t setFrequency(float freq);
|
||||
|
||||
// Return true if we are actively receiving a message currently
|
||||
bool isReceiving();
|
||||
|
||||
#ifndef RADIOLIB_GODMODE
|
||||
private:
|
||||
#endif
|
||||
|
|
Ładowanie…
Reference in New Issue