Browse Source

* improved setup (if no data is in EEprom)

* improved NRF24 Pinout regarding to #36, Standard Pinout should be now: https://github.com/grindylow/ahoy/issues/36#issuecomment-1149981052
pull/75/head
lumapu 2 years ago
parent
commit
4a28884cff
  1. 10
      tools/esp8266/app.cpp
  2. 6
      tools/esp8266/defines.h
  3. 2
      tools/esp8266/html/h/index_html.h
  4. 2
      tools/esp8266/html/index.html
  5. 8
      tools/esp8266/main.cpp

10
tools/esp8266/app.cpp

@ -99,6 +99,11 @@ void app::setup(uint32_t timeout) {
mEep->read(ADDR_PINOUT, &mSys->Radio.pinCs); mEep->read(ADDR_PINOUT, &mSys->Radio.pinCs);
mEep->read(ADDR_PINOUT+1, &mSys->Radio.pinCe); mEep->read(ADDR_PINOUT+1, &mSys->Radio.pinCe);
mEep->read(ADDR_PINOUT+2, &mSys->Radio.pinIrq); mEep->read(ADDR_PINOUT+2, &mSys->Radio.pinIrq);
if(mSys->Radio.pinCs == mSys->Radio.pinCe) {
mSys->Radio.pinCs = RF24_CS_PIN;
mSys->Radio.pinCe = RF24_CE_PIN;
mSys->Radio.pinIrq = RF24_IRQ_PIN;
}
// nrf24 amplifier power // nrf24 amplifier power
@ -186,7 +191,10 @@ void app::setup(uint32_t timeout) {
DPRINTLN(DBG_INFO, F("\n\n----------------------------------------")); DPRINTLN(DBG_INFO, F("\n\n----------------------------------------"));
DPRINTLN(DBG_INFO, F("Welcome to AHOY!")); DPRINTLN(DBG_INFO, F("Welcome to AHOY!"));
DPRINT(DBG_INFO, F("\npoint your browser to http://")); DPRINT(DBG_INFO, F("\npoint your browser to http://"));
DBGPRINTLN(WiFi.localIP()); if(mApActive)
DBGPRINTLN(F("192.168.1.1"));
else
DBGPRINTLN(WiFi.localIP());
DPRINTLN(DBG_INFO, F("to configure your device")); DPRINTLN(DBG_INFO, F("to configure your device"));
DPRINTLN(DBG_INFO, F("----------------------------------------\n")); DPRINTLN(DBG_INFO, F("----------------------------------------\n"));
} }

6
tools/esp8266/defines.h

@ -12,8 +12,8 @@
// PINOUT (Default, can be changed in setup) // PINOUT (Default, can be changed in setup)
//------------------------------------- //-------------------------------------
#define RF24_CS_PIN 15 #define RF24_CS_PIN 15
#define RF24_CE_PIN 2 #define RF24_CE_PIN 0
#define RF24_IRQ_PIN 0 #define RF24_IRQ_PIN 2
//------------------------------------- //-------------------------------------
@ -21,7 +21,7 @@
//------------------------------------- //-------------------------------------
#define VERSION_MAJOR 0 #define VERSION_MAJOR 0
#define VERSION_MINOR 4 #define VERSION_MINOR 4
#define VERSION_PATCH 19 #define VERSION_PATCH 20
//------------------------------------- //-------------------------------------

2
tools/esp8266/html/h/index_html.h

