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

Re-work of the network manager #533

Merged
merged 33 commits into from
Mar 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ea13ea3
Attempt to fix weird WiFi connection issue (WIP)
jeremypoulter Jun 21, 2022
6785553
Merge branch 'master' into wifi_connection-issue
jeremypoulter Nov 5, 2022
694467a
Fix merge mistake
jeremypoulter Nov 5, 2022
8d16553
Initial rework to change update the network stack to a MicroTask
jeremypoulter Nov 12, 2022
c5778d9
Removed MicroTask debug
jeremypoulter Nov 12, 2022
3e263ee
Added network state management
jeremypoulter Jan 19, 2023
16248d0
A few bugfixes
jeremypoulter Jan 23, 2023
5447f06
Fixed setting the time
jeremypoulter Jan 29, 2023
5214caa
A few more bugfixes and tweaks
jeremypoulter Jan 29, 2023
95de203
Disable sleep
jeremypoulter Jan 29, 2023
12cfbff
Merge branch 'master' into wifi_connection-issue
jeremypoulter Jan 29, 2023
c8e4fe9
Use the latest Microtasks release with new features
jeremypoulter Jan 29, 2023
4854238
Merge branch 'master' into wifi_connection-issue
jeremypoulter Feb 21, 2023
ba7119e
Fix for starting up the the AP when already connected to a WiFi network
jeremypoulter Feb 21, 2023
9b903e6
restart mDNS when hostname has changed
KipK Feb 21, 2023
0d68d7b
Updated the WiFi Scanning code to block the web request while the sca…
jeremypoulter Feb 22, 2023
f47a7fe
Merge branch 'wifi_connection-issue' of https://github.com/jeremypoul…
KipK Feb 23, 2023
467e149
restart mDNS when hostname has changed
KipK Feb 21, 2023
b3a0aa0
removed static function , restart also _dnsServer
KipK Feb 23, 2023
6c9417b
Merge branch 'master' into wifi_connection-issue
jeremypoulter Feb 23, 2023
82847db
Fixed some issues starting the WiFi on an ESP32 Gateway with no ether…
jeremypoulter Feb 23, 2023
784d454
Merge branch 'master' into wifi_connection-issue
jeremypoulter Feb 23, 2023
e40ac2a
force wifi to connect to AP with best signal
KipK Feb 25, 2023
bd5b22b
fix setting in wrong function
KipK Feb 25, 2023
88b29df
remove dns restart
KipK Feb 25, 2023
12a5b5c
restart network stack at hostname change if no AP
KipK Feb 25, 2023
2e5e593
remove restart network task at hostname change
KipK Feb 25, 2023
f7b1009
fix Captive portal not showing in AP+STA mode
KipK Feb 25, 2023
4242971
use isWifiModeAp
KipK Feb 25, 2023
7968d38
Merge pull request #17 from KipK/wifi_connection-issue
jeremypoulter Feb 27, 2023
85cd826
fix compile
KipK Feb 27, 2023
3ee4a29
Merge branch 'wifi_connection-issue' of https://github.com/jeremypoul…
KipK Feb 27, 2023
0537e30
Merge pull request #20 from KipK/wifi_connection-issue
jeremypoulter Feb 27, 2023
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
11 changes: 5 additions & 6 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ lib_deps =
jeremypoulter/[email protected]
jeremypoulter/[email protected]
jeremypoulter/[email protected]
jeremypoulter/[email protected].2
jeremypoulter/[email protected].3
matth-x/[email protected]
matth-x/[email protected]
lib_ignore = WebSockets ; ArduinoOcpp: don't compile built-in WS library
Expand All @@ -60,6 +60,8 @@ debug_flags =
#-D ENABLE_DEBUG_TESLA_CLIENT
#-D ENABLE_DEBUG_LIMIT
#-D ENABLE_PROFILE
#-D ENABLE_NOISY_PROFILE
#-D ENABLE_DEBUG_MICROTASKS
src_build_flags =
# -D ARDUINOJSON_USE_LONG_LONG
# -D ENABLE_ASYNC_WIFI_SCAN
Expand Down Expand Up @@ -114,13 +116,13 @@ build_flags =
${common.build_flags}
#upload_port = openevse.local
upload_speed = 921600
monitor_speed = 115200
extra_scripts = ${common.extra_scripts}
board_build.partitions = ${common.build_partitions}
#platform_packages =
# ; use a special branch
# framework-arduinoespressif32 @ https://github.com/marcovannoord/arduino-esp32.git#idf-release/v4.0
# platformio/framework-arduinoespressif32 @ ~3.10006.0
monitor_speed = 115200
monitor_filters =
esp32_exception_decoder

Expand Down Expand Up @@ -248,7 +250,6 @@ build_flags =
-D DEBUG_PORT=Serial
-D RAPI_PORT=Serial2
-D ENABLE_WIRED_ETHERNET
-D RANDOM_SEED_CHANNEL=1
# https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFi/examples/ETH_LAN8720/ETH_LAN8720.ino

