Browse Source

0.8.98

* fix Ethernet
* modified wizard
* fix github compile?
pull/1549/head
lumapu 10 months ago
parent
commit
92231672e8
  1. 6
      src/app.h
  2. 2
      src/config/config.h
  3. 12
      src/config/settings.h
  4. 17
      src/network/AhoyEthernet.h
  5. 17
      src/network/AhoyEthernetSpi.h
  6. 47
      src/network/AhoyNetwork.h
  7. 2
      src/network/AhoyNetworkHelper.h
  8. 32
      src/network/AhoyWifiEsp32.h
  9. 43
      src/network/AhoyWifiEsp8266.h
  10. 55
      src/platformio.ini
  11. 18
      src/web/RestApi.h
  12. 8
      src/web/html/setup.html
  13. 212
      src/web/html/wizard.html
  14. 35
      src/web/lang.json
  15. 4
      src/web/web.h

6
src/app.h

@ -184,7 +184,11 @@ class app : public IApp, public ah::Scheduler {
}*/ }*/
bool getWasInCh12to14(void) const override { bool getWasInCh12to14(void) const override {
return false; // @todo mWifi.getWasInCh12to14(); #if defined(ESP8266)
return mNetwork->getWasInCh12to14();
#else
return false;
#endif
} }
#endif /* !defined(ETHERNET) */ #endif /* !defined(ETHERNET) */

2
src/config/config.h

@ -78,7 +78,7 @@
#define DEF_ETH_CS_PIN 15 #define DEF_ETH_CS_PIN 15
#endif #endif
#ifndef DEF_ETH_RST_PIN #ifndef DEF_ETH_RST_PIN
#define DEF_ETH_RST_PIN 2 #define DEF_ETH_RST_PIN DEF_PIN_OFF
#endif #endif
#else /* defined(ETHERNET) */ #else /* defined(ETHERNET) */
// time in seconds how long the station info (ssid + pwd) will be tried // time in seconds how long the station info (ssid + pwd) will be tried

12
src/config/settings.h

