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()
|
||||
{
|
||||
long r = random(0, 255);
|
||||
|
||||
if (needsWifi() && WiFi.status() != WL_CONNECTED) {
|
||||
reconnectWifi();
|
||||
}
|
||||
if (needsAprsis() && !aprsisConn_.connected() && persistentConn_) {
|
||||
reconnectAprsis();
|
||||
}
|
||||
if (aprsisConn_.available() > 0) {
|
||||
onAprsisDataAvailable();
|
||||
}
|
||||
if (serialBt_.available()) {
|
||||
onBtDataAvailable();
|
||||
}
|
||||
if (int packetSize = LoRa.parsePacket()) {
|
||||
onLoraDataAvailable(packetSize);
|
||||
}
|
||||
if (needsBeacon()) {
|
||||
sendPeriodicBeacon();
|
||||
else if (random(0, 255) < CfgCsmaProbBoundary) {
|
||||
if (serialBt_.available()) {
|
||||
onBtDataAvailable();
|
||||
}
|
||||
if (aprsisConn_.available() > 0) {
|
||||
onAprsisDataAvailable();
|
||||
}
|
||||
if (needsBeacon()) {
|
||||
sendPeriodicBeacon();
|
||||
}
|
||||
}
|
||||
delay(CfgPollDelayMs);
|
||||
}
|
||||
|
|
|
@ -65,7 +65,12 @@ private:
|
|||
};
|
||||
|
||||
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 CfgPinRst = 26;
|
||||
|
|
Ładowanie…
Reference in New Issue