[env:openevse_esp32-gateway-f]
Expand All @@ -266,7 +267,7 @@ build_flags =
-D DEBUG_PORT=Serial
-D RAPI_PORT=Serial2
-D ENABLE_WIRED_ETHERNET
-D RANDOM_SEED_CHANNEL=1
-D RESET_ETH_PHY_ON_BOOT=1
-D RX2=16
-D TX2=32
board_build.extra_flags = "-DARDUINO_ESP32_GATEWAY=\'F\'"
Expand All @@ -278,7 +279,6 @@ upload_speed = 921600
extends = env:openevse_esp32-gateway-f
build_flags =
${env:openevse_esp32-gateway-f.build_flags}
-D RESET_ETH_PHY_ON_BOOT=1
board_build.extra_flags = "-DARDUINO_ESP32_GATEWAY=\'E\'"

[env:openevse_esp32-gateway-e_dev]
Expand Down Expand Up @@ -309,7 +309,6 @@ build_flags =
-D DEBUG_PORT=Serial
-D RAPI_PORT=Serial2
-D ENABLE_WIRED_ETHERNET
-D RANDOM_SEED_CHANNEL=1
-D RESET_ETH_PHY_ON_BOOT=1
upload_speed = 921600

Expand Down
4 changes: 4 additions & 0 deletions src/app_config.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "emonesp.h"
#include "espal.h"
#include "divert.h"
#include "net_manager.h"
#include "mqtt.h"
#include "ocpp.h"
#include "tesla_client.h"
Expand Down Expand Up @@ -393,3 +394,6 @@ config_reset() {
LittleFS.format();
config_load_settings();
}



16 changes: 10 additions & 6 deletions src/emonesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
#endif

#ifndef WIFI_CLIENT_RETRY_TIMEOUT
#define WIFI_CLIENT_RETRY_TIMEOUT (5 * 60 * 1000)
#define WIFI_CLIENT_RETRY_TIMEOUT (10 * 1000)
#endif

#ifndef WIFI_CLIENT_DISCONNECTS_BEFORE_AP
Expand All @@ -61,11 +61,15 @@
// Used to change the ADC channel used for seeding the rndom number generator
// Should be set to an unconnected pin
#ifndef RANDOM_SEED_CHANNEL
#if WIFI_BUTTON != 0 && (!defined(WIFI_LED) || WIFI_LED != 0)
#define RANDOM_SEED_CHANNEL 0
#else
#define RANDOM_SEED_CHANNEL 1
#endif
#ifdef ESP32
#define RANDOM_SEED_CHANNEL 14
#else
#if WIFI_BUTTON != 0 && (!defined(WIFI_LED) || WIFI_LED != 0)
#define RANDOM_SEED_CHANNEL 0
#else
#define RANDOM_SEED_CHANNEL 1
#endif
#endif
#endif

#ifndef HAL_ID_ENCODING_BASE
Expand Down
4 changes: 2 additions & 2 deletions src/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,10 @@ void input_setup()
{
case OPENEVSE_WIFI_MODE_AP:
case OPENEVSE_WIFI_MODE_AP_DEFAULT:
net_wifi_turn_on_ap();
net.wifiTurnOnAp();
break;
case OPENEVSE_WIFI_MODE_CLIENT:
net_wifi_turn_off_ap();
net.wifiTurnOffAp();
break;
}
});
Expand Down
11 changes: 6 additions & 5 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ Scheduler scheduler(evse);
ManualOverride manual(evse);
DivertTask divert(evse);

NetManagerTask net(lcd, ledManager, timeManager);

RapiSender &rapiSender = evse.getSender();

unsigned long Timer1; // Timer for events once every 30 seconds
Expand Down Expand Up @@ -137,7 +139,7 @@ void setup()
ledManager.begin(evse);

// Initialise the WiFi
net_setup();
net.begin();
DBUGF("After net_setup: %d", ESPAL.getFreeHeap());

// Initialise Mongoose networking library
Expand Down Expand Up @@ -177,7 +179,6 @@ loop() {
Profile_End(Mongoose, 10);

web_server_loop();
net_loop();
ota_loop();
rapiSender.loop();

Expand Down Expand Up @@ -216,7 +217,7 @@ loop() {
}
}

if(net_is_connected())
if(net.isConnected())
{
if (config_tesla_enabled()) {
teslaClient.loop();
Expand Down Expand Up @@ -288,7 +289,7 @@ class SystemRestart : public MicroTasks::Alarm
void Trigger()
{
DBUGLN("Restarting...");
net_wifi_disconnect();
net.wifiStop();
ESPAL.reset();
}
} systemRestartAlarm;
Expand Down Expand Up @@ -336,4 +337,4 @@ void handle_serial()
DEBUG_PORT.printf("{\"code\":200,\"msg\":\"%s\"}\n", config_modified ? "done" : "no change");
}
}
}
}
2 changes: 1 addition & 1 deletion src/mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ mqtt_connect()
doc["id"] = ESPAL.getLongId();
doc["name"] = esp_hostname;
doc["mqtt"] = mqtt_topic;
doc["http"] = "http://"+ipaddress+"/";
doc["http"] = "http://"+net.getIp()+"/";

// Once connected, publish an announcement..
String announce = "";
Expand Down
Loading