@ -1,4 +1,4 @@
#ifndef __INDEX_HTML_H__ #ifndef __INDEX_HTML_H__
#define __INDEX_HTML_H__ #define __INDEX_HTML_H__
const char index_html[] PROGMEM = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\">getAjax('/uptime', 'uptime');getAjax('/time', 'time');getAjax('/cmdstat', 'cmdstat');window.setInterval(\"getAjax('/uptime', 'uptime')\", {JS_TS});window.setInterval(\"getAjax('/time', 'time')\", {JS_TS});window.setInterval(\"getAjax('/cmdstat', 'cmds')\", {JS_TS});function getAjax(url, resid) {var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"GET\", url, true);http.onreadystatechange = print;http.send(null);}function print() {if(http.readyState == 4) {document.getElementById(resid).innerHTML = http.responseText;}}}</script></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/hoymiles\">Visualization</a><br/><br/><a href=\"/setup\">Setup</a><br/></p><p><span class=\"des\">Uptime: </span><span id=\"uptime\"></span></p><p><span class=\"des\">Time: </span><span id=\"time\"></span></p><p><span class=\"des\">Statistics: </span><pre id=\"cmds\"></pre></p><p>Every {TS}seconds the values are updated</p><div id=\"note\">This project was started from <a href=\"https://www.mikrocontroller.net/topic/525778\" target=\"_blank\">this discussion. (Mikrocontroller.net)</a><br/>New updates can be found on Github: <a href=\"https://github.com/grindylow/ahoy\" target=\"_blank\">https://github.com/grindylow/ahoy</a><br/><br/>Please report issues using the feature provided by Github.<br/><br/><p class=\"lic\">Creative Commons - <a href=\"https://creativecommons.org/licenses/by-nc-sa/3.0/de\">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>Check the licenses which are published on <a href=\"https://github.com/grindylow/ahoy\">https://github.com/grindylow/ahoy</a>as well</p></div></div><div id=\"footer\"><p class=\"left\">&copy 2022</p><p class=\"left\"><a href=\"/update\">Update Firmware</a></p><p class=\"right\">AHOY :: {VERSION}</p><p class=\"right\"><a href=\"/reboot\">Reboot</a></p></div></body></html>"; const char index_html[] PROGMEM = "<!doctype html><html><head><title>Index - {DEVICE}</title><link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\"/><meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"><script type=\"text/javascript\">getAjax('/uptime', 'uptime');getAjax('/time', 'time');getAjax('/cmdstat', 'cmdstat');window.setInterval(\"getAjax('/uptime', 'uptime')\", {JS_TS});window.setInterval(\"getAjax('/time', 'time')\", {JS_TS});window.setInterval(\"getAjax('/cmdstat', 'cmds')\", {JS_TS});function getAjax(url, resid) {var http = null;http = new XMLHttpRequest();if(http != null) {http.open(\"GET\", url, true);http.onreadystatechange = print;http.send(null);}function print() {if(http.readyState == 4) {document.getElementById(resid).innerHTML = http.responseText;}}}</script></head><body><h1>AHOY - {DEVICE}</h1><div id=\"content\" class=\"content\"><p><a href=\"/hoymiles\">Visualization</a><br/><br/><a href=\"/setup\">Setup</a><br/></p><p><span class=\"des\">Uptime: </span><span id=\"uptime\"></span></p><p><span class=\"des\">Time: </span><span id=\"time\"></span></p><p><span class=\"des\">Statistics: </span><pre id=\"cmds\"></pre></p><p>Every {TS}seconds the values are updated</p><div id=\"note\">This project was started from <a href=\"https://www.mikrocontroller.net/topic/525778\" target=\"_blank\">this discussion. (Mikrocontroller.net)</a><br/>New updates can be found on Github: <a href=\"https://github.com/grindylow/ahoy\" target=\"_blank\">https://github.com/grindylow/ahoy</a><br/><br/>Please report issues using the feature provided by Github.<br/><br/><p class=\"lic\"><a href=\"https://creativecommons.org/licenses/by-nc-sa/3.0/de\">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>Check the licenses which are published on <a href=\"https://github.com/grindylow/ahoy\">https://github.com/grindylow/ahoy</a>&nbsp;as well</p></div></div><div id=\"footer\"><p class=\"left\">&copy 2022</p><p class=\"left\"><a href=\"/update\">Update Firmware</a></p><p class=\"right\">AHOY :: {VERSION}</p><p class=\"right\"><a href=\"/reboot\">Reboot</a></p></div></body></html>";
#endif /*__INDEX_HTML_H__*/ #endif /*__INDEX_HTML_H__*/

2
tools/esp8266/html/index.html

@ -48,7 +48,7 @@
<br/> <br/>
Please report issues using the feature provided by Github.<br/> Please report issues using the feature provided by Github.<br/>
<br/> <br/>
<p class="lic">Creative Commons - <a href="https://creativecommons.org/licenses/by-nc-sa/3.0/de">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/> <p class="lic"><a href="https://creativecommons.org/licenses/by-nc-sa/3.0/de">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>
Check the licenses which are published on <a href="https://github.com/grindylow/ahoy">https://github.com/grindylow/ahoy</a> as well</p> Check the licenses which are published on <a href="https://github.com/grindylow/ahoy">https://github.com/grindylow/ahoy</a> as well</p>
</div> </div>
</div> </div>

8
tools/esp8266/main.cpp

@ -63,8 +63,6 @@ void Main::setup(uint32_t timeout) {
#ifndef AP_ONLY #ifndef AP_ONLY
if(false == startAp) if(false == startAp)
startAp = setupStation(timeout); startAp = setupStation(timeout);
#else
setupAp(WIFI_AP_SSID, WIFI_AP_PWD);
#endif #endif
mUpdater->setup(mWeb); mUpdater->setup(mWeb);
@ -79,11 +77,12 @@ void Main::loop(void) {
mDns->processNextRequest(); mDns->processNextRequest();
#ifndef AP_ONLY #ifndef AP_ONLY
if(checkTicker(&mNextTryTs, (WIFI_AP_ACTIVE_TIME * 1000))) { if(checkTicker(&mNextTryTs, (WIFI_AP_ACTIVE_TIME * 1000))) {
mApLastTick = millis();
mApActive = setupStation(mLimit); mApActive = setupStation(mLimit);
if(mApActive) { if(mApActive) {
if(strlen(WIFI_AP_PWD) < 8) if(strlen(WIFI_AP_PWD) < 8)
DPRINTLN(DBG_ERROR, F("password must be at least 8 characters long")); DPRINTLN(DBG_ERROR, F("password must be at least 8 characters long"));
mApLastTick = millis();
mNextTryTs = (millis() + (WIFI_AP_ACTIVE_TIME * 1000));
setupAp(WIFI_AP_SSID, WIFI_AP_PWD); setupAp(WIFI_AP_SSID, WIFI_AP_PWD);
} }
} }
@ -134,7 +133,8 @@ bool Main::getConfig(void) {
mEep->read(ADDR_PWD, mStationPwd, PWD_LEN); mEep->read(ADDR_PWD, mStationPwd, PWD_LEN);
mEep->read(ADDR_DEVNAME, mDeviceName, DEVNAME_LEN); mEep->read(ADDR_DEVNAME, mDeviceName, DEVNAME_LEN);
} }
else {
if((!mWifiSettingsValid) || (mStationSsid[0] == 0xff)) {
snprintf(mStationSsid, SSID_LEN, "%s", FB_WIFI_SSID); snprintf(mStationSsid, SSID_LEN, "%s", FB_WIFI_SSID);
snprintf(mStationPwd, PWD_LEN, "%s", FB_WIFI_PWD); snprintf(mStationPwd, PWD_LEN, "%s", FB_WIFI_PWD);
snprintf(mDeviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME); snprintf(mDeviceName, DEVNAME_LEN, "%s", DEF_DEVICE_NAME);

Loading…
Cancel
Save