mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-28 18:47:40 +00:00
old RF95 code builds again
This commit is contained in:
parent
d7d8188093
commit
dd7452ad96
@ -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'
|
## 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.
|
- 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
|
- 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.
|
- 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.
|
||||||
|
@ -118,8 +118,10 @@ static uint32_t ledBlinker()
|
|||||||
|
|
||||||
Periodic ledPeriodic(ledBlinker);
|
Periodic ledPeriodic(ledBlinker);
|
||||||
|
|
||||||
|
#ifdef NO_ESP32
|
||||||
#include "SX1262Interface.h"
|
#include "SX1262Interface.h"
|
||||||
#include "variant.h"
|
#include "variant.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
|
@ -54,8 +54,8 @@ bool MeshRadio::init()
|
|||||||
delay(10);
|
delay(10);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
radioIf.setThisAddress(
|
// we now expect interfaces to operate in promiscous mode
|
||||||
nodeDB.getNodeNum()); // Note: we must do this here, because the nodenum isn't inited at constructor time.
|
// radioIf.setThisAddress(nodeDB.getNodeNum()); // Note: we must do this here, because the nodenum isn't inited at constructor time.
|
||||||
|
|
||||||
applySettings();
|
applySettings();
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ bool CustomRF95::init()
|
|||||||
{
|
{
|
||||||
bool ok = RH_RF95::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)
|
if (ok)
|
||||||
reconfigure(); // Finish our device setup
|
reconfigure(); // Finish our device setup
|
||||||
|
|
||||||
@ -73,6 +74,10 @@ ErrorCode CustomRF95::send(MeshPacket *p)
|
|||||||
// necessary
|
// necessary
|
||||||
void CustomRF95::handleInterrupt()
|
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();
|
RH_RF95::handleInterrupt();
|
||||||
|
|
||||||
if (_mode == RHModeIdle) // We are now done sending or receiving
|
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;
|
uint8_t *payload = _buf + RH_RF95_HEADER_LEN;
|
||||||
|
|
||||||
// FIXME - throws exception if called in ISR context: frequencyError() - probably the floating point math
|
// 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",
|
// 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);
|
// srcaddr, destaddr, id, rxlen, rf95.rxGood(), rf95.rxBad(), freqerr, snr);
|
||||||
|
|
||||||
@ -105,19 +110,11 @@ void CustomRF95::handleInterrupt()
|
|||||||
mp->from = _rxHeaderFrom;
|
mp->from = _rxHeaderFrom;
|
||||||
mp->to = _rxHeaderTo;
|
mp->to = _rxHeaderTo;
|
||||||
mp->id = _rxHeaderId;
|
mp->id = _rxHeaderId;
|
||||||
|
mp->rx_snr = snr;
|
||||||
|
|
||||||
//_rxHeaderId = _buf[2];
|
//_rxHeaderId = _buf[2];
|
||||||
//_rxHeaderFlags = _buf[3];
|
//_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)) {
|
if (!pb_decode_from_bytes(payload, payloadLen, SubPacket_fields, p)) {
|
||||||
packetPool.release(mp);
|
packetPool.release(mp);
|
||||||
} else {
|
} else {
|
||||||
@ -195,7 +192,7 @@ void CustomRF95::loop()
|
|||||||
|
|
||||||
bool CustomRF95::reconfigure()
|
bool CustomRF95::reconfigure()
|
||||||
{
|
{
|
||||||
radioIf.setModeIdle(); // Need to be idle before doing init
|
setModeIdle(); // Need to be idle before doing init
|
||||||
|
|
||||||
// Set up default configuration
|
// Set up default configuration
|
||||||
// No Sync Words in LORA mode.
|
// 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
|
// 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:
|
// you can set transmitter powers from 5 to 23 dBm:
|
||||||
// FIXME - can we do this? It seems to be in the Heltec board.
|
// 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
|
// Done with init tell radio to start receiving
|
||||||
radioIf.setModeRx();
|
setModeRx();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
@ -81,16 +81,6 @@ class RadioInterface
|
|||||||
|
|
||||||
// methods from radiohead
|
// 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.
|
/// Initialise the Driver transport hardware and software.
|
||||||
/// Make sure the Driver is properly configured before calling init().
|
/// Make sure the Driver is properly configured before calling init().
|
||||||
@ -118,17 +108,6 @@ class SimRadio : public RadioInterface
|
|||||||
|
|
||||||
// methods from radiohead
|
// 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.
|
/// Initialise the Driver transport hardware and software.
|
||||||
/// Make sure the Driver is properly configured before calling init().
|
/// Make sure the Driver is properly configured before calling init().
|
||||||
/// \return true if initialisation succeeded.
|
/// \return true if initialisation succeeded.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include "RadioLibInterface.h"
|
#include "RadioLibInterface.h"
|
||||||
#include "MeshTypes.h"
|
#include "MeshTypes.h"
|
||||||
#include "mesh-pb-constants.h"
|
#include "mesh-pb-constants.h"
|
||||||
|
#include <NodeDB.h> // FIXME, this class shouldn't need to look into nodedb
|
||||||
#include <configuration.h>
|
#include <configuration.h>
|
||||||
#include <pb_decode.h>
|
#include <pb_decode.h>
|
||||||
#include <pb_encode.h>
|
#include <pb_encode.h>
|
||||||
@ -165,10 +166,18 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||||||
// Skip the 4 headers that are at the beginning of the rxBuf
|
// Skip the 4 headers that are at the beginning of the rxBuf
|
||||||
int32_t payloadLen = length - sizeof(PacketHeader);
|
int32_t payloadLen = length - sizeof(PacketHeader);
|
||||||
const uint8_t *payload = radiobuf + sizeof(PacketHeader);
|
const uint8_t *payload = radiobuf + sizeof(PacketHeader);
|
||||||
|
|
||||||
|
// check for short packets
|
||||||
|
if (payloadLen < 0) {
|
||||||
|
DEBUG_MSG("ignoring received packet too short\n");
|
||||||
|
rxBad++;
|
||||||
|
} else {
|
||||||
const PacketHeader *h = (PacketHeader *)radiobuf;
|
const PacketHeader *h = (PacketHeader *)radiobuf;
|
||||||
|
uint8_t ourAddr = nodeDB.getNodeNum();
|
||||||
|
|
||||||
// fixme check for short packets
|
if (h->to != 255 && h->to != ourAddr) {
|
||||||
|
DEBUG_MSG("ignoring packet not sent to us\n");
|
||||||
|
} else {
|
||||||
MeshPacket *mp = packetPool.allocZeroed();
|
MeshPacket *mp = packetPool.allocZeroed();
|
||||||
|
|
||||||
SubPacket *p = &mp->payload;
|
SubPacket *p = &mp->payload;
|
||||||
@ -180,7 +189,7 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||||||
if (!pb_decode_from_bytes(payload, payloadLen, SubPacket_fields, p)) {
|
if (!pb_decode_from_bytes(payload, payloadLen, SubPacket_fields, p)) {
|
||||||
DEBUG_MSG("Invalid protobufs in received mesh packet, discarding.\n");
|
DEBUG_MSG("Invalid protobufs in received mesh packet, discarding.\n");
|
||||||
packetPool.release(mp);
|
packetPool.release(mp);
|
||||||
// rxBad++; not really a hw errpr
|
// rxBad++; not really a hw error
|
||||||
} else {
|
} else {
|
||||||
// parsing was successful, queue for our recipient
|
// parsing was successful, queue for our recipient
|
||||||
mp->has_payload = true;
|
mp->has_payload = true;
|
||||||
@ -189,6 +198,8 @@ void RadioLibInterface::handleReceiveInterrupt()
|
|||||||
deliverToReceiver(mp);
|
deliverToReceiver(mp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** start an immediate transmit */
|
/** start an immediate transmit */
|
||||||
|
@ -75,17 +75,6 @@ class RadioLibInterface : public RadioInterface
|
|||||||
|
|
||||||
// methods from radiohead
|
// 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
|
virtual void loop(); // Idle processing
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user