old RF95 code builds again

pull/117/head
geeksville 2020-04-30 16:36:59 -07:00
rodzic d7d8188093
commit dd7452ad96
7 zmienionych plików z 47 dodań i 66 usunięć

Wyświetl plik

@ -54,6 +54,7 @@ Needed to be fully functional at least at the same level of the ESP32 boards. At
## Items to be 'feature complete'
- turn back on in-radio destaddr checking for RF95
- remove the MeshRadio wrapper - we don't need it anymore, just do everythin in RadioInterface subclasses.
- figure out what the correct current limit should be for the sx1262, currently we just use the default 100
- put sx1262 in sleepmode when processor gets shutdown (or rebooted), ideally even for critical faults (to keep power draw low). repurpose deepsleep state for this.

Wyświetl plik

@ -118,8 +118,10 @@ static uint32_t ledBlinker()
Periodic ledPeriodic(ledBlinker);
#ifdef NO_ESP32
#include "SX1262Interface.h"
#include "variant.h"
#endif
void setup()
{

Wyświetl plik

@ -54,8 +54,8 @@ bool MeshRadio::init()
delay(10);
#endif
radioIf.setThisAddress(
nodeDB.getNodeNum()); // Note: we must do this here, because the nodenum isn't inited at constructor time.
// we now expect interfaces to operate in promiscous mode
// radioIf.setThisAddress(nodeDB.getNodeNum()); // Note: we must do this here, because the nodenum isn't inited at constructor time.
applySettings();

Wyświetl plik

@ -34,6 +34,7 @@ bool CustomRF95::init()
{
bool ok = RH_RF95::init();
// this->setPromiscuous(true); // Make the old RH stack work like the new one, make make CPU check dest addr
if (ok)
reconfigure(); // Finish our device setup
@ -73,6 +74,10 @@ ErrorCode CustomRF95::send(MeshPacket *p)
// necessary
void CustomRF95::handleInterrupt()
{
setThisAddress(
nodeDB
.getNodeNum()); // temp hack to make sure we are looking for the right address. This class is going away soon anyways
RH_RF95::handleInterrupt();
if (_mode == RHModeIdle) // We are now done sending or receiving
@ -94,7 +99,7 @@ void CustomRF95::handleInterrupt()
uint8_t *payload = _buf + RH_RF95_HEADER_LEN;
// FIXME - throws exception if called in ISR context: frequencyError() - probably the floating point math
int32_t freqerr = -1, snr = lastSNR();
int32_t snr = lastSNR();
// DEBUG_MSG("Received packet from mesh src=0x%x,dest=0x%x,id=%d,len=%d rxGood=%d,rxBad=%d,freqErr=%d,snr=%d\n",
// srcaddr, destaddr, id, rxlen, rf95.rxGood(), rf95.rxBad(), freqerr, snr);
@ -105,19 +110,11 @@ void CustomRF95::handleInterrupt()
mp->from = _rxHeaderFrom;
mp->to = _rxHeaderTo;
mp->id = _rxHeaderId;
mp->rx_snr = snr;
//_rxHeaderId = _buf[2];
//_rxHeaderFlags = _buf[3];
// If we already have an entry in the DB for this nodenum, goahead and hide the snr/freqerr info there.
// Note: we can't create it at this point, because it might be a bogus User node allocation. But odds are we will
// already have a record we can hide this debugging info in.
NodeInfo *info = nodeDB.getNode(mp->from);
if (info) {
info->snr = snr;
info->frequency_error = freqerr;
}
if (!pb_decode_from_bytes(payload, payloadLen, SubPacket_fields, p)) {
packetPool.release(mp);
} else {
@ -195,7 +192,7 @@ void CustomRF95::loop()
bool CustomRF95::reconfigure()
{
radioIf.setModeIdle(); // Need to be idle before doing init
setModeIdle(); // Need to be idle before doing init
// Set up default configuration
// No Sync Words in LORA mode.
@ -214,9 +211,11 @@ bool CustomRF95::reconfigure()
// If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
// you can set transmitter powers from 5 to 23 dBm:
// FIXME - can we do this? It seems to be in the Heltec board.
radioIf.setTxPower(tx_power, false);
setTxPower(power, false);
// Done with init tell radio to start receiving
radioIf.setModeRx();
setModeRx();
return true;
}
#endif

Wyświetl plik

@ -81,16 +81,6 @@ class RadioInterface
// methods from radiohead
/// Sets the address of this node. Defaults to 0xFF. Subclasses or the user may want to change this.
/// This will be used to test the adddress in incoming messages. In non-promiscuous mode,
/// only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted.
/// In promiscuous mode, all messages will be accepted regardless of the TO header.
/// In a conventional multinode system, all nodes will have a unique address
/// (which you could store in EEPROM).
/// You would normally set the header FROM address to be the same as thisAddress (though you dont have to,
/// allowing the possibilty of address spoofing).
/// \param[in] thisAddress The address of this node.
virtual void setThisAddress(uint8_t thisAddress) = 0;
/// Initialise the Driver transport hardware and software.
/// Make sure the Driver is properly configured before calling init().
@ -118,17 +108,6 @@ class SimRadio : public RadioInterface
// methods from radiohead
/// Sets the address of this node. Defaults to 0xFF. Subclasses or the user may want to change this.
/// This will be used to test the adddress in incoming messages. In non-promiscuous mode,
/// only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted.
/// In promiscuous mode, all messages will be accepted regardless of the TO header.
/// In a conventional multinode system, all nodes will have a unique address
/// (which you could store in EEPROM).
/// You would normally set the header FROM address to be the same as thisAddress (though you dont have to,
/// allowing the possibilty of address spoofing).
/// \param[in] thisAddress The address of this node.
virtual void setThisAddress(uint8_t thisAddress) {}
/// Initialise the Driver transport hardware and software.
/// Make sure the Driver is properly configured before calling init().
/// \return true if initialisation succeeded.

Wyświetl plik

@ -1,6 +1,7 @@
#include "RadioLibInterface.h"
#include "MeshTypes.h"
#include "mesh-pb-constants.h"
#include <NodeDB.h> // FIXME, this class shouldn't need to look into nodedb
#include <configuration.h>
#include <pb_decode.h>
#include <pb_encode.h>
@ -165,28 +166,38 @@ void RadioLibInterface::handleReceiveInterrupt()
// Skip the 4 headers that are at the beginning of the rxBuf
int32_t payloadLen = length - sizeof(PacketHeader);
const uint8_t *payload = radiobuf + sizeof(PacketHeader);
const PacketHeader *h = (PacketHeader *)radiobuf;
// fixme check for short packets
MeshPacket *mp = packetPool.allocZeroed();
SubPacket *p = &mp->payload;
mp->from = h->from;
mp->to = h->to;
mp->id = h->id;
if (!pb_decode_from_bytes(payload, payloadLen, SubPacket_fields, p)) {
DEBUG_MSG("Invalid protobufs in received mesh packet, discarding.\n");
packetPool.release(mp);
// rxBad++; not really a hw errpr
// check for short packets
if (payloadLen < 0) {
DEBUG_MSG("ignoring received packet too short\n");
rxBad++;
} else {
// parsing was successful, queue for our recipient
mp->has_payload = true;
txGood++;
const PacketHeader *h = (PacketHeader *)radiobuf;
uint8_t ourAddr = nodeDB.getNodeNum();
deliverToReceiver(mp);
if (h->to != 255 && h->to != ourAddr) {
DEBUG_MSG("ignoring packet not sent to us\n");
} else {
MeshPacket *mp = packetPool.allocZeroed();
SubPacket *p = &mp->payload;
mp->from = h->from;
mp->to = h->to;
mp->id = h->id;
if (!pb_decode_from_bytes(payload, payloadLen, SubPacket_fields, p)) {
DEBUG_MSG("Invalid protobufs in received mesh packet, discarding.\n");
packetPool.release(mp);
// rxBad++; not really a hw error
} else {
// parsing was successful, queue for our recipient
mp->has_payload = true;
txGood++;
deliverToReceiver(mp);
}
}
}
}
}

Wyświetl plik

@ -75,17 +75,6 @@ class RadioLibInterface : public RadioInterface
// methods from radiohead
/// Sets the address of this node. Defaults to 0xFF. Subclasses or the user may want to change this.
/// This will be used to test the adddress in incoming messages. In non-promiscuous mode,
/// only messages with a TO header the same as thisAddress or the broadcast addess (0xFF) will be accepted.
/// In promiscuous mode, all messages will be accepted regardless of the TO header.
/// In a conventional multinode system, all nodes will have a unique address
/// (which you could store in EEPROM).
/// You would normally set the header FROM address to be the same as thisAddress (though you dont have to,
/// allowing the possibilty of address spoofing).
/// \param[in] thisAddress The address of this node.
virtual void setThisAddress(uint8_t thisAddress) {}
virtual void loop(); // Idle processing
/**