mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-11 07:56:39 +02:00
fix #389 prevent connect to default Wifi 'YOUR_WIFI_SSID'
implemented #388 add inverter Id to the front of serial print fix inverter serial number length in input field (api.js)
This commit is contained in:
parent
6fc5fb75b2
commit
ea991a7723
7 changed files with 24 additions and 13 deletions
|
@ -33,10 +33,16 @@ ahoywifi::ahoywifi(app *main, sysConfig_t *sysCfg, config_t *config) {
|
|||
|
||||
//-----------------------------------------------------------------------------
|
||||
void ahoywifi::setup(uint32_t timeout, bool settingValid) {
|
||||
#ifdef FB_WIFI_OVERRIDDEN
|
||||
mStationWifiIsDef = false;
|
||||
#else
|
||||
mStationWifiIsDef = (strncmp(mSysCfg->stationSsid, FB_WIFI_SSID, 14) == 0);
|
||||
#endif
|
||||
|
||||
mWifiStationTimeout = timeout;
|
||||
#ifndef AP_ONLY
|
||||
if(false == mApActive)
|
||||
mApActive = setupStation(mWifiStationTimeout);
|
||||
mApActive = (mStationWifiIsDef) ? true : setupStation(mWifiStationTimeout);
|
||||
#endif
|
||||
|
||||
if(!settingValid) {
|
||||
|
@ -66,7 +72,7 @@ bool ahoywifi::loop(void) {
|
|||
mDns->processNextRequest();
|
||||
#ifndef AP_ONLY
|
||||
if(mMain->checkTicker(&mNextTryTs, (WIFI_AP_ACTIVE_TIME * 1000))) {
|
||||
mApActive = setupStation(mWifiStationTimeout);
|
||||
mApActive = (mStationWifiIsDef) ? true : setupStation(mWifiStationTimeout);
|
||||
if(mApActive) {
|
||||
if(strlen(WIFI_AP_PWD) < 8)
|
||||
DPRINTLN(DBG_ERROR, F("password must be at least 8 characters long"));
|
||||
|
@ -77,12 +83,13 @@ bool ahoywifi::loop(void) {
|
|||
}
|
||||
else {
|
||||
if(millis() - mApLastTick > 10000) {
|
||||
mApLastTick = millis();
|
||||
uint8_t cnt = WiFi.softAPgetStationNum();
|
||||
if(cnt > 0) {
|
||||
DPRINTLN(DBG_INFO, String(cnt) + F(" client connected, resetting AP timeout"));
|
||||
DPRINTLN(DBG_INFO, String(cnt) + F(" client connected (no timeout)"));
|
||||
mNextTryTs = (millis() + (WIFI_AP_ACTIVE_TIME * 1000));
|
||||
}
|
||||
mApLastTick = millis();
|
||||
else
|
||||
DPRINTLN(DBG_INFO, F("AP will be closed in ") + String((mNextTryTs - mApLastTick) / 1000) + F(" seconds"));
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +99,7 @@ bool ahoywifi::loop(void) {
|
|||
if((WiFi.status() != WL_CONNECTED) && wifiWasEstablished) {
|
||||
if(!mApActive) {
|
||||
DPRINTLN(DBG_INFO, "[WiFi]: Connection Lost");
|
||||
mApActive = setupStation(mWifiStationTimeout);
|
||||
mApActive = (mStationWifiIsDef) ? true : setupStation(mWifiStationTimeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ class ahoywifi {
|
|||
uint32_t mApLastTick;
|
||||
bool mApActive;
|
||||
bool wifiWasEstablished;
|
||||
bool mStationWifiIsDef;
|
||||
};
|
||||
|
||||
#endif /*__AHOYWIFI_H__*/
|
||||
|
|
|
@ -17,11 +17,11 @@ app::app() {
|
|||
Serial.begin(115200);
|
||||
DPRINTLN(DBG_VERBOSE, F("app::app"));
|
||||
mEep = new eep();
|
||||
mWifi = new ahoywifi(this, &mSysConfig, &mConfig);
|
||||
|
||||
resetSystem();
|
||||
loadDefaultConfig();
|
||||
|
||||
mWifi = new ahoywifi(this, &mSysConfig, &mConfig);
|
||||
mSys = new HmSystemType();
|
||||
mSys->enableDebug();
|
||||
mShouldReboot = false;
|
||||
|
@ -231,7 +231,7 @@ void app::loop(void) {
|
|||
if (mConfig.serialDebug)
|
||||
DPRINTLN(DBG_INFO, F("enqueued cmd failed/timeout"));
|
||||
if (mConfig.serialDebug) {
|
||||
DPRINT(DBG_INFO, F("Inverter #") + String(iv->id) + " ");
|
||||
DPRINT(DBG_INFO, F("(#") + String(iv->id) + ") ");
|
||||
DPRINTLN(DBG_INFO, F("no Payload received! (retransmits: ") + String(mPayload[iv->id].retransmits) + ")");
|
||||
}
|
||||
}
|
||||
|
@ -242,18 +242,19 @@ void app::loop(void) {
|
|||
yield();
|
||||
if (mConfig.serialDebug) {
|
||||
DPRINTLN(DBG_DEBUG, F("app:loop WiFi WiFi.status ") + String(WiFi.status()));
|
||||
DPRINTLN(DBG_INFO, F("Requesting Inverter SN ") + String(iv->serial.u64, HEX));
|
||||
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Requesting Inv SN ") + String(iv->serial.u64, HEX));
|
||||
}
|
||||
|
||||
if (iv->devControlRequest) {
|
||||
if (mConfig.serialDebug)
|
||||
DPRINTLN(DBG_INFO, F("Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0]));
|
||||
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") Devcontrol request ") + String(iv->devControlCmd) + F(" power limit ") + String(iv->powerLimit[0]));
|
||||
mSys->Radio.sendControlPacket(iv->radioId.u64, iv->devControlCmd, iv->powerLimit);
|
||||
mPayload[iv->id].txCmd = iv->devControlCmd;
|
||||
iv->clearCmdQueue();
|
||||
iv->enqueCommand<InfoCommand>(SystemConfigPara);
|
||||
} else {
|
||||
uint8_t cmd = iv->getQueuedCmd();
|
||||
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") sendTimePacket"));
|
||||
mSys->Radio.sendTimePacket(iv->radioId.u64, cmd, mPayload[iv->id].ts, iv->alarmMesIndex);
|
||||
mPayload[iv->id].txCmd = cmd;
|
||||
mRxTicker = 0;
|
||||
|
@ -333,6 +334,7 @@ void app::processPayload(bool retransmit) {
|
|||
mSys->Radio.sendCmdPacket(iv->radioId.u64, TX_REQ_INFO, mLastPacketId, true);
|
||||
else {
|
||||
mPayload[iv->id].txCmd = iv->getQueuedCmd();
|
||||
DPRINTLN(DBG_INFO, F("(#") + String(iv->id) + F(") sendTimePacket"));
|
||||
mSys->Radio.sendTimePacket(iv->radioId.u64, mPayload[iv->id].txCmd, mPayload[iv->id].ts, iv->alarmMesIndex);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#define __CONFIG_OVERRIDE_H__
|
||||
|
||||
// override fallback WiFi info
|
||||
#define FB_WIFI_OVERRIDDEN
|
||||
|
||||
// each ovveride must be preceeded with an #undef statement
|
||||
#undef FB_WIFI_SSID
|
||||
|
|
|
@ -144,7 +144,7 @@ class Inverter {
|
|||
template <typename T>
|
||||
void enqueCommand(uint8_t cmd) {
|
||||
_commandQueue.push(std::make_shared<T>(cmd));
|
||||
DPRINTLN(DBG_INFO, "enqueuedCmd: " + String(cmd));
|
||||
DPRINTLN(DBG_INFO, F("(#") + String(id) + F(") enqueuedCmd: ") + String(cmd));
|
||||
}
|
||||
|
||||
void setQueuedCmdFinished() {
|
||||
|
|
|
@ -220,7 +220,7 @@ class HmRadio {
|
|||
}
|
||||
|
||||
void sendTimePacket(uint64_t invId, uint8_t cmd, uint32_t ts, uint16_t alarmMesId) {
|
||||
DPRINTLN(DBG_INFO, F("sendTimePacket"));
|
||||
DPRINTLN(DBG_VERBOSE, F("sendTimePacket"));
|
||||
sendCmdPacket(invId, TX_REQ_INFO, ALL_FRAMES, false);
|
||||
mTxBuf[10] = cmd; // cid
|
||||
mTxBuf[11] = 0x00;
|
||||
|
|
|
@ -90,7 +90,7 @@ function inp(name, val, max=32, cl=["text"], id=null, type=null) {
|
|||
e.classList.add(...cl);
|
||||
e.name = name;
|
||||
e.value = val;
|
||||
if(null != type) e.maxLength = max;
|
||||
if(null != max) e.maxLength = max;
|
||||
if(null != id) e.id = id;
|
||||
if(null != type) e.type = type;
|
||||
return e;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue