mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-08 05:31:25 +00:00
RAK13800 Ethernet improvements
Fixes (#3618) by allowing more time for slower requests. Resolve Syslog not maintaining client causing issues on RAK13800. Resolve Ethernet static IP setting subnet as gateway IP. Reduce comment and log message ambiguity around API. Remove duplicate #if !MESHTASTIC_EXCLUDE_WEBSERVER block.
This commit is contained in:
parent
26a3841a93
commit
d72a836e07
@ -97,12 +97,14 @@ Syslog &Syslog::logMask(uint8_t priMask)
|
|||||||
|
|
||||||
void Syslog::enable()
|
void Syslog::enable()
|
||||||
{
|
{
|
||||||
|
this->_client->begin(this->_port);
|
||||||
this->_enabled = true;
|
this->_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Syslog::disable()
|
void Syslog::disable()
|
||||||
{
|
{
|
||||||
this->_enabled = false;
|
this->_enabled = false;
|
||||||
|
this->_client->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Syslog::isEnabled()
|
bool Syslog::isEnabled()
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
ServerAPI<T>::ServerAPI(T &_client) : StreamAPI(&client), concurrency::OSThread("ServerAPI"), client(_client)
|
ServerAPI<T>::ServerAPI(T &_client) : StreamAPI(&client), concurrency::OSThread("ServerAPI"), client(_client)
|
||||||
{
|
{
|
||||||
LOG_INFO("Incoming wifi connection\n");
|
LOG_INFO("Incoming API connection\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T> ServerAPI<T>::~ServerAPI()
|
template <typename T> ServerAPI<T>::~ServerAPI()
|
||||||
@ -49,6 +49,16 @@ template <class T, class U> int32_t APIServerPort<T, U>::runOnce()
|
|||||||
if (client) {
|
if (client) {
|
||||||
// Close any previous connection (see FIXME in header file)
|
// Close any previous connection (see FIXME in header file)
|
||||||
if (openAPI) {
|
if (openAPI) {
|
||||||
|
#if RAK_4631
|
||||||
|
// RAK13800 Ethernet requests periodically take more time
|
||||||
|
// This backoff addresses most cases keeping max wait < 1s
|
||||||
|
// Reconnections are delayed by full wait time
|
||||||
|
if (waitTime < 400) {
|
||||||
|
waitTime *= 2;
|
||||||
|
LOG_INFO("Previous TCP connection still open, trying again in %dms\n", waitTime);
|
||||||
|
return waitTime;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
LOG_INFO("Force closing previous TCP connection\n");
|
LOG_INFO("Force closing previous TCP connection\n");
|
||||||
delete openAPI;
|
delete openAPI;
|
||||||
}
|
}
|
||||||
@ -56,5 +66,8 @@ template <class T, class U> int32_t APIServerPort<T, U>::runOnce()
|
|||||||
openAPI = new T(client);
|
openAPI = new T(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if RAK_4631
|
||||||
|
waitTime = 100;
|
||||||
|
#endif
|
||||||
return 100; // only check occasionally for incoming connections
|
return 100; // only check occasionally for incoming connections
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ template <class T> class ServerAPI : public StreamAPI, private concurrency::OSTh
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens for incoming connections and does accepts and creates instances of WiFiServerAPI as needed
|
* Listens for incoming connections and does accepts and creates instances of ServerAPI as needed
|
||||||
*/
|
*/
|
||||||
template <class T, class U> class APIServerPort : public U, private concurrency::OSThread
|
template <class T, class U> class APIServerPort : public U, private concurrency::OSThread
|
||||||
{
|
{
|
||||||
@ -41,6 +41,10 @@ template <class T, class U> class APIServerPort : public U, private concurrency:
|
|||||||
* delegate to the worker. Once coroutines are implemented we can relax this restriction.
|
* delegate to the worker. Once coroutines are implemented we can relax this restriction.
|
||||||
*/
|
*/
|
||||||
T *openAPI = NULL;
|
T *openAPI = NULL;
|
||||||
|
#if RAK_4631
|
||||||
|
// Track wait time for RAK13800 Ethernet requests
|
||||||
|
int32_t waitTime = 100;
|
||||||
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit APIServerPort(int port);
|
explicit APIServerPort(int port);
|
||||||
|
@ -14,7 +14,7 @@ class ethServerAPI : public ServerAPI<EthernetClient>
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listens for incoming connections and does accepts and creates instances of WiFiServerAPI as needed
|
* Listens for incoming connections and does accepts and creates instances of EthernetServerAPI as needed
|
||||||
*/
|
*/
|
||||||
class ethServerPort : public APIServerPort<ethServerAPI, EthernetServer>
|
class ethServerPort : public APIServerPort<ethServerAPI, EthernetServer>
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ static int32_t reconnectETH()
|
|||||||
Ethernet.maintain();
|
Ethernet.maintain();
|
||||||
if (!ethStartupComplete) {
|
if (!ethStartupComplete) {
|
||||||
// Start web server
|
// Start web server
|
||||||
LOG_INFO("... Starting network services\n");
|
LOG_INFO("Starting Ethernet network services\n");
|
||||||
|
|
||||||
#ifndef DISABLE_NTP
|
#ifndef DISABLE_NTP
|
||||||
LOG_INFO("Starting NTP time client\n");
|
LOG_INFO("Starting NTP time client\n");
|
||||||
@ -131,7 +131,8 @@ bool initEthernet()
|
|||||||
status = Ethernet.begin(mac);
|
status = Ethernet.begin(mac);
|
||||||
} else if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC) {
|
} else if (config.network.address_mode == meshtastic_Config_NetworkConfig_AddressMode_STATIC) {
|
||||||
LOG_INFO("starting Ethernet Static\n");
|
LOG_INFO("starting Ethernet Static\n");
|
||||||
Ethernet.begin(mac, config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.subnet);
|
Ethernet.begin(mac, config.network.ipv4_config.ip, config.network.ipv4_config.dns, config.network.ipv4_config.gateway,
|
||||||
|
config.network.ipv4_config.subnet);
|
||||||
status = 1;
|
status = 1;
|
||||||
} else {
|
} else {
|
||||||
LOG_INFO("Ethernet Disabled\n");
|
LOG_INFO("Ethernet Disabled\n");
|
||||||
|
@ -15,10 +15,8 @@
|
|||||||
#include <WiFiUdp.h>
|
#include <WiFiUdp.h>
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
||||||
#if !MESHTASTIC_EXCLUDE_WEBSERVER
|
|
||||||
#include "mesh/http/WebServer.h"
|
#include "mesh/http/WebServer.h"
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
#include <ESPmDNS.h>
|
#include <ESPmDNS.h>
|
||||||
#include <esp_wifi.h>
|
#include <esp_wifi.h>
|
||||||
static void WiFiEvent(WiFiEvent_t event);
|
static void WiFiEvent(WiFiEvent_t event);
|
||||||
@ -58,7 +56,7 @@ static void onNetworkConnected()
|
|||||||
{
|
{
|
||||||
if (!APStartupComplete) {
|
if (!APStartupComplete) {
|
||||||
// Start web server
|
// Start web server
|
||||||
LOG_INFO("Starting network services\n");
|
LOG_INFO("Starting WiFi network services\n");
|
||||||
|
|
||||||
#ifdef ARCH_ESP32
|
#ifdef ARCH_ESP32
|
||||||
// start mdns
|
// start mdns
|
||||||
|
Loading…
Reference in New Issue
Block a user