mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-13 08:32:08 +00:00
DSR WIP
This commit is contained in:
parent
da2ef0ac61
commit
f56ff2ca20
@ -27,13 +27,12 @@
|
|||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "Periodic.h"
|
#include "Periodic.h"
|
||||||
#include "PowerFSM.h"
|
#include "PowerFSM.h"
|
||||||
#include "Router.h"
|
|
||||||
#include "UBloxGPS.h"
|
#include "UBloxGPS.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "power.h"
|
#include "power.h"
|
||||||
// #include "rom/rtc.h"
|
// #include "rom/rtc.h"
|
||||||
#include "ReliableRouter.h"
|
#include "DSRRouter.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "screen.h"
|
#include "screen.h"
|
||||||
#include "sleep.h"
|
#include "sleep.h"
|
||||||
@ -53,7 +52,7 @@ meshtastic::PowerStatus powerStatus;
|
|||||||
bool ssd1306_found;
|
bool ssd1306_found;
|
||||||
bool axp192_found;
|
bool axp192_found;
|
||||||
|
|
||||||
ReliableRouter realRouter;
|
DSRRouter realRouter;
|
||||||
Router &router = realRouter; // Users of router don't care what sort of subclass implements that API
|
Router &router = realRouter; // Users of router don't care what sort of subclass implements that API
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
@ -38,9 +38,26 @@ when we receive a routeError packet
|
|||||||
|
|
||||||
ErrorCode DSRRouter::send(MeshPacket *p)
|
ErrorCode DSRRouter::send(MeshPacket *p)
|
||||||
{
|
{
|
||||||
// If we have an entry in our routing tables, just send it, otherwise start a route discovery
|
// We only consider multihop routing packets (i.e. those with dest set)
|
||||||
|
if (p->decoded.dest) {
|
||||||
|
// add an entry for this pending message
|
||||||
|
auto pending = startRetransmission(p);
|
||||||
|
// FIXME - when acks come in for this packet, we should _not_ delete the record unless the ack was from
|
||||||
|
// the final dest. We need to keep that record around until FIXME
|
||||||
|
// Also we should not retransmit multihop entries in that table at all
|
||||||
|
|
||||||
return ReliableRouter::send(p);
|
// If we have an entry in our routing tables, just send it, otherwise start a route discovery
|
||||||
|
NodeNum nextHop = getNextHop(p->decoded.dest);
|
||||||
|
if (nextHop) {
|
||||||
|
sendNextHop(nextHop, p); // start a reliable single hop send
|
||||||
|
} else {
|
||||||
|
pending->wantRoute = true;
|
||||||
|
|
||||||
|
// start discovery, but only if we don't already a discovery in progress for that node number
|
||||||
|
startDiscovery(p->decoded.dest);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
return ReliableRouter::send(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DSRRouter::sniffReceived(const MeshPacket *p)
|
void DSRRouter::sniffReceived(const MeshPacket *p)
|
||||||
|
@ -146,13 +146,15 @@ bool ReliableRouter::stopRetransmission(GlobalPacketId key)
|
|||||||
/**
|
/**
|
||||||
* Add p to the list of packets to retransmit occasionally. We will free it once we stop retransmitting.
|
* Add p to the list of packets to retransmit occasionally. We will free it once we stop retransmitting.
|
||||||
*/
|
*/
|
||||||
void ReliableRouter::startRetransmission(MeshPacket *p)
|
PendingPacket *ReliableRouter::startRetransmission(MeshPacket *p)
|
||||||
{
|
{
|
||||||
auto id = GlobalPacketId(p);
|
auto id = GlobalPacketId(p);
|
||||||
auto rec = PendingPacket(p);
|
auto rec = PendingPacket(p);
|
||||||
|
|
||||||
stopRetransmission(p->from, p->id);
|
stopRetransmission(p->from, p->id);
|
||||||
pending[id] = rec;
|
pending[id] = rec;
|
||||||
|
|
||||||
|
return &pending[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,6 +103,11 @@ class ReliableRouter : public FloodingRouter
|
|||||||
*/
|
*/
|
||||||
virtual bool shouldFilterReceived(const MeshPacket *p);
|
virtual bool shouldFilterReceived(const MeshPacket *p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add p to the list of packets to retransmit occasionally. We will free it once we stop retransmitting.
|
||||||
|
*/
|
||||||
|
PendingPacket *startRetransmission(MeshPacket *p);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Send an ack or a nak packet back towards whoever sent idFrom
|
* Send an ack or a nak packet back towards whoever sent idFrom
|
||||||
@ -117,11 +122,6 @@ class ReliableRouter : public FloodingRouter
|
|||||||
bool stopRetransmission(NodeNum from, PacketId id);
|
bool stopRetransmission(NodeNum from, PacketId id);
|
||||||
bool stopRetransmission(GlobalPacketId p);
|
bool stopRetransmission(GlobalPacketId p);
|
||||||
|
|
||||||
/**
|
|
||||||
* Add p to the list of packets to retransmit occasionally. We will free it once we stop retransmitting.
|
|
||||||
*/
|
|
||||||
void startRetransmission(MeshPacket *p);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do any retransmissions that are scheduled (FIXME - for the time being called from loop)
|
* Do any retransmissions that are scheduled (FIXME - for the time being called from loop)
|
||||||
*/
|
*/
|
||||||
|
@ -78,5 +78,12 @@ void nrf52Setup()
|
|||||||
|
|
||||||
// Not yet on board
|
// Not yet on board
|
||||||
// pmu.init();
|
// pmu.init();
|
||||||
DEBUG_MSG("FIXME, need to call randomSeed on nrf52!\n");
|
|
||||||
|
// Init random seed
|
||||||
|
// FIXME - use this to get random numbers
|
||||||
|
// #include "nrf_rng.h"
|
||||||
|
// uint32_t r;
|
||||||
|
// ble_controller_rand_vector_get_blocking(&r, sizeof(r));
|
||||||
|
// randomSeed(r);
|
||||||
|
DEBUG_MSG("FIXME, call randomSeed\n");
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user