Skip to content

Commit

Permalink
0.8.110
Browse files Browse the repository at this point in the history
* improved `Wizard
  • Loading branch information
lumapu committed Apr 11, 2024
1 parent e76722a commit 1f86e4c
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* revert CMT2300A changes #1553
* merged PR: fix closing tag #1584
* add disable retain flag #1582
* fix German translation #1569
* improved `Wizard`

## 0.8.109 - 2024-04-09
* fix hal patch
Expand Down
6 changes: 5 additions & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class app : public IApp, public ah::Scheduler {

#if !defined(ETHERNET)
bool getAvailNetworks(JsonObject obj) override {
return mNetwork->getAvailNetworks(obj);
return mNetwork->getAvailNetworks(obj, this);
}

void setupStation(void) override {
Expand Down Expand Up @@ -204,6 +204,10 @@ class app : public IApp, public ah::Scheduler {
return mVersionModules;
}

void addOnce(ah::scdCb c, uint32_t timeout, const char *name) override {
once(c, timeout, name);
}

uint32_t getSunrise() override {
return mSunrise;
}
Expand Down
3 changes: 3 additions & 0 deletions src/appInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#include "defines.h"
#include "ESPAsyncWebServer.h"
#include "utils/scheduler.h"

// abstract interface to App. Make members of App accessible from child class
// like web or API without forward declaration
Expand All @@ -25,6 +26,8 @@ class IApp {
virtual const char *getVersion() = 0;
virtual const char *getVersionModules() = 0;

virtual void addOnce(ah::scdCb c, uint32_t timeout, const char *name) = 0;

#if !defined(ETHERNET)
virtual bool getAvailNetworks(JsonObject obj) = 0;
virtual void setupStation(void) = 0;
Expand Down
14 changes: 9 additions & 5 deletions src/network/AhoyNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,9 @@ class AhoyNetwork {
}

#if !defined(ETHERNET)
bool getAvailNetworks(JsonObject obj) {
bool getAvailNetworks(JsonObject obj, IApp *app) {
if(!mScanActive) {
mScanActive = true;
if(NetworkState::GOT_IP != mStatus)
WiFi.disconnect();
WiFi.scanNetworks(true, true);
app->addOnce([this]() {scan();}, 1, F("scan"));
return false;
}

Expand All @@ -117,6 +114,13 @@ class AhoyNetwork {

return true;
}

void scan(void) {
mScanActive = true;
if(NetworkState::GOT_IP != mStatus)
WiFi.disconnect();
WiFi.scanNetworks(true, true);
}
#endif

protected:
Expand Down
1 change: 1 addition & 0 deletions src/network/AhoyWifiAp.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class AhoyWifiAp {
#if defined(ETHERNET)
WiFi.mode(WIFI_OFF);
#else
WiFi.scanDelete();
WiFi.mode(WIFI_STA);
#endif

Expand Down
1 change: 1 addition & 0 deletions src/network/AhoyWifiEsp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AhoyWifi : public AhoyNetwork {

DBGPRINT(F("connect to network '"));
DBGPRINT(mConfig->sys.stationSsid);
DBGPRINTLN(F("'"));
#endif
}

Expand Down
4 changes: 3 additions & 1 deletion src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,9 @@ class RestApi {

void getHtmlFactory(AsyncWebServerRequest *request, JsonObject obj) {
getGeneric(request, obj.createNestedObject(F("generic")));
obj[F("html")] = F("Factory reset? <a class=\"btn\" href=\"/factorytrue\">yes</a> <a class=\"btn\" href=\"/\">no</a>");
char tmp[200];
snprintf(tmp, 200, "%s <a class=\"btn\" href=\"/factorytrue\">%s</a> <a class=\"btn\" href=\"/\">%s</a>", FACTORY_RESET, BTN_YES, BTN_NO);
obj[F("html")] = tmp;
}

void getHtmlFactoryTrue(AsyncWebServerRequest *request, JsonObject obj) {
Expand Down
18 changes: 18 additions & 0 deletions src/web/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,22 @@
#define BTN_REBOOT "Reboot"
#endif

#ifdef LANG_DE
#define BTN_REBOOT "Ahoy neustarten"
#else /*LANG_EN*/
#define BTN_REBOOT "Reboot"
#endif

#ifdef LANG_DE
#define BTN_YES "ja"
#else /*LANG_EN*/
#define BTN_YES "yes"
#endif

#ifdef LANG_DE
#define BTN_NO "nein"
#else /*LANG_EN*/
#define BTN_NO "no"
#endif

#endif /*__LANG_H__*/
2 changes: 1 addition & 1 deletion src/web/lang.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
{
"token": "NETWORK_SUCCESS",
"en": "success, got following IP in your network: ",
"de": "Verindung erfolgreich. AhoyDTU hat die folgende IP bekommen: "
"de": "Verbindung erfolgreich. AhoyDTU hat die folgende IP bekommen: "
},
{
"token": "BTN_FINISH",
Expand Down

0 comments on commit 1f86e4c

Please sign in to comment.