kopia lustrzana https://github.com/sh123/esp32_loraprs
Add WiFi connect max retries, so it won't completely block processing if WiFi is not available
rodzic
da50386616
commit
74acb404fa
|
@ -12,10 +12,6 @@ Service::Service()
|
|||
{
|
||||
}
|
||||
|
||||
Service::~Service() {
|
||||
delete txQueue_;
|
||||
}
|
||||
|
||||
void Service::setup(const Config &conf)
|
||||
{
|
||||
previousBeaconMs_ = 0;
|
||||
|
@ -74,9 +70,14 @@ void Service::setupWifi(const String &wifiName, const String &wifiKey)
|
|||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(wifiName.c_str(), wifiKey.c_str());
|
||||
|
||||
int retryCnt = 0;
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(CfgConnRetryMs);
|
||||
Serial.print(".");
|
||||
if (retryCnt++ >= CfgWiFiConnRetryMaxTimes) {
|
||||
Serial.println("failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
Serial.println("ok");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
@ -87,10 +88,15 @@ void Service::reconnectWifi()
|
|||
{
|
||||
Serial.print("WIFI re-connecting...");
|
||||
|
||||
int retryCnt = 0;
|
||||
while (WiFi.status() != WL_CONNECTED || WiFi.localIP() == IPAddress(0,0,0,0)) {
|
||||
WiFi.reconnect();
|
||||
delay(CfgConnRetryMs);
|
||||
Serial.print(".");
|
||||
if (retryCnt++ >= CfgWiFiConnRetryMaxTimes) {
|
||||
Serial.println("failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Serial.println("ok");
|
||||
|
@ -231,7 +237,7 @@ void Service::onAprsisDataAvailable()
|
|||
sendAX25ToLora(payload);
|
||||
}
|
||||
else {
|
||||
Serial.println("Invalid payload from APRSIS");
|
||||
Serial.println("Unknown payload from APRSIS, ignoring...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ class Service
|
|||
{
|
||||
public:
|
||||
Service();
|
||||
~Service();
|
||||
|
||||
void setup(const Config &conf);
|
||||
void loop();
|
||||
|
@ -77,6 +76,7 @@ private:
|
|||
const int CfgConnRetryMs = 500;
|
||||
const int CfgPollDelayMs = 5;
|
||||
const int CfgLoraTxQueueSize = 4096;
|
||||
const int CfgWiFiConnRetryMaxTimes = 10;
|
||||
|
||||
// tx when lower than this value from random 0..255
|
||||
// use lower value for high traffic, use 255 for real time
|
||||
|
@ -114,7 +114,7 @@ private:
|
|||
long previousBeaconMs_;
|
||||
byte csmaP_;
|
||||
long csmaSlotTime_;
|
||||
cppQueue *txQueue_;
|
||||
std::shared_ptr<cppQueue>txQueue_;
|
||||
|
||||
// peripherals
|
||||
BluetoothSerial serialBt_;
|
||||
|
|
Ładowanie…
Reference in New Issue