Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32/network fixes #2325

Merged
merged 6 commits into from
May 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192

# Mandatory Sming framework changes
CONFIG_ESP_TIMER_TASK_STACK_SIZE=8192
CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192

# The bootloader logs all type of messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000
CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=8192

# Mandatory Sming framework changes
CONFIG_ESP_TIMER_TASK_STACK_SIZE=8192
CONFIG_ESP_TIMER_TASK_STACK_SIZE=16384
CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=8192

# The bootloader logs only errors
Expand Down
29 changes: 20 additions & 9 deletions Sming/Components/Network/Arch/Esp32/Platform/AccessPointImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,31 +95,42 @@ bool AccessPointImpl::config(const String& ssid, String password, WifiAuthMode m

IpAddress AccessPointImpl::getIP() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(apNetworkInterface, &info));
return info.ip.addr;
if(esp_netif_get_ip_info(apNetworkInterface, &info) == ESP_OK) {
addr = info.ip.addr;
}
return addr;
}

IpAddress AccessPointImpl::getNetworkBroadcast() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(apNetworkInterface, &info));
return info.ip.addr | ~info.netmask.addr;
if(esp_netif_get_ip_info(apNetworkInterface, &info) == ESP_OK) {
addr = info.ip.addr | ~info.netmask.addr;
}
return addr;
}

IpAddress AccessPointImpl::getNetworkMask() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(apNetworkInterface, &info));
return info.netmask.addr;
if(esp_netif_get_ip_info(apNetworkInterface, &info) == ESP_OK) {
addr = info.netmask.addr;
}
return addr;
}

IpAddress AccessPointImpl::getNetworkGateway() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(apNetworkInterface, &info));

return info.gw.addr;
if(esp_netif_get_ip_info(apNetworkInterface, &info) == ESP_OK) {
addr = info.gw.addr;
}
return addr;
}

bool AccessPointImpl::setIP(IpAddress address)
Expand Down
21 changes: 15 additions & 6 deletions Sming/Components/Network/Arch/Esp32/Platform/StationImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,23 +193,32 @@ bool StationImpl::setMacAddress(const MacAddress& addr) const

IpAddress StationImpl::getNetworkBroadcast() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(stationNetworkInterface, &info));
return info.ip.addr | ~info.netmask.addr;
if(esp_netif_get_ip_info(stationNetworkInterface, &info) == ESP_OK) {
addr = info.ip.addr | ~info.netmask.addr;
}
return addr;
}

IpAddress StationImpl::getNetworkMask() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(stationNetworkInterface, &info));
return info.netmask.addr;
if(esp_netif_get_ip_info(stationNetworkInterface, &info) == ESP_OK) {
addr = info.netmask.addr;
}
return addr;
}

IpAddress StationImpl::getNetworkGateway() const
{
IpAddress addr;
esp_netif_ip_info_t info;
ESP_ERROR_CHECK(esp_netif_get_ip_info(stationNetworkInterface, &info));
return info.gw.addr;
if(esp_netif_get_ip_info(stationNetworkInterface, &info) == ESP_OK) {
addr = info.gw.addr;
}
return addr;
}

bool StationImpl::setIP(IpAddress address, IpAddress netmask, IpAddress gateway)
Expand Down
4 changes: 2 additions & 2 deletions Sming/Components/Network/src/Network/HttpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include "Data/Stream/FileStream.h"

HttpClient::HttpConnectionPool HttpClient::httpConnectionPool;
Timer HttpClient::cleanUpTimer;
SimpleTimer HttpClient::cleanUpTimer;

bool HttpClient::send(HttpRequest* request)
{
Expand All @@ -41,7 +41,7 @@ bool HttpClient::send(HttpRequest* request)
}

if(!cleanUpTimer.isStarted()) {
cleanUpTimer.initializeMs<60000>(&HttpClient::cleanInactive).start(); // run every minute
cleanUpTimer.initializeMs<60000>(HttpClient::cleanInactive).start(); // run every minute
}
return connection->send(request);
}
Expand Down
4 changes: 2 additions & 2 deletions Sming/Components/Network/src/Network/HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "Http/HttpRequest.h"
#include "Http/HttpClientConnection.h"
#include "Data/Stream/LimitedMemoryStream.h"
#include <Timer.h>
#include <SimpleTimer.h>

class HttpClient
{
Expand Down Expand Up @@ -145,7 +145,7 @@ class HttpClient
static HttpConnectionPool httpConnectionPool;

private:
static Timer cleanUpTimer;
static SimpleTimer cleanUpTimer;
static void cleanInactive();
};

Expand Down
2 changes: 1 addition & 1 deletion Sming/Components/ssl/src/Session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ String Options::toString() const
if(field) { \
if(s) { \
s += ", "; \
s += _F(#field); \
} \
s += _F(#field); \
}

ADD(sessionResume);
Expand Down
2 changes: 1 addition & 1 deletion samples/Basic_IFS/basic_ifs_Esp32.hw
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"base_config": "basic_ifs",
"arch": "Esp32",
"partitions": {
"rom0": {
"factory": {
"size": "960K"
}
}
Expand Down
2 changes: 1 addition & 1 deletion samples/Basic_WebSkeletonApp/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void init()
WifiEvents.onStationDisconnect(STADisconnect);
WifiEvents.onStationGotIP(STAGotIP);

startWebServer();
System.onReady(startWebServer);

counterTimer.initializeMs(1000, counterLoop).start();
}
2 changes: 1 addition & 1 deletion samples/Basic_WebSkeletonApp_LTS/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void init()
WifiEvents.onStationDisconnect(STADisconnect);
WifiEvents.onStationGotIP(STAGotIP);

startWebServer();
System.onReady(startWebServer);

counterTimer.initializeMs(1000, counterLoop).start();
}
Expand Down