Skip to content

Commit

Permalink
0.8.102 - 2024-04-01
Browse files Browse the repository at this point in the history
* fix NTP for `opendtufusion` #1542
* fix scan WiFi in AP mode
  • Loading branch information
lumapu committed Apr 1, 2024
1 parent 2a4c836 commit bcc52c7
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 43 deletions.
2 changes: 1 addition & 1 deletion scripts/htmlPreprocessorDefines.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ def check(inp, lst, pattern):
return out

def conv(inp, lst):
print(lst)
#print(lst)
out = check(inp, lst, r'\/\*(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\*\/')
return check(out, lst, r'\<\!\-\-(?:IF_|ELS|ENDIF_)([A-Z0-9\-_]+)?\-\-\>')
4 changes: 4 additions & 0 deletions src/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Development Changes

## 0.8.102 - 2024-04-01
* fix NTP for `opendtufusion` #1542
* fix scan WiFi in AP mode

## 0.8.101 - 2024-03-28
* updated converter scripts to include all enabled features again (redundant scan of build flags) #1534

Expand Down
2 changes: 1 addition & 1 deletion src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void app::setup() {
#endif // ETHERNET
mNetwork->setup(mConfig, &mTimestamp, [this](bool gotIp) { this->onNetwork(gotIp); }, [this](bool gotTime) { this->onNtpUpdate(gotTime); });
mNetwork->begin();
everySec(std::bind(&AhoyNetwork::tickNetworkLoop, mNetwork), "net");

esp_task_wdt_reset();

Expand Down Expand Up @@ -176,6 +175,7 @@ void app::regularTickers(void) {
DPRINTLN(DBG_DEBUG, F("regularTickers"));
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
everySec([this]() { mProtection->tickSecond(); }, "prot");
everySec([this]() {mNetwork->tickNetworkLoop(); }, "net");

// Plugins
#if defined(PLUGIN_DISPLAY)
Expand Down
8 changes: 0 additions & 8 deletions src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,6 @@ class app : public IApp, public ah::Scheduler {
}

#if !defined(ETHERNET)
void scanAvailNetworks() override {
mNetwork->scanAvailNetworks();
}

bool getAvailNetworks(JsonObject obj) override {
return mNetwork->getAvailNetworks(obj);
}
Expand All @@ -179,10 +175,6 @@ class app : public IApp, public ah::Scheduler {
mNetwork->begin();
}

/*void setStopApAllowedMode(bool allowed) override {
mWifi.setStopApAllowedMode(allowed);
}*/

bool getWasInCh12to14(void) const override {
#if defined(ESP8266)
return mNetwork->getWasInCh12to14();
Expand Down
2 changes: 0 additions & 2 deletions src/appInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ class IApp {
virtual const char *getVersionModules() = 0;

#if !defined(ETHERNET)
virtual void scanAvailNetworks() = 0;
virtual bool getAvailNetworks(JsonObject obj) = 0;
virtual void setupStation(void) = 0;
//virtual void setStopApAllowedMode(bool allowed) = 0;
virtual bool getWasInCh12to14(void) const = 0;
#endif /* defined(ETHERNET) */
virtual String getIp(void) = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 8
#define VERSION_PATCH 101
#define VERSION_PATCH 102
//-------------------------------------
typedef struct {
uint8_t ch;
Expand Down
16 changes: 8 additions & 8 deletions src/network/AhoyNetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,20 @@ class AhoyNetwork {
}

#if !defined(ETHERNET)
void scanAvailNetworks(void) {
bool getAvailNetworks(JsonObject obj) {
JsonArray nets = obj.createNestedArray(F("networks"));

if(!mScanActive) {
mScanActive = true;
WiFi.scanNetworks(true);
WiFi.disconnect();
WiFi.scanNetworks(true, true);
return false;
}
}

bool getAvailNetworks(JsonObject obj) {
JsonArray nets = obj.createNestedArray(F("networks"));

int n = WiFi.scanComplete();
if (n < 0)
if (WIFI_SCAN_RUNNING == n)
return false;

if(n > 0) {
int sort[n];
sortRSSI(&sort[0], n);
Expand Down Expand Up @@ -174,7 +175,6 @@ class AhoyNetwork {

private:
void sendNTPpacket(void) {
//DPRINTLN(DBG_VERBOSE, F("wifi::sendNTPpacket"));
uint8_t buf[NTP_PACKET_SIZE];
memset(buf, 0, NTP_PACKET_SIZE);

Expand Down
7 changes: 7 additions & 0 deletions src/network/AhoyWifiAp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ class AhoyWifiAp {
void tickLoop() {
if(mEnabled)
mDns.processNextRequest();

if (WiFi.softAPgetStationNum() != mLast) {
mLast = WiFi.softAPgetStationNum();
if(mLast > 0)
DBGPRINTLN(F("AP client connected"));
}
}

void enable() {
Expand Down Expand Up @@ -68,6 +74,7 @@ class AhoyWifiAp {
DNSServer mDns;
IPAddress mIp;
bool mEnabled = false;
uint8_t mLast = 0;
};

#endif /*__AHOY_WIFI_AP_H__*/
6 changes: 1 addition & 5 deletions src/network/AhoyWifiEsp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AhoyWifi : public AhoyNetwork {
WiFi.setSortMethod(WIFI_CONNECT_AP_BY_SIGNAL);
WiFi.begin(mConfig->sys.stationSsid, mConfig->sys.stationPwd, WIFI_ALL_CHANNEL_SCAN);

DBGPRINT(F("connect to network '")); Serial.flush();
DBGPRINT(F("connect to network '"));
DBGPRINT(mConfig->sys.stationSsid);
#endif
}
Expand All @@ -44,10 +44,6 @@ class AhoyWifi : public AhoyNetwork {
mOnNetworkCB(false);
mAp.enable();
}

if (WiFi.softAPgetStationNum() > 0) {
DBGPRINTLN(F("AP client connected"));
}
break;

case NetworkState::CONNECTED:
Expand Down
2 changes: 2 additions & 0 deletions src/network/AhoyWifiEsp8266.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ class AhoyWifi : public AhoyNetwork {
mOnNetworkCB(true);
}

MDNS.update();

if(WiFi.channel() > 11)
mWasInCh12to14 = true;
break;
Expand Down
8 changes: 5 additions & 3 deletions src/utils/improv.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,12 @@ class Improv {
}

void getNetworks(void) {
if(!mScanRunning)
mApp->scanAvailNetworks();

JsonObject obj;
if(!mScanRunning) {
mApp->getAvailNetworks(obj);
return;
}

if(!mApp->getAvailNetworks(obj))
return;

Expand Down
15 changes: 5 additions & 10 deletions src/web/RestApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class RestApi {
else if(path == "setup") getSetup(request, root);
#if !defined(ETHERNET)
else if(path == "setup/networks") getNetworks(root);
else if(path == "setup/getip") getWifiIp(root);
else if(path == "setup/getip") getIp(root);
#endif /* !defined(ETHERNET) */
else if(path == "live") getLive(request,root);
else if (path == "powerHistory") getPowerHistory(request, root);
Expand Down Expand Up @@ -891,12 +891,13 @@ class RestApi {

#if !defined(ETHERNET)
void getNetworks(JsonObject obj) {
mApp->getAvailNetworks(obj);
obj[F("success")] = mApp->getAvailNetworks(obj);
}
void getWifiIp(JsonObject obj) {
#endif /* !defined(ETHERNET) */

void getIp(JsonObject obj) {
obj[F("ip")] = mApp->getIp();
}
#endif /* !defined(ETHERNET) */

void getLive(AsyncWebServerRequest *request, JsonObject obj) {
getGeneric(request, obj.createNestedObject(F("generic")));
Expand Down Expand Up @@ -1031,11 +1032,6 @@ class RestApi {
if(isProtected(jsonIn, jsonOut, clientIP))
return false;

#if !defined(ETHERNET)
if(F("scan_wifi") == jsonIn[F("cmd")])
mApp->scanAvailNetworks();
else
#endif /* !defined(ETHERNET) */
if(F("set_time") == jsonIn[F("cmd")])
mApp->setTimestamp(jsonIn[F("val")]);
else if(F("sync_ntp") == jsonIn[F("cmd")])
Expand All @@ -1049,7 +1045,6 @@ class RestApi {
snprintf(mConfig->sys.stationSsid, SSID_LEN, "%s", jsonIn[F("ssid")].as<const char*>());
snprintf(mConfig->sys.stationPwd, PWD_LEN, "%s", jsonIn[F("pwd")].as<const char*>());
mApp->saveSettings(false); // without reboot
//mApp->setStopApAllowedMode(false);
mApp->setupStation();
}
#else
Expand Down
9 changes: 5 additions & 4 deletions src/web/html/wizard.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
ml("div", {class: "row my-4"}, ml("div", {class: "col a-r"}, ml("input", {type: "button", class:"btn hide", id: "btn", value: "{#BTN_FINISH}", onclick: () => {redirect()}}, null))),
ml("div", {class: "row mt-5"}, ml("div", {class: "col a-c"}, ml("a", {href: "http://192.168.4.1/"}, "{#STOP_WIZARD}")))
)
v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 2500);
v = setInterval(() => {getAjax('/api/setup/getip', printIp)}, 1000);
}

function redirect() {
Expand Down Expand Up @@ -270,6 +270,9 @@
getAjax("/api/setup", ((o) => c.append(step1(o.eth))));
/*ELSE*/
function nets(obj) {
if(!obj.success)
return;

var e = document.getElementById("net");
if(obj.networks.length > 0) {
var a = []
Expand All @@ -280,12 +283,10 @@
}
e.replaceChildren(...a)
}
getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"}));
}

getAjax("/api/setup", ((o) => {}), "POST", JSON.stringify({cmd: "scan_wifi"}));
c.append(step1())
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 2500);
v = setInterval(() => {getAjax('/api/setup/networks', nets)}, 1000);
/*ENDIF_ETHERNET*/

</script>
Expand Down
1 change: 1 addition & 0 deletions src/web/web.h
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class Web {

void showNotFound(AsyncWebServerRequest *request) {
checkProtection(request);
//DBGPRINTLN(request->url());
request->redirect("/wizard");
}

Expand Down

0 comments on commit bcc52c7

Please sign in to comment.