mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-20 16:56:17 +00:00
added first Part of FSR-Module
This commit is contained in:
parent
37a91d6a07
commit
dbb6970c1f
@ -24,28 +24,89 @@ FishEyeStateRoutingModule::FishEyeStateRoutingModule()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* gets called from the NeighborInfo-Module if a new NeighborInfo Package arrives
|
||||||
|
*/
|
||||||
bool FishEyeStateRoutingModule::addNeighborInfo(meshtastic_NeighborInfo Ninfo){
|
bool FishEyeStateRoutingModule::addNeighborInfo(meshtastic_NeighborInfo Ninfo){
|
||||||
|
auto it = LSPDB.find(Ninfo.node_id);
|
||||||
|
if(it != LSPDB.end()){ //Node already in LSPDB
|
||||||
|
if(it->second.LSP.creation < Ninfo.creation){
|
||||||
|
bool diff = false;
|
||||||
|
for(int i = 0; i < min(Ninfo.neighbors_count,it->second.LSP.neighbors_count); i++){
|
||||||
|
if((Ninfo.neighbors[i].node_id) != (it->second.LSP.neighbors[i].node_id)){
|
||||||
|
diff = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(diff || (it->second.LSP.traveledHops != 1) || (it->second.LSP.neighbors_count != Ninfo.neighbors_count)){
|
||||||
|
LSPDBEntry entry;
|
||||||
|
NinfoToLSPDBEntry(&Ninfo,&entry);
|
||||||
|
if(it->second.forwarded == false){
|
||||||
|
entry.timeout = min(it->second.timeout,entry.timeout);
|
||||||
|
}
|
||||||
|
entry.nextHop = it->second.nextHop;
|
||||||
|
it->second = entry;
|
||||||
|
calcNextHop();
|
||||||
|
return 1;
|
||||||
|
}else{
|
||||||
|
it->second.forwarded = false;
|
||||||
|
it->second.timeout = getTime() + moduleConfig.neighbor_info.update_interval * std::pow(it->second.LSP.traveledHops, alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{ //Node not in LSPDB
|
||||||
|
LSPDBEntry entry; //new entry
|
||||||
|
NinfoToLSPDBEntry(&Ninfo,&entry);
|
||||||
|
LSPDB.insert(std::make_pair(entry.LSP.node_id,entry)); //insert into DB
|
||||||
|
calcNextHop(); //calculate shortest Path
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FishEyeStateRoutingModule::NinfoToLSPDBEntry(meshtastic_NeighborInfo *Ninfo, LSPDBEntry *fsr){
|
||||||
|
fsr->nextHop = NODENUM_BROADCAST;
|
||||||
|
fsr->LSP.node_id = Ninfo->node_id;
|
||||||
|
fsr->LSP.traveledHops = 1;
|
||||||
|
fsr->LSP.neighbors_count = Ninfo->neighbors_count;
|
||||||
|
for(int i = 0; i < Ninfo->neighbors_count; i++){
|
||||||
|
fsr->LSP.neighbors[i] = Ninfo->neighbors[i];
|
||||||
|
}
|
||||||
|
fsr->LSP.creation = Ninfo->creation;
|
||||||
|
fsr->timeout = getTime() + moduleConfig.neighbor_info.update_interval * std::pow(fsr->LSP.traveledHops, alpha);
|
||||||
|
fsr->forwarded = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* returns next-Hop for a Message to a given NodeID
|
||||||
|
*/
|
||||||
uint32_t FishEyeStateRoutingModule::getNextHopForID(uint32_t dest){
|
uint32_t FishEyeStateRoutingModule::getNextHopForID(uint32_t dest){
|
||||||
|
auto it = LSPDB.find(dest);
|
||||||
|
if(it == LSPDB.end()){
|
||||||
|
return NODENUM_BROADCAST;
|
||||||
|
}else{
|
||||||
|
return it->second.nextHop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* handels incomming LSP-Packages
|
||||||
|
*/
|
||||||
bool FishEyeStateRoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_FishEyeStateRouting *lsp)
|
bool FishEyeStateRoutingModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp, meshtastic_FishEyeStateRouting *lsp)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t FishEyeStateRoutingModule::runOnce(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FishEyeStateRoutingModule::calcNextHop(){
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Collect a received neighbor info packet from another node
|
*
|
||||||
Pass it to an upper client; do not persist this data on the mesh
|
*/
|
||||||
*/
|
int32_t FishEyeStateRoutingModule::runOnce(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Calculates Distances and Next-Hops
|
||||||
|
*/
|
||||||
|
bool FishEyeStateRoutingModule::calcNextHop(){
|
||||||
|
//sofortigen run once Check calen
|
||||||
|
|
||||||
|
}
|
@ -39,7 +39,11 @@ class FishEyeStateRoutingModule : public ProtobufModule<meshtastic_FishEyeStateR
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
float alpha = 2;
|
||||||
|
|
||||||
struct LSPDBEntry{
|
struct LSPDBEntry{
|
||||||
|
uint32_t timeout;
|
||||||
|
bool forwarded;
|
||||||
uint32_t nextHop;
|
uint32_t nextHop;
|
||||||
meshtastic_FishEyeStateRouting LSP;
|
meshtastic_FishEyeStateRouting LSP;
|
||||||
};
|
};
|
||||||
@ -54,5 +58,10 @@ class FishEyeStateRoutingModule : public ProtobufModule<meshtastic_FishEyeStateR
|
|||||||
*/
|
*/
|
||||||
bool calcNextHop();
|
bool calcNextHop();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* converts NeighborInfo Struct into LSPDBEntry-Struct
|
||||||
|
*/
|
||||||
|
void NinfoToLSPDBEntry(meshtastic_NeighborInfo *Ninfo, LSPDBEntry *fsr);
|
||||||
|
|
||||||
};
|
};
|
||||||
extern FishEyeStateRoutingModule *fishEyeStateRoutingModule;
|
extern FishEyeStateRoutingModule *fishEyeStateRoutingModule;
|
@ -4,6 +4,7 @@
|
|||||||
#include "NodeDB.h"
|
#include "NodeDB.h"
|
||||||
#include "RTC.h"
|
#include "RTC.h"
|
||||||
#include <Throttle.h>
|
#include <Throttle.h>
|
||||||
|
#include "FishEyeStateRoutingModule.h"
|
||||||
|
|
||||||
NeighborInfoModule *neighborInfoModule;
|
NeighborInfoModule *neighborInfoModule;
|
||||||
|
|
||||||
@ -145,6 +146,9 @@ bool NeighborInfoModule::handleReceivedProtobuf(const meshtastic_MeshPacket &mp,
|
|||||||
// If the hopLimit is the same as hopStart, then it is a neighbor
|
// If the hopLimit is the same as hopStart, then it is a neighbor
|
||||||
getOrCreateNeighbor(mp.from, mp.from, 0, mp.rx_snr); // Set the broadcast interval to 0, as we don't know it
|
getOrCreateNeighbor(mp.from, mp.from, 0, mp.rx_snr); // Set the broadcast interval to 0, as we don't know it
|
||||||
}
|
}
|
||||||
|
if(moduleConfig.has_fish_eye_state_routing && moduleConfig.fish_eye_state_routing.enabled && (config.network.routingAlgorithm == meshtastic_Config_RoutingConfig_FishEyeState)){
|
||||||
|
fishEyeStateRoutingModule->addNeighborInfo(*np);
|
||||||
|
}
|
||||||
// Allow others to handle this packet
|
// Allow others to handle this packet
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user