kopia lustrzana https://github.com/sh123/esp32_loraprs
Add basic CSMAp logic
rodzic
c500f52775
commit
3a55d70cfb
|
@ -137,23 +137,27 @@ void Service::setupBt(const String &btName)
|
||||||
|
|
||||||
void Service::loop()
|
void Service::loop()
|
||||||
{
|
{
|
||||||
|
long r = random(0, 255);
|
||||||
|
|
||||||
if (needsWifi() && WiFi.status() != WL_CONNECTED) {
|
if (needsWifi() && WiFi.status() != WL_CONNECTED) {
|
||||||
reconnectWifi();
|
reconnectWifi();
|
||||||
}
|
}
|
||||||
if (needsAprsis() && !aprsisConn_.connected() && persistentConn_) {
|
if (needsAprsis() && !aprsisConn_.connected() && persistentConn_) {
|
||||||
reconnectAprsis();
|
reconnectAprsis();
|
||||||
}
|
}
|
||||||
if (aprsisConn_.available() > 0) {
|
|
||||||
onAprsisDataAvailable();
|
|
||||||
}
|
|
||||||
if (serialBt_.available()) {
|
|
||||||
onBtDataAvailable();
|
|
||||||
}
|
|
||||||
if (int packetSize = LoRa.parsePacket()) {
|
if (int packetSize = LoRa.parsePacket()) {
|
||||||
onLoraDataAvailable(packetSize);
|
onLoraDataAvailable(packetSize);
|
||||||
}
|
}
|
||||||
if (needsBeacon()) {
|
else if (random(0, 255) < CfgCsmaProbBoundary) {
|
||||||
sendPeriodicBeacon();
|
if (serialBt_.available()) {
|
||||||
|
onBtDataAvailable();
|
||||||
|
}
|
||||||
|
if (aprsisConn_.available() > 0) {
|
||||||
|
onAprsisDataAvailable();
|
||||||
|
}
|
||||||
|
if (needsBeacon()) {
|
||||||
|
sendPeriodicBeacon();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
delay(CfgPollDelayMs);
|
delay(CfgPollDelayMs);
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,12 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
const String CfgLoraprsVersion = "LoRAPRS 0.1";
|
const String CfgLoraprsVersion = "LoRAPRS 0.1";
|
||||||
const int CfgPollDelayMs = 10;
|
|
||||||
|
// tune depending on TOA, higher value for higher time on air
|
||||||
|
const int CfgPollDelayMs = 500;
|
||||||
|
|
||||||
|
// tx when lower than this value from random 0..255, use lower value for high traffic
|
||||||
|
const long CfgCsmaProbBoundary = 100;
|
||||||
|
|
||||||
const byte CfgPinSs = 5;
|
const byte CfgPinSs = 5;
|
||||||
const byte CfgPinRst = 26;
|
const byte CfgPinRst = 26;
|
||||||
|
|
Ładowanie…
Reference in New Issue