* new RX delays based on SNR

This commit is contained in:
Scott Powell 2025-02-04 12:35:53 +11:00
parent 29e62b9ce2
commit 7da0a5f7ec
13 changed files with 116 additions and 23 deletions

View file

@ -18,4 +18,14 @@ public:
}
float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); }
float getLastSNR() const override { return ((CustomLLCC68 *)_radio)->getSNR(); }
float packetScore(float snr, int packet_len) override {
int sf = ((CustomLLCC68 *)_radio)->spreadingFactor;
const float A = 0.7;
const float B = 0.4;
float ber = exp(-pow(10, (snr / 10)) / (A * pow(10, (snr / 10)) + B * (1 << sf)));
return pow(1 - ber, packet_len * 8);
}
};

View file

@ -2,6 +2,7 @@
#include "CustomSX1262.h"
#include "RadioLibWrappers.h"
#include <math.h>
class CustomSX1262Wrapper : public RadioLibWrapper {
public:
@ -18,4 +19,14 @@ public:
}
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); }
float packetScore(float snr, int packet_len) override {
int sf = ((CustomSX1262 *)_radio)->spreadingFactor;
const float A = 0.7;
const float B = 0.4;
float ber = exp(-pow(10, (snr / 10)) / (A * pow(10, (snr / 10)) + B * (1 << sf)));
return pow(1 - ber, packet_len * 8);
}
};

View file

@ -18,4 +18,14 @@ public:
}
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
float getLastSNR() const override { return ((CustomSX1268 *)_radio)->getSNR(); }
float packetScore(float snr, int packet_len) override {
int sf = ((CustomSX1268 *)_radio)->spreadingFactor;
const float A = 0.7;
const float B = 0.4;
float ber = exp(-pow(10, (snr / 10)) / (A * pow(10, (snr / 10)) + B * (1 << sf)));
return pow(1 - ber, packet_len * 8);
}
};

View file

@ -25,6 +25,8 @@ public:
uint32_t getPacketsSent() const { return n_sent; }
virtual float getLastRSSI() const override;
virtual float getLastSNR() const override;
float packetScore(float snr, int packet_len) override { return 0.85f; } // stub impl
};
/**

View file

@ -57,7 +57,7 @@ void PacketQueue::add(mesh::Packet* packet, uint8_t priority, uint32_t scheduled
_num++;
}
StaticPoolPacketManager::StaticPoolPacketManager(int pool_size): unused(pool_size), send_queue(pool_size) {
StaticPoolPacketManager::StaticPoolPacketManager(int pool_size): unused(pool_size), send_queue(pool_size), rx_queue(pool_size) {
// load up our unusued Packet pool
for (int i = 0; i < pool_size; i++) {
unused.add(new mesh::Packet(), 0, 0);
@ -95,3 +95,10 @@ mesh::Packet* StaticPoolPacketManager::getOutboundByIdx(int i) {
mesh::Packet* StaticPoolPacketManager::removeOutboundByIdx(int i) {
return send_queue.removeByIdx(i);
}
void StaticPoolPacketManager::queueInbound(mesh::Packet* packet, uint32_t scheduled_for) {
// TODO
}
mesh::Packet* StaticPoolPacketManager::getNextInbound(uint32_t now) {
return NULL; // TODO
}

View file

@ -18,7 +18,7 @@ public:
};
class StaticPoolPacketManager : public mesh::PacketManager {
PacketQueue unused, send_queue;
PacketQueue unused, send_queue, rx_queue;
public:
StaticPoolPacketManager(int pool_size);
@ -31,4 +31,6 @@ public:
int getFreeCount() const override;
mesh::Packet* getOutboundByIdx(int i) override;
mesh::Packet* removeOutboundByIdx(int i) override;
void queueInbound(mesh::Packet* packet, uint32_t scheduled_for) override;
mesh::Packet* getNextInbound(uint32_t now) override;
};