@ -405,13 +405,17 @@ class settings {
else { else {
snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID); snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID);
snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD); snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD);
snprintf(mCfg.sys.apPwd, PWD_LEN, WIFI_AP_PWD);
mCfg.sys.isHidden = false; mCfg.sys.isHidden = false;
} }
#endif #endif
snprintf(mCfg.sys.apPwd, PWD_LEN, WIFI_AP_PWD);
#if defined(ETHERNET) #if defined(ETHERNET)
mCfg.sys.eth.enabled = false; #if defined(DEF_ETH_ENABLED)
mCfg.sys.eth.enabled = true;
#else
mCfg.sys.eth.enabled = false;
#endif
mCfg.sys.eth.pinCs = DEF_ETH_CS_PIN; mCfg.sys.eth.pinCs = DEF_ETH_CS_PIN;
mCfg.sys.eth.pinSclk = DEF_ETH_SCK_PIN; mCfg.sys.eth.pinSclk = DEF_ETH_SCK_PIN;
mCfg.sys.eth.pinMiso = DEF_ETH_MISO_PIN; mCfg.sys.eth.pinMiso = DEF_ETH_MISO_PIN;
@ -431,7 +435,11 @@ class settings {
mCfg.nrf.pinMosi = DEF_NRF_MOSI_PIN; mCfg.nrf.pinMosi = DEF_NRF_MOSI_PIN;
mCfg.nrf.pinSclk = DEF_NRF_SCLK_PIN; mCfg.nrf.pinSclk = DEF_NRF_SCLK_PIN;
#if defined(ETHERNET)
mCfg.nrf.enabled = false;
#else
mCfg.nrf.enabled = true; mCfg.nrf.enabled = true;
#endif
#if defined(ESP32) #if defined(ESP32)
mCfg.cmt.pinSclk = DEF_CMT_SCLK; mCfg.cmt.pinSclk = DEF_CMT_SCLK;

17
src/network/AhoyEthernet.h

@ -18,12 +18,16 @@ class AhoyEthernet : public AhoyNetwork {
void begin() override { void begin() override {
mAp.enable(); mAp.enable();
if(!mConfig->sys.eth.enabled)
return;
mEthSpi.begin(mConfig->sys.eth.pinMiso, mConfig->sys.eth.pinMosi, mConfig->sys.eth.pinSclk, mConfig->sys.eth.pinCs, mConfig->sys.eth.pinIrq, mConfig->sys.eth.pinRst);
ETH.setHostname(mConfig->sys.deviceName);
// static IP // static IP
setupIp([this](IPAddress ip, IPAddress gateway, IPAddress mask, IPAddress dns1, IPAddress dns2) -> bool { setupIp([this](IPAddress ip, IPAddress gateway, IPAddress mask, IPAddress dns1, IPAddress dns2) -> bool {
return ETH.config(ip, gateway, mask, dns1, dns2); return ETH.config(ip, gateway, mask, dns1, dns2);
}); });
ETH.setHostname(mConfig->sys.deviceName);
} }
void tickNetworkLoop() override { void tickNetworkLoop() override {
@ -43,9 +47,8 @@ class AhoyEthernet : public AhoyNetwork {
break; break;
case NetworkState::GOT_IP: case NetworkState::GOT_IP:
mAp.disable();
if(!mConnected) { if(!mConnected) {
mAp.disable();
mConnected = true; mConnected = true;
ah::welcome(ETH.localIP().toString(), F("Station")); ah::welcome(ETH.localIP().toString(), F("Station"));
MDNS.begin(mConfig->sys.deviceName); MDNS.begin(mConfig->sys.deviceName);
@ -59,10 +62,8 @@ class AhoyEthernet : public AhoyNetwork {
return ETH.localIP().toString(); return ETH.localIP().toString();
} }
void scanAvailNetworks(void) override {}; private:
bool getAvailNetworks(JsonObject obj) override { AhoyEthernetSpi mEthSpi;
return false;
}
}; };
#endif /*ETHERNET*/ #endif /*ETHERNET*/

17
src/network/AhoyEthernetSpi.h

@ -26,9 +26,11 @@ class AhoyEthernetSpi {
eth_netif(nullptr) {} eth_netif(nullptr) {}
void begin(int8_t pin_miso, int8_t pin_mosi, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst) { void begin(int8_t pin_miso, int8_t pin_mosi, int8_t pin_sclk, int8_t pin_cs, int8_t pin_int, int8_t pin_rst) {
gpio_reset_pin(static_cast<gpio_num_t>(pin_rst)); if(-1 != pin_rst) {
gpio_set_direction(static_cast<gpio_num_t>(pin_rst), GPIO_MODE_OUTPUT); gpio_reset_pin(static_cast<gpio_num_t>(pin_rst));
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 0); gpio_set_direction(static_cast<gpio_num_t>(pin_rst), GPIO_MODE_OUTPUT);
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 0);
}
gpio_reset_pin(static_cast<gpio_num_t>(pin_sclk)); gpio_reset_pin(static_cast<gpio_num_t>(pin_sclk));
gpio_reset_pin(static_cast<gpio_num_t>(pin_mosi)); gpio_reset_pin(static_cast<gpio_num_t>(pin_mosi));
@ -42,6 +44,7 @@ class AhoyEthernetSpi {
gpio_reset_pin(static_cast<gpio_num_t>(pin_int)); gpio_reset_pin(static_cast<gpio_num_t>(pin_int));
gpio_set_pull_mode(static_cast<gpio_num_t>(pin_int), GPIO_PULLUP_ONLY); gpio_set_pull_mode(static_cast<gpio_num_t>(pin_int), GPIO_PULLUP_ONLY);
spi_bus_config_t buscfg = { spi_bus_config_t buscfg = {
.mosi_io_num = pin_mosi, .mosi_io_num = pin_mosi,
.miso_io_num = pin_miso, .miso_io_num = pin_miso,
@ -80,9 +83,11 @@ class AhoyEthernetSpi {
ESP_ERROR_CHECK(spi_bus_add_device(SPI3_HOST, &devcfg, &spi)); ESP_ERROR_CHECK(spi_bus_add_device(SPI3_HOST, &devcfg, &spi));
// Reset sequence // Reset sequence
delayMicroseconds(500); if(-1 != pin_rst) {
gpio_set_level(static_cast<gpio_num_t>(pin_rst), 1); delayMicroseconds(500);
delayMicroseconds(1000); gpio_set_level(static_cast<gpio_num_t>(pin_rst), 1);
delayMicroseconds(1000);
}
// Arduino function to start networking stack if not already started // Arduino function to start networking stack if not already started
tcpipInit(); tcpipInit();

47
src/network/AhoyNetwork.h

@ -80,8 +80,39 @@ class AhoyNetwork {
virtual void begin() = 0; virtual void begin() = 0;
virtual void tickNetworkLoop() = 0; virtual void tickNetworkLoop() = 0;
virtual String getIp(void) = 0; virtual String getIp(void) = 0;
virtual void scanAvailNetworks(void) = 0;
virtual bool getAvailNetworks(JsonObject obj) = 0; virtual bool getWasInCh12to14() {
return false;
}
#if !defined(ETHERNET)
void scanAvailNetworks(void) {
if(!mScanActive) {
mScanActive = true;
WiFi.scanNetworks(true);
}
}
bool getAvailNetworks(JsonObject obj) {
JsonArray nets = obj.createNestedArray(F("networks"));
int n = WiFi.scanComplete();
if (n < 0)
return false;
if(n > 0) {
int sort[n];
sortRSSI(&sort[0], n);
for (int i = 0; i < n; ++i) {
nets[i][F("ssid")] = WiFi.SSID(sort[i]);
nets[i][F("rssi")] = WiFi.RSSI(sort[i]);
}
}
mScanActive = false;
WiFi.scanDelete();
return true;
}
#endif
protected: protected:
void setupIp(std::function<bool(IPAddress ip, IPAddress gateway, IPAddress mask, IPAddress dns1, IPAddress dns2)> cb) { void setupIp(std::function<bool(IPAddress ip, IPAddress gateway, IPAddress mask, IPAddress dns1, IPAddress dns2)> cb) {
@ -169,6 +200,17 @@ class AhoyNetwork {
mUdp.close(); mUdp.close();
} }
#if !defined(ETHERNET)
void sortRSSI(int *sort, int n) {
for (int i = 0; i < n; i++)
sort[i] = i;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i]))
std::swap(sort[i], sort[j]);
}
#endif
protected: protected:
enum class NetworkState : uint8_t { enum class NetworkState : uint8_t {
DISCONNECTED, DISCONNECTED,
@ -182,6 +224,7 @@ class AhoyNetwork {
settings_t *mConfig = nullptr; settings_t *mConfig = nullptr;
uint32_t *mUtcTimestamp = nullptr; uint32_t *mUtcTimestamp = nullptr;
bool mConnected = false; bool mConnected = false;
bool mScanActive = false;
OnNetworkCB mOnNetworkCB; OnNetworkCB mOnNetworkCB;
OnTimeCB mOnTimeCB; OnTimeCB mOnTimeCB;

2
src/network/AhoyNetworkHelper.h

@ -9,7 +9,7 @@
#include "../utils/dbg.h" #include "../utils/dbg.h"
#include <Arduino.h> #include <Arduino.h>
#if defined(ESP32) #if defined(ESP32)
#include <WiFi.h> #include "ESPAsyncWebServer.h"
#include <WiFiType.h> #include <WiFiType.h>
#include <ESPmDNS.h> #include <ESPmDNS.h>
#else #else

32
src/network/AhoyWifiEsp32.h

@ -9,8 +9,8 @@
#if defined(ESP32) && !defined(ETHERNET) #if defined(ESP32) && !defined(ETHERNET)
#include <functional> #include <functional>
#include <AsyncUDP.h> #include <AsyncUDP.h>
#include <Wifi.h>
#include "AhoyNetwork.h" #include "AhoyNetwork.h"
#include "ESPAsyncWebServer.h"
class AhoyWifi : public AhoyNetwork { class AhoyWifi : public AhoyNetwork {
public: public:
@ -69,33 +69,6 @@ class AhoyWifi : public AhoyNetwork {
return WiFi.localIP().toString(); return WiFi.localIP().toString();
} }
void scanAvailNetworks(void) override {
if(!mScanActive) {
mScanActive = true;
WiFi.scanNetworks(true);
}
}
bool getAvailNetworks(JsonObject obj) override {
JsonArray nets = obj.createNestedArray(F("networks"));
int n = WiFi.scanComplete();
if (n < 0)
return false;
if(n > 0) {
int sort[n];
sortRSSI(&sort[0], n);
for (int i = 0; i < n; ++i) {
nets[i][F("ssid")] = WiFi.SSID(sort[i]);
nets[i][F("rssi")] = WiFi.RSSI(sort[i]);
}
}
mScanActive = false;
WiFi.scanDelete();
return true;
}
private: private:
void sortRSSI(int *sort, int n) { void sortRSSI(int *sort, int n) {
for (int i = 0; i < n; i++) for (int i = 0; i < n; i++)
@ -105,9 +78,6 @@ class AhoyWifi : public AhoyNetwork {
if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i])) if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i]))
std::swap(sort[i], sort[j]); std::swap(sort[i], sort[j]);
} }
private:
bool mScanActive = false;
}; };
#endif /*ESP32 & !ETHERNET*/ #endif /*ESP32 & !ETHERNET*/

43
src/network/AhoyWifiEsp8266.h

@ -74,7 +74,6 @@ class AhoyWifi : public AhoyNetwork {
DBGPRINT(" " + String(bssid[j], HEX)); DBGPRINT(" " + String(bssid[j], HEX));
} }
DBGPRINTLN(""); DBGPRINTLN("");
mGotDisconnect = false;
WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, 0, &bssid[0]); WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, 0, &bssid[0]);
break; break;
@ -96,6 +95,9 @@ class AhoyWifi : public AhoyNetwork {
MDNS.begin(mConfig->sys.deviceName); MDNS.begin(mConfig->sys.deviceName);
mOnNetworkCB(true); mOnNetworkCB(true);
} }
if(WiFi.channel() > 11)
mWasInCh12to14 = true;
break; break;
} }
} }
@ -104,43 +106,11 @@ class AhoyWifi : public AhoyNetwork {
return WiFi.localIP().toString(); return WiFi.localIP().toString();
} }
void scanAvailNetworks(void) override { bool getWasInCh12to14() override {
if(!mScanActive) { return mWasInCh12to14;
mScanActive = true;
WiFi.scanNetworks(true);
}
}
bool getAvailNetworks(JsonObject obj) override {
JsonArray nets = obj.createNestedArray(F("networks"));
int n = WiFi.scanComplete();
if (n < 0)
return false;
if(n > 0) {
int sort[n];
sortRSSI(&sort[0], n);
for (int i = 0; i < n; ++i) {
nets[i][F("ssid")] = WiFi.SSID(sort[i]);
nets[i][F("rssi")] = WiFi.RSSI(sort[i]);
}
}
mScanActive = false;
WiFi.scanDelete();
return true;
} }
private: private:
void sortRSSI(int *sort, int n) {
for (int i = 0; i < n; i++)
sort[i] = i;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (WiFi.RSSI(sort[j]) > WiFi.RSSI(sort[i]))
std::swap(sort[i], sort[j]);
}
bool getBSSIDs() { bool getBSSIDs() {
bool result = false; bool result = false;
int n = WiFi.scanComplete(); int n = WiFi.scanComplete();
@ -175,9 +145,8 @@ class AhoyWifi : public AhoyNetwork {
private: private:
uint8_t mCnt = 0; uint8_t mCnt = 0;
uint8_t mScanCnt = 0; uint8_t mScanCnt = 0;
bool mScanActive = false;
bool mGotDisconnect = false;
std::list<uint8_t> mBSSIDList; std::list<uint8_t> mBSSIDList;
bool mWasInCh12to14 = false;
static constexpr uint8_t TIMEOUT = 20; static constexpr uint8_t TIMEOUT = 20;
static constexpr uint8_t SCAN_TIMEOUT = 10; static constexpr uint8_t SCAN_TIMEOUT = 10;
}; };

55
src/platformio.ini

@ -41,6 +41,16 @@ build_unflags =
-std=gnu++11 -std=gnu++11
[env:esp8266-minimal]
platform = espressif8266
board = esp12e
board_build.f_cpu = 80000000L
build_flags = ${env.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
;-Wl,-Map,output.map
monitor_filters =
esp8266_exception_decoder
[env:esp8266] [env:esp8266]
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
@ -48,10 +58,8 @@ board_build.f_cpu = 80000000L
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
https://github.com/me-no-dev/ESPAsyncUDP https://github.com/me-no-dev/ESPAsyncUDP
build_flags = ${env.build_flags} build_flags = ${env:esp8266-minimal.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DENABLE_MQTT -DENABLE_MQTT
;-Wl,-Map,output.map
monitor_filters = monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
@ -59,11 +67,8 @@ monitor_filters =
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
board_build.f_cpu = 80000000L board_build.f_cpu = 80000000L
build_flags = ${env.build_flags} build_flags = ${env:esp8266.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DLANG_DE -DLANG_DE
-DENABLE_MQTT
;-Wl,-Map,output.map
monitor_filters = monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
@ -71,12 +76,9 @@ monitor_filters =
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
board_build.f_cpu = 80000000L board_build.f_cpu = 80000000L
build_flags = ${env.build_flags} build_flags = ${env:esp8266.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DENABLE_MQTT
-DPLUGIN_DISPLAY -DPLUGIN_DISPLAY
-DENABLE_HISTORY -DENABLE_HISTORY
;-Wl,-Map,output.map
monitor_filters = monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
@ -84,13 +86,8 @@ monitor_filters =
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
board_build.f_cpu = 80000000L board_build.f_cpu = 80000000L
build_flags = ${env.build_flags} build_flags = ${env:esp8266-all.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DLANG_DE -DLANG_DE
-DENABLE_MQTT
-DPLUGIN_DISPLAY
-DENABLE_HISTORY
;-Wl,-Map,output.map
monitor_filters = monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
@ -98,12 +95,8 @@ monitor_filters =
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
board_build.f_cpu = 80000000L board_build.f_cpu = 80000000L
build_flags = ${env.build_flags} build_flags = ${env:esp8266-all.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DENABLE_PROMETHEUS_EP -DENABLE_PROMETHEUS_EP
-DENABLE_MQTT
-DPLUGIN_DISPLAY
-DENABLE_HISTORY
monitor_filters = monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
@ -111,23 +104,8 @@ monitor_filters =
platform = espressif8266 platform = espressif8266
board = esp12e board = esp12e
board_build.f_cpu = 80000000L board_build.f_cpu = 80000000L
build_flags = ${env.build_flags} build_flags = ${env:esp8266-prometheus.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
-DENABLE_PROMETHEUS_EP
-DLANG_DE -DLANG_DE
-DENABLE_MQTT
-DPLUGIN_DISPLAY
-DENABLE_HISTORY
monitor_filters =
esp8266_exception_decoder
[env:esp8266-minimal]
platform = espressif8266
board = esp12e
board_build.f_cpu = 80000000L
build_flags = ${env.build_flags}
-DEMC_MIN_FREE_MEMORY=4096
;-Wl,-Map,output.map
monitor_filters = monitor_filters =
esp8266_exception_decoder esp8266_exception_decoder
@ -350,6 +328,7 @@ build_flags = ${env:opendtufusion-minimal.build_flags}
-DDEF_ETH_MOSI_PIN=40 -DDEF_ETH_MOSI_PIN=40
-DDEF_ETH_IRQ_PIN=44 -DDEF_ETH_IRQ_PIN=44
-DDEF_ETH_RST_PIN=43 -DDEF_ETH_RST_PIN=43
-DDEF_ETH_ENABLED
monitor_filters = monitor_filters =
esp32_exception_decoder, colorize esp32_exception_decoder, colorize

18
src/web/RestApi.h

@ -375,14 +375,12 @@ class RestApi {
} }
void getSysInfo(AsyncWebServerRequest *request, JsonObject obj) { void getSysInfo(AsyncWebServerRequest *request, JsonObject obj) {
obj[F("ap_pwd")] = mConfig->sys.apPwd;
#if !defined(ETHERNET) #if !defined(ETHERNET)
obj[F("ssid")] = mConfig->sys.stationSsid; obj[F("ssid")] = mConfig->sys.stationSsid;
obj[F("ap_pwd")] = mConfig->sys.apPwd;
obj[F("hidd")] = mConfig->sys.isHidden; obj[F("hidd")] = mConfig->sys.isHidden;
obj[F("mac")] = WiFi.macAddress(); obj[F("mac")] = WiFi.macAddress();
obj[F("wifi_channel")] = WiFi.channel(); obj[F("wifi_channel")] = WiFi.channel();
#else
getEthernet(obj.createNestedObject(F("eth")));
#endif /* !defined(ETHERNET) */ #endif /* !defined(ETHERNET) */
obj[F("device_name")] = mConfig->sys.deviceName; obj[F("device_name")] = mConfig->sys.deviceName;
obj[F("dark_mode")] = (bool)mConfig->sys.darkMode; obj[F("dark_mode")] = (bool)mConfig->sys.darkMode;
@ -882,6 +880,9 @@ class RestApi {
#if defined(ESP32) #if defined(ESP32)
getRadioCmt(obj.createNestedObject(F("radioCmt"))); getRadioCmt(obj.createNestedObject(F("radioCmt")));
#endif #endif
#if defined(ETHERNET)
getEthernet(obj.createNestedObject(F("eth")));
#endif
getRadioNrf(obj.createNestedObject(F("radioNrf"))); getRadioNrf(obj.createNestedObject(F("radioNrf")));
getSerial(obj.createNestedObject(F("serial"))); getSerial(obj.createNestedObject(F("serial")));
getStaticIp(obj.createNestedObject(F("static_ip"))); getStaticIp(obj.createNestedObject(F("static_ip")));
@ -1051,6 +1052,17 @@ class RestApi {
//mApp->setStopApAllowedMode(false); //mApp->setStopApAllowedMode(false);
mApp->setupStation(); mApp->setupStation();
} }
#else
else if(F("save_eth") == jsonIn[F("cmd")]) {
mConfig->sys.eth.enabled = jsonIn[F("en")].as<bool>();
mConfig->sys.eth.pinCs = jsonIn[F("cs")].as<uint8_t>();
mConfig->sys.eth.pinSclk = jsonIn[F("sclk")].as<uint8_t>();
mConfig->sys.eth.pinMiso = jsonIn[F("miso")].as<uint8_t>();
mConfig->sys.eth.pinMosi = jsonIn[F("mosi")].as<uint8_t>();
mConfig->sys.eth.pinIrq = jsonIn[F("irq")].as<uint8_t>();
mConfig->sys.eth.pinRst = jsonIn[F("reset")].as<uint8_t>();
mApp->saveSettings(true);
}
#endif /* !defined(ETHERNET */ #endif /* !defined(ETHERNET */
else if(F("save_iv") == jsonIn[F("cmd")]) { else if(F("save_iv") == jsonIn[F("cmd")]) {
Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")], false); Inverter<> *iv = mSys->getInverterByPos(jsonIn[F("id")], false);

8
src/web/html/setup.html

@ -949,7 +949,7 @@
} }
} }
function parsePinout(obj, type, system) { function parsePinout(obj) {
var e = document.getElementById("pinout"); var e = document.getElementById("pinout");
/*IF_ESP32*/ /*IF_ESP32*/
var pinList = esp32pins; var pinList = esp32pins;
@ -1291,13 +1291,13 @@
parseMqtt(root["mqtt"]); parseMqtt(root["mqtt"]);
parseNtp(root["ntp"]); parseNtp(root["ntp"]);
parseSun(root["sun"]); parseSun(root["sun"]);
parsePinout(root["pinout"], root["system"]["esp_type"], root["system"]); parsePinout(root.pinout);
parseNrfRadio(root["radioNrf"], root["pinout"]); parseNrfRadio(root["radioNrf"], root["pinout"]);
/*IF_ESP32*/ /*IF_ESP32*/
parseCmtRadio(root["radioCmt"]); parseCmtRadio(root.radioCmt);
/*ENDIF_ESP32*/ /*ENDIF_ESP32*/
/*IF_ETHERNET*/ /*IF_ETHERNET*/
parseEth(root.system.eth) parseEth(root.eth)
/*ENDIF_ETHERNET*/ /*ENDIF_ETHERNET*/
parseSerial(root["serial"]); parseSerial(root["serial"]);
/*IF_PLUGIN_DISPLAY*/ /*IF_PLUGIN_DISPLAY*/

212
src/web/html/wizard.html

@ -15,6 +15,165 @@
var found = false; var found = false;
var c = document.getElementById("con"); var c = document.getElementById("con");
/*IF_ESP32*/
var pinList = [
[255, "{#PIN_OFF}"],
[0, "GPIO0"],
[1, "TX (GPIO1)"],
[2, "GPIO2 (LED)"],
[3, "RX (GPIO3)"],
[4, "GPIO4"],
[5, "GPIO5"],
[12, "GPIO12 (HSPI MISO)"],
[13, "GPIO13 (HSPI MOSI)"],
[14, "GPIO14 (HSPI SCLK)"],
[15, "GPIO15"],
[16, "GPIO16"],
[17, "GPIO17"],
[18, "GPIO18 (VSPI SCLK)"],
[19, "GPIO19 (VSPI MISO)"],
[21, "GPIO21 (SDA)"],
[22, "GPIO22 (SCL)"],
[23, "GPIO23 (VSPI MOSI)"],
[25, "GPIO25"],
[26, "GPIO26"],
[27, "GPIO27"],
[32, "GPIO32"],
[33, "GPIO33"],
[34, "GPIO34 ({#PIN_INPUT_ONLY})"],
[35, "GPIO35 ({#PIN_INPUT_ONLY})"],
[36, "VP (GPIO36, {#PIN_INPUT_ONLY})"],
[39, "VN (GPIO39, {#PIN_INPUT_ONLY})"]
];
/*IF_ESP32-S2*/
pinList = [
[255, "off / default"],
[0, "GPIO0 ({#PIN_DONT_USE} - BOOT)"],
[1, "GPIO1"],
[2, "GPIO2"],
[3, "GPIO3"],
[4, "GPIO4"],
[5, "GPIO5"],
[6, "GPIO6"],
[7, "GPIO7"],
[8, "GPIO8"],
[9, "GPIO9"],
[10, "GPIO10"],
[11, "GPIO11"],
[12, "GPIO12"],
[13, "GPIO13"],
[14, "GPIO14"],
[15, "GPIO15"],
[16, "GPIO16"],
[17, "GPIO17"],
[18, "GPIO18"],
[19, "GPIO19 ({#PIN_DONT_USE} - USB-)"],
[20, "GPIO20 ({#PIN_DONT_USE} - USB+)"],
[21, "GPIO21"],
[26, "GPIO26 (PSRAM - {#PIN_NOT_AVAIL})"],
[27, "GPIO27 (FLASH - {#PIN_NOT_AVAIL})"],
[28, "GPIO28 (FLASH - {#PIN_NOT_AVAIL})"],
[29, "GPIO29 (FLASH - {#PIN_NOT_AVAIL})"],
[30, "GPIO30 (FLASH - {#PIN_NOT_AVAIL})"],
[31, "GPIO31 (FLASH - {#PIN_NOT_AVAIL})"],
[32, "GPIO32 (FLASH - {#PIN_NOT_AVAIL})"],
[33, "GPIO33 (not exposed on S3-WROOM modules)"],
[34, "GPIO34 (not exposed on S3-WROOM modules)"],
[35, "GPIO35"],
[36, "GPIO36"],
[37, "GPIO37"],
[38, "GPIO38"],
[39, "GPIO39"],
[40, "GPIO40"],
[41, "GPIO41"],
[42, "GPIO42"],
[43, "GPIO43"],
[44, "GPIO44"],
[45, "GPIO45 ({#PIN_DONT_USE} - STRAPPING PIN)"],
[46, "GPIO46 ({#PIN_DONT_USE} - STRAPPING PIN)"],
[47, "GPIO47"],
[48, "GPIO48"],
];
/*ENDIF_ESP32-S2*/
/*IF_ESP32-S3*/
pinList = [
[255, "off / default"],
[0, "GPIO0 ({#PIN_DONT_USE} - BOOT)"],
[1, "GPIO1"],
[2, "GPIO2"],
[3, "GPIO3"],
[4, "GPIO4"],
[5, "GPIO5"],
[6, "GPIO6"],
[7, "GPIO7"],
[8, "GPIO8"],
[9, "GPIO9"],
[10, "GPIO10"],
[11, "GPIO11"],
[12, "GPIO12"],
[13, "GPIO13"],
[14, "GPIO14"],
[15, "GPIO15"],
[16, "GPIO16"],
[17, "GPIO17"],
[18, "GPIO18"],
[19, "GPIO19 ({#PIN_DONT_USE} - USB-)"],
[20, "GPIO20 ({#PIN_DONT_USE} - USB+)"],
[21, "GPIO21"],
[26, "GPIO26 (PSRAM - {#PIN_NOT_AVAIL})"],
[27, "GPIO27 (FLASH - {#PIN_NOT_AVAIL})"],
[28, "GPIO28 (FLASH - {#PIN_NOT_AVAIL})"],
[29, "GPIO29 (FLASH - {#PIN_NOT_AVAIL})"],
[30, "GPIO30 (FLASH - {#PIN_NOT_AVAIL})"],
[31, "GPIO31 (FLASH - {#PIN_NOT_AVAIL})"],
[32, "GPIO32 (FLASH - {#PIN_NOT_AVAIL})"],
[33, "GPIO33 (not exposed on S3-WROOM modules)"],
[34, "GPIO34 (not exposed on S3-WROOM modules)"],
[35, "GPIO35"],
[36, "GPIO36"],
[37, "GPIO37"],
[38, "GPIO38"],
[39, "GPIO39"],
[40, "GPIO40"],
[41, "GPIO41"],
[42, "GPIO42"],
[43, "GPIO43"],
[44, "GPIO44"],
[45, "GPIO45 ({#PIN_DONT_USE} - STRAPPING PIN)"],
[46, "GPIO46 ({#PIN_DONT_USE} - STRAPPING PIN)"],
[47, "GPIO47"],
[48, "GPIO48"],
];
/*ENDIF_ESP32-S3*/
/*IF_ESP32-C3*/
pinList = [
[255, "off / default"],
[0, "GPIO0"],
[1, "GPIO1"],
[2, "GPIO2"],
[3, "GPIO3"],
[4, "GPIO4"],
[5, "GPIO5"],
[6, "GPIO6"],
[7, "GPIO7"],
[8, "GPIO8"],
[9, "GPIO9"],
[10, "GPIO10"],
[11, "GPIO11"],
[12, "GPIO12 (PSRAM/FLASH)"],
[13, "GPIO13 (PSRAM/FLASH)"],
[14, "GPIO14 (PSRAM/FLASH)"],
[15, "GPIO15 (PSRAM/FLASH)"],
[16, "GPIO16 (PSRAM/FLASH)"],
[17, "GPIO17 (PSRAM/FLASH)"],
[18, "GPIO18 ({#PIN_DONT_USE} - USB-)"],
[19, "GPIO19 ({#PIN_DONT_USE} - USB+)"],
[20, "GPIO20 (RX)"],
[21, "GPIO21 (TX)"],
];
/*ENDIF_ESP32-C3*/
/*ENDIF_ESP32*/
function sect(e1, e2) { function sect(e1, e2) {
return ml("div", {class: "row"}, [ return ml("div", {class: "row"}, [
ml("div", {class: "col-12"}, ml("p", {}, e1)), ml("div", {class: "col-12"}, ml("p", {}, e1)),
@ -22,7 +181,36 @@
]) ])
} }
function wifi() { /*IF_ETHERNET*/
var pins = ['cs', 'sclk', 'miso', 'mosi', 'irq', 'reset']
function step1(obj) {
console.log(obj)
lst = []
for(p of pins) {
lst.push(
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-12 col-sm-3 my-2"}, p.toUpperCase()),
ml("div", {class: "col-12 col-sm-9"},
sel(p, pinList, obj[p])
)
])
)
}
let en = inp("en", null, null, ["cb"], "en", "checkbox");
en.checked = obj["en"];
return sect("{#NETWORK_SETUP}", [
ml("div", {class: "row mb-3"}, [
ml("div", {class: "col-8"}, "{#ETH_ENABLE}"),
ml("div", {class: "col-4"}, en)
]),
...lst,
ml("div", {class: "row my-4"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", class:"btn", value: "{#BTN_REBOOT}", onclick: () => {saveEth()}}, null))),
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}")))
])
}
/*ELSE*/
function step1() {
return ml("div", {}, [ return ml("div", {}, [
ml("div", {class: "row my-5"}, ml("div", {class: "col"}, ml("span", {class: "fs-1"}, "{#WELCOME}"))), ml("div", {class: "row my-5"}, ml("div", {class: "col"}, ml("span", {class: "fs-1"}, "{#WELCOME}"))),
ml("div", {class: "row"}, ml("div", {class: "col"}, ml("span", {class: "fs-5"}, "{#NETWORK_SETUP}"))), ml("div", {class: "row"}, ml("div", {class: "col"}, ml("span", {class: "fs-5"}, "{#NETWORK_SETUP}"))),
@ -33,6 +221,7 @@
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}"))) ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}")))
]) ])
} }
/*ENDIF_ETHERNET*/
function checkWifi() { function checkWifi() {
c.replaceChildren( c.replaceChildren(
@ -57,13 +246,29 @@
} }
} }
/*IF_ETHERNET*/
function saveEth() {
let o = {
cmd: "save_eth",
en: document.getElementsByName("en")[0].checked
}
for(p of pins) {
o[p] = document.getElementsByName(p)[0].value
}
getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify(o));
}
/*ELSE*/
function saveWifi() { function saveWifi() {
var ssid = document.getElementById("net").value; var ssid = document.getElementById("net").value;
if(-1 == ssid) if(-1 == ssid)
ssid = document.getElementById("man").value; ssid = document.getElementById("man").value;
getAjax("/api/setup", ((o) => {if(!o.error) checkWifi()}), "POST", JSON.stringify({cmd: "save_wifi", ssid: ssid, pwd: document.getElementById("pwd").value})); getAjax("/api/setup", ((o) => {if(!o.error) checkWifi()}), "POST", JSON.stringify({cmd: "save_wifi", ssid: ssid, pwd: document.getElementById("pwd").value}));
} }
/*ENDIF_ETHERNET*/
/*IF_ETHERNET*/
getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
/*ELSE*/
function nets(obj) { function nets(obj) {
var e = document.getElementById("net"); var e = document.getElementById("net");
if(obj.networks.length > 0) { if(obj.networks.length > 0) {
@ -79,9 +284,10 @@
} }
getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"})); getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"}));
c.append(wifi()) c.append(step1())
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 2500); v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 2500);
/*ENDIF_ETHERNET*/
</script> </script>
</body> </body>
</html> </html>

35
src/web/lang.json

@ -83,6 +83,11 @@
"en": "next >>", "en": "next >>",
"de": "prüfen >>" "de": "prüfen >>"
}, },
{
"token": "BTN_REBOOT",
"en": "reboot >>",
"de": "Ahoy neustarten >>"
},
{ {
"token": "TEST_CONNECTION", "token": "TEST_CONNECTION",
"en": "Test Connection", "en": "Test Connection",
@ -112,6 +117,36 @@
"token": "NUM_NETWORKS_FOUND", "token": "NUM_NETWORKS_FOUND",
"en": "Network(s) found", "en": "Network(s) found",
"de": "Netzwerk(e) gefunden" "de": "Netzwerk(e) gefunden"
},
{
"token": "PIN_OFF",
"en": "off / default",
"de": "aus / Standard"
},
{
"token": "PIN_NO_IRQ",
"en": "no IRQ!",
"de": "kein Interrupt!"
},
{
"token": "PIN_INPUT_ONLY",
"en": "in only",
"de": "nur Eingang"
},
{
"token": "PIN_DONT_USE",
"en": "DONT USE",
"de": "nicht benutzen"
},
{
"token": "PIN_NOT_AVAIL",
"en": "not available",
"de": "nicht verf&uuml;gbar"
},
{
"token": "ETH_ENABLE",
"en": "Ethernet enable",
"de": "Ethernet aktivieren"
} }
] ]
}, },

4
src/web/web.h

@ -447,10 +447,10 @@ class Web {
request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN); request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN);
if (request->arg("pwd") != "{PWD}") if (request->arg("pwd") != "{PWD}")
request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN); request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN);
if (request->arg("ap_pwd") != "")
request->arg("ap_pwd").toCharArray(mConfig->sys.apPwd, PWD_LEN);
mConfig->sys.isHidden = (request->arg("hidd") == "on"); mConfig->sys.isHidden = (request->arg("hidd") == "on");
#endif /* !defined(ETHERNET) */ #endif /* !defined(ETHERNET) */
if (request->arg("ap_pwd") != "")
request->arg("ap_pwd").toCharArray(mConfig->sys.apPwd, PWD_LEN);
if (request->arg("device") != "") if (request->arg("device") != "")
request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN); request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN);
mConfig->sys.darkMode = (request->arg("darkMode") == "on"); mConfig->sys.darkMode = (request->arg("darkMode") == "on");

Loading…
Cancel
Save