Add basic CSMAp logic

pull/15/head
sh123 2020-06-20 12:50:57 +03:00
rodzic c500f52775
commit 3a55d70cfb
2 zmienionych plików z 18 dodań i 9 usunięć

Wyświetl plik

@ -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);
}

Wyświetl plik

@ -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;