mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
* refactor of RadioLibWrapper::isReceiving()
This commit is contained in:
parent
4449fd3a24
commit
2f8d9cf96a
8 changed files with 32 additions and 73 deletions
|
|
@ -6,18 +6,8 @@
|
||||||
class CustomLLCC68Wrapper : public RadioLibWrapper {
|
class CustomLLCC68Wrapper : public RadioLibWrapper {
|
||||||
public:
|
public:
|
||||||
CustomLLCC68Wrapper(CustomLLCC68& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
CustomLLCC68Wrapper(CustomLLCC68& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||||
bool isReceiving() override {
|
bool isReceivingPacket() override {
|
||||||
if (((CustomLLCC68 *)_radio)->isReceiving()) return true;
|
return ((CustomLLCC68 *)_radio)->isReceiving();
|
||||||
|
|
||||||
idle(); // put sx126x into standby
|
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|
||||||
bool activity = (((CustomLLCC68 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
|
||||||
if (activity) {
|
|
||||||
startRecv();
|
|
||||||
} else {
|
|
||||||
idle();
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); }
|
||||||
float getLastSNR() const override { return ((CustomLLCC68 *)_radio)->getSNR(); }
|
float getLastSNR() const override { return ((CustomLLCC68 *)_radio)->getSNR(); }
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,8 @@
|
||||||
class CustomLR1110Wrapper : public RadioLibWrapper {
|
class CustomLR1110Wrapper : public RadioLibWrapper {
|
||||||
public:
|
public:
|
||||||
CustomLR1110Wrapper(CustomLR1110& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
CustomLR1110Wrapper(CustomLR1110& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||||
bool isReceiving() override {
|
bool isReceivingPacket() override {
|
||||||
if (((CustomLR1110 *)_radio)->isReceiving()) return true;
|
return ((CustomLR1110 *)_radio)->isReceiving();
|
||||||
|
|
||||||
idle(); // put sx126x into standby
|
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|
||||||
bool activity = (((CustomLR1110 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
|
||||||
if (activity) {
|
|
||||||
startRecv();
|
|
||||||
} else {
|
|
||||||
idle();
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void onSendFinished() override {
|
void onSendFinished() override {
|
||||||
|
|
|
||||||
|
|
@ -7,18 +7,8 @@
|
||||||
class CustomSTM32WLxWrapper : public RadioLibWrapper {
|
class CustomSTM32WLxWrapper : public RadioLibWrapper {
|
||||||
public:
|
public:
|
||||||
CustomSTM32WLxWrapper(CustomSTM32WLx& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
CustomSTM32WLxWrapper(CustomSTM32WLx& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||||
bool isReceiving() override {
|
bool isReceivingPacket() override {
|
||||||
if (((CustomSTM32WLx *)_radio)->isReceiving()) return true;
|
return ((CustomSTM32WLx *)_radio)->isReceiving();
|
||||||
|
|
||||||
idle(); // put sx126x into standby
|
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|
||||||
bool activity = (((CustomSTM32WLx *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
|
||||||
if (activity) {
|
|
||||||
startRecv();
|
|
||||||
} else {
|
|
||||||
idle();
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSTM32WLx *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSTM32WLx *)_radio)->getRSSI(); }
|
||||||
float getLastSNR() const override { return ((CustomSTM32WLx *)_radio)->getSNR(); }
|
float getLastSNR() const override { return ((CustomSTM32WLx *)_radio)->getSNR(); }
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,12 @@
|
||||||
|
|
||||||
#include "CustomSX1262.h"
|
#include "CustomSX1262.h"
|
||||||
#include "RadioLibWrappers.h"
|
#include "RadioLibWrappers.h"
|
||||||
#include <math.h>
|
|
||||||
|
|
||||||
class CustomSX1262Wrapper : public RadioLibWrapper {
|
class CustomSX1262Wrapper : public RadioLibWrapper {
|
||||||
public:
|
public:
|
||||||
CustomSX1262Wrapper(CustomSX1262& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
CustomSX1262Wrapper(CustomSX1262& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||||
bool isReceiving() override {
|
bool isReceivingPacket() override {
|
||||||
if (((CustomSX1262 *)_radio)->isReceiving()) return true;
|
return ((CustomSX1262 *)_radio)->isReceiving();
|
||||||
|
|
||||||
idle(); // put sx126x into standby
|
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|
||||||
bool activity = (((CustomSX1262 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
|
||||||
if (activity) {
|
|
||||||
startRecv();
|
|
||||||
} else {
|
|
||||||
idle();
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSX1262 *)_radio)->getRSSI(); }
|
||||||
float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); }
|
float getLastSNR() const override { return ((CustomSX1262 *)_radio)->getSNR(); }
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,8 @@
|
||||||
class CustomSX1268Wrapper : public RadioLibWrapper {
|
class CustomSX1268Wrapper : public RadioLibWrapper {
|
||||||
public:
|
public:
|
||||||
CustomSX1268Wrapper(CustomSX1268& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
CustomSX1268Wrapper(CustomSX1268& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||||
bool isReceiving() override {
|
bool isReceivingPacket() override {
|
||||||
if (((CustomSX1268 *)_radio)->isReceiving()) return true;
|
return ((CustomSX1268 *)_radio)->isReceiving();
|
||||||
|
|
||||||
idle(); // put sx126x into standby
|
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|
||||||
bool activity = (((CustomSX1268 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED);
|
|
||||||
if (activity) {
|
|
||||||
startRecv();
|
|
||||||
} else {
|
|
||||||
idle();
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSX1268 *)_radio)->getRSSI(); }
|
||||||
float getLastSNR() const override { return ((CustomSX1268 *)_radio)->getSNR(); }
|
float getLastSNR() const override { return ((CustomSX1268 *)_radio)->getSNR(); }
|
||||||
|
|
|
||||||
|
|
@ -6,18 +6,8 @@
|
||||||
class CustomSX1276Wrapper : public RadioLibWrapper {
|
class CustomSX1276Wrapper : public RadioLibWrapper {
|
||||||
public:
|
public:
|
||||||
CustomSX1276Wrapper(CustomSX1276& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
CustomSX1276Wrapper(CustomSX1276& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||||
bool isReceiving() override {
|
bool isReceivingPacket() override {
|
||||||
if (((CustomSX1276 *)_radio)->isReceiving()) return true;
|
return ((CustomSX1276 *)_radio)->isReceiving();
|
||||||
|
|
||||||
idle(); // put into standby
|
|
||||||
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
|
||||||
bool activity = (((CustomSX1276 *)_radio)->tryScanChannel() == RADIOLIB_PREAMBLE_DETECTED);
|
|
||||||
if (activity) {
|
|
||||||
startRecv();
|
|
||||||
} else {
|
|
||||||
idle();
|
|
||||||
}
|
|
||||||
return activity;
|
|
||||||
}
|
}
|
||||||
float getLastRSSI() const override { return ((CustomSX1276 *)_radio)->getRSSI(); }
|
float getLastRSSI() const override { return ((CustomSX1276 *)_radio)->getRSSI(); }
|
||||||
float getLastSNR() const override { return ((CustomSX1276 *)_radio)->getSNR(); }
|
float getLastSNR() const override { return ((CustomSX1276 *)_radio)->getSNR(); }
|
||||||
|
|
|
||||||
|
|
@ -108,6 +108,18 @@ void RadioLibWrapper::onSendFinished() {
|
||||||
state = STATE_IDLE;
|
state = STATE_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool RadioLibWrapper::isChannelActive() {
|
||||||
|
idle(); // put sx126x into standby
|
||||||
|
// do some basic CAD (blocks for ~12780 micros (on SF 10)!)
|
||||||
|
bool activity = _radio->scanChannel() == RADIOLIB_LORA_DETECTED;
|
||||||
|
if (activity) {
|
||||||
|
startRecv();
|
||||||
|
} else {
|
||||||
|
idle();
|
||||||
|
}
|
||||||
|
return activity;
|
||||||
|
}
|
||||||
|
|
||||||
float RadioLibWrapper::getLastRSSI() const {
|
float RadioLibWrapper::getLastRSSI() const {
|
||||||
return _radio->getRSSI();
|
return _radio->getRSSI();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ protected:
|
||||||
void idle();
|
void idle();
|
||||||
void startRecv();
|
void startRecv();
|
||||||
float packetScoreInt(float snr, int sf, int packet_len);
|
float packetScoreInt(float snr, int sf, int packet_len);
|
||||||
|
virtual bool isReceivingPacket() =0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board) { n_recv = n_sent = 0; }
|
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board) { n_recv = n_sent = 0; }
|
||||||
|
|
@ -23,6 +24,13 @@ public:
|
||||||
bool isSendComplete() override;
|
bool isSendComplete() override;
|
||||||
void onSendFinished() override;
|
void onSendFinished() override;
|
||||||
bool isInRecvMode() const override;
|
bool isInRecvMode() const override;
|
||||||
|
bool isChannelActive();
|
||||||
|
|
||||||
|
bool isReceiving() override {
|
||||||
|
if (isReceivingPacket()) return true;
|
||||||
|
|
||||||
|
return isChannelActive();
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t getPacketsRecv() const { return n_recv; }
|
uint32_t getPacketsRecv() const { return n_recv; }
|
||||||
uint32_t getPacketsSent() const { return n_sent; }
|
uint32_t getPacketsSent() const { return n_sent; }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue