mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-24 22:36:10 +02:00
0.7.3
* fix hidden SSID scan #983 * improved NRF24 missing message on home screen #981 * fix MqTT publishing only updated values #982
This commit is contained in:
parent
53853f8429
commit
4e54bcf299
14 changed files with 68 additions and 38 deletions
|
@ -1,5 +1,10 @@
|
|||
# Development Changes
|
||||
|
||||
## 0.7.3 - 2023-06-09
|
||||
* fix hidden SSID scan #983
|
||||
* improved NRF24 missing message on home screen #981
|
||||
* fix MqTT publishing only updated values #982
|
||||
|
||||
## 0.7.2 - 2023-06-08
|
||||
* fix HMS-800 and HMS-1000 assignments #981
|
||||
* make nrf enabled all the time for ESP8266
|
||||
|
|
10
src/app.cpp
10
src/app.cpp
|
@ -55,11 +55,11 @@ void app::setup() {
|
|||
if(mConfig->nrf.enabled) {
|
||||
mPayload.setup(this, &mSys, &mNrfRadio, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp);
|
||||
mPayload.enableSerialDebug(mConfig->serial.debug);
|
||||
mPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
||||
mPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
mMiPayload.setup(this, &mSys, &mNrfRadio, &mStat, mConfig->nrf.maxRetransPerPyld, &mTimestamp);
|
||||
mMiPayload.enableSerialDebug(mConfig->serial.debug);
|
||||
mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1));
|
||||
mMiPayload.addPayloadListener(std::bind(&app::payloadEventListener, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
#if defined(ESP32)
|
||||
|
@ -334,7 +334,7 @@ void app::tickZeroValues(void) {
|
|||
}
|
||||
|
||||
if(changed)
|
||||
payloadEventListener(RealTimeRunData_Debug);
|
||||
payloadEventListener(RealTimeRunData_Debug, NULL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -356,7 +356,7 @@ void app::tickMinute(void) {
|
|||
}
|
||||
|
||||
if(changed)
|
||||
payloadEventListener(RealTimeRunData_Debug);
|
||||
payloadEventListener(RealTimeRunData_Debug, NULL);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -379,7 +379,7 @@ void app::tickMidnight(void) {
|
|||
}
|
||||
|
||||
if(changed)
|
||||
payloadEventListener(RealTimeRunData_Debug);
|
||||
payloadEventListener(RealTimeRunData_Debug, NULL);
|
||||
|
||||
if (mMqttEnabled)
|
||||
mMqtt.tickerMidnight();
|
||||
|
|
|
@ -242,10 +242,10 @@ class app : public IApp, public ah::Scheduler {
|
|||
|
||||
void resetSystem(void);
|
||||
|
||||
void payloadEventListener(uint8_t cmd) {
|
||||
void payloadEventListener(uint8_t cmd, Inverter<> *iv) {
|
||||
#if !defined(AP_ONLY)
|
||||
if (mMqttEnabled)
|
||||
mMqtt.payloadEventListener(cmd);
|
||||
mMqtt.payloadEventListener(cmd, iv);
|
||||
#endif
|
||||
if(mConfig->plugin.display.type != 0)
|
||||
mDisplay.payloadEventListener(cmd);
|
||||
|
|
|
@ -68,6 +68,7 @@ typedef struct {
|
|||
// wifi
|
||||
char stationSsid[SSID_LEN];
|
||||
char stationPwd[PWD_LEN];
|
||||
bool isHidden;
|
||||
|
||||
cfgIp_t ip;
|
||||
} cfgSys_t;
|
||||
|
@ -359,6 +360,7 @@ class settings {
|
|||
else {
|
||||
snprintf(mCfg.sys.stationSsid, SSID_LEN, FB_WIFI_SSID);
|
||||
snprintf(mCfg.sys.stationPwd, PWD_LEN, FB_WIFI_PWD);
|
||||
mCfg.sys.isHidden = false;
|
||||
}
|
||||
|
||||
snprintf(mCfg.sys.deviceName, DEVNAME_LEN, DEF_DEVICE_NAME);
|
||||
|
@ -426,6 +428,7 @@ class settings {
|
|||
char buf[16];
|
||||
obj[F("ssid")] = mCfg.sys.stationSsid;
|
||||
obj[F("pwd")] = mCfg.sys.stationPwd;
|
||||
obj[F("hidd")] = (bool) mCfg.sys.isHidden;
|
||||
obj[F("dev")] = mCfg.sys.deviceName;
|
||||
obj[F("adm")] = mCfg.sys.adminPwd;
|
||||
obj[F("prot_mask")] = mCfg.sys.protectionMask;
|
||||
|
@ -438,6 +441,7 @@ class settings {
|
|||
} else {
|
||||
getChar(obj, F("ssid"), mCfg.sys.stationSsid, SSID_LEN);
|
||||
getChar(obj, F("pwd"), mCfg.sys.stationPwd, PWD_LEN);
|
||||
getVal<bool>(obj, F("hidd"), &mCfg.sys.isHidden);
|
||||
getChar(obj, F("dev"), mCfg.sys.deviceName, DEVNAME_LEN);
|
||||
getChar(obj, F("adm"), mCfg.sys.adminPwd, PWD_LEN);
|
||||
getVal<uint16_t>(obj, F("prot_mask"), &mCfg.sys.protectionMask);
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
//-------------------------------------
|
||||
#define VERSION_MAJOR 0
|
||||
#define VERSION_MINOR 7
|
||||
#define VERSION_PATCH 2
|
||||
#define VERSION_PATCH 3
|
||||
|
||||
//-------------------------------------
|
||||
typedef struct {
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef struct {
|
|||
} invPayload_t;
|
||||
|
||||
|
||||
typedef std::function<void(uint8_t)> payloadListenerType;
|
||||
typedef std::function<void(uint8_t, Inverter<> *)> payloadListenerType;
|
||||
typedef std::function<void(uint16_t alarmCode, uint32_t start, uint32_t end)> alarmListenerType;
|
||||
|
||||
|
||||
|
@ -342,7 +342,7 @@ class HmPayload {
|
|||
yield();
|
||||
}
|
||||
iv->doCalculations();
|
||||
notify(mPayload[iv->id].txCmd);
|
||||
notify(mPayload[iv->id].txCmd, iv);
|
||||
|
||||
if(AlarmData == mPayload[iv->id].txCmd) {
|
||||
uint8_t i = 0;
|
||||
|
@ -372,9 +372,9 @@ class HmPayload {
|
|||
}
|
||||
|
||||
private:
|
||||
void notify(uint8_t val) {
|
||||
void notify(uint8_t val, Inverter<> *iv) {
|
||||
if(NULL != mCbPayload)
|
||||
(mCbPayload)(val);
|
||||
(mCbPayload)(val, iv);
|
||||
}
|
||||
|
||||
void notify(uint16_t code, uint32_t start, uint32_t endTime) {
|
||||
|
|
|
@ -33,7 +33,7 @@ typedef struct {
|
|||
} miPayload_t;
|
||||
|
||||
|
||||
typedef std::function<void(uint8_t)> miPayloadListenerType;
|
||||
typedef std::function<void(uint8_t, Inverter<> *)> miPayloadListenerType;
|
||||
|
||||
|
||||
template<class HMSYSTEM, class HMRADIO>
|
||||
|
@ -363,7 +363,7 @@ const byteAssign_t InfoAssignment[] = {
|
|||
yield();
|
||||
}
|
||||
iv->doCalculations();
|
||||
notify(mPayload[iv->id].txCmd);
|
||||
notify(mPayload[iv->id].txCmd, iv);
|
||||
|
||||
if(AlarmData == mPayload[iv->id].txCmd) {
|
||||
uint8_t i = 0;
|
||||
|
@ -556,9 +556,9 @@ const byteAssign_t InfoAssignment[] = {
|
|||
}
|
||||
|
||||
private:
|
||||
void notify(uint8_t val) {
|
||||
void notify(uint8_t val, Inverter<> *iv) {
|
||||
if(NULL != mCbMiPayload)
|
||||
(mCbMiPayload)(val);
|
||||
(mCbMiPayload)(val, iv);
|
||||
}
|
||||
|
||||
void miStsDecode(Inverter<> *iv, packet_t *p, uint8_t stschan = CH1) {
|
||||
|
@ -752,7 +752,7 @@ const byteAssign_t InfoAssignment[] = {
|
|||
iv->setQueuedCmdFinished();
|
||||
mStat->rxSuccess++;
|
||||
yield();
|
||||
notify(RealTimeRunData_Debug); //iv->type == INV_TYPE_4CH ? 0x36 : 0x09 );
|
||||
notify(RealTimeRunData_Debug, iv); //iv->type == INV_TYPE_4CH ? 0x36 : 0x09 );
|
||||
}
|
||||
|
||||
bool build(uint8_t id, bool *complete) {
|
||||
|
|
|
@ -29,7 +29,7 @@ typedef struct {
|
|||
} hmsPayload_t;
|
||||
|
||||
|
||||
typedef std::function<void(uint8_t)> payloadListenerType;
|
||||
typedef std::function<void(uint8_t, Inverter<> *)> payloadListenerType;
|
||||
typedef std::function<void(uint16_t alarmCode, uint32_t start, uint32_t end)> alarmListenerType;
|
||||
|
||||
|
||||
|
@ -305,7 +305,7 @@ class HmsPayload {
|
|||
yield();
|
||||
}
|
||||
iv->doCalculations();
|
||||
notify(mPayload[iv->id].txCmd);
|
||||
notify(mPayload[iv->id].txCmd, iv);
|
||||
|
||||
/*if(AlarmData == mPayload[iv->id].txCmd) {
|
||||
uint8_t i = 0;
|
||||
|
@ -335,9 +335,9 @@ class HmsPayload {
|
|||
}
|
||||
|
||||
private:
|
||||
void notify(uint8_t val) {
|
||||
void notify(uint8_t val, Inverter<> *iv) {
|
||||
if(NULL != mCbPayload)
|
||||
(mCbPayload)(val);
|
||||
(mCbPayload)(val, iv);
|
||||
}
|
||||
|
||||
void notify(uint16_t code, uint32_t start, uint32_t endTime) {
|
||||
|
|
|
@ -119,7 +119,7 @@ class PubMqtt {
|
|||
else { // send mqtt data in a fixed interval
|
||||
if(mIntervalTimeout == 0) {
|
||||
mIntervalTimeout = mCfgMqtt->interval;
|
||||
mSendList.push(RealTimeRunData_Debug);
|
||||
mSendList.push(sendListCmdIv(RealTimeRunData_Debug, NULL));
|
||||
sendIvData();
|
||||
}
|
||||
}
|
||||
|
@ -165,10 +165,10 @@ class PubMqtt {
|
|||
publish(mSubTopic, mVal, true);
|
||||
}
|
||||
|
||||
void payloadEventListener(uint8_t cmd) {
|
||||
void payloadEventListener(uint8_t cmd, Inverter<> *iv) {
|
||||
if(mClient.connected()) { // prevent overflow if MQTT broker is not reachable but set
|
||||
if((0 == mCfgMqtt->interval) || (RealTimeRunData_Debug != cmd)) // no interval or no live data
|
||||
mSendList.push(cmd);
|
||||
mSendList.push(sendListCmdIv(cmd, iv));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -564,7 +564,7 @@ class PubMqtt {
|
|||
void sendIvData() {
|
||||
bool anyAvail = processIvStatus();
|
||||
if (mLastAnyAvail != anyAvail)
|
||||
mSendList.push(RealTimeRunData_Debug); // makes sure that total values are calculated
|
||||
mSendList.push(sendListCmdIv(RealTimeRunData_Debug, NULL)); // makes sure that total values are calculated
|
||||
|
||||
if(mSendList.empty())
|
||||
return;
|
||||
|
@ -584,7 +584,7 @@ class PubMqtt {
|
|||
|
||||
uint32_t *mUtcTimestamp;
|
||||
uint32_t mRxCnt, mTxCnt;
|
||||
std::queue<uint8_t> mSendList;
|
||||
std::queue<sendListCmdIv> mSendList;
|
||||
std::queue<alarm_t> mAlarmList;
|
||||
subscriptionCb mSubscriptionCb;
|
||||
bool mLastAnyAvail;
|
||||
|
|
|
@ -12,10 +12,16 @@
|
|||
|
||||
typedef std::function<void(const char *subTopic, const char *payload, bool retained)> pubMqttPublisherType;
|
||||
|
||||
struct sendListCmdIv {
|
||||
uint8_t cmd;
|
||||
Inverter<> *iv;
|
||||
sendListCmdIv(uint8_t a, Inverter<> *i) : cmd(a), iv(i) {}
|
||||
};
|
||||
|
||||
template<class HMSYSTEM>
|
||||
class PubMqttIvData {
|
||||
public:
|
||||
void setup(HMSYSTEM *sys, uint32_t *utcTs, std::queue<uint8_t> *sendList) {
|
||||
void setup(HMSYSTEM *sys, uint32_t *utcTs, std::queue<sendListCmdIv> *sendList) {
|
||||
mSys = sys;
|
||||
mUtcTimestamp = utcTs;
|
||||
mSendList = sendList;
|
||||
|
@ -60,7 +66,8 @@ class PubMqttIvData {
|
|||
void stateStart() {
|
||||
mLastIvId = 0;
|
||||
if(!mSendList->empty()) {
|
||||
mCmd = mSendList->front();
|
||||
mCmd = mSendList->front().cmd;
|
||||
mIvSend = mSendList->front().iv;
|
||||
|
||||
if((RealTimeRunData_Debug != mCmd) || !mRTRDataHasBeenSent) {
|
||||
mSendTotals = (RealTimeRunData_Debug == mCmd);
|
||||
|
@ -141,9 +148,11 @@ class PubMqttIvData {
|
|||
} else
|
||||
mIvLastRTRpub[mIv->id] = lastTs;
|
||||
|
||||
if((mIvSend == mIv) || (NULL == mIvSend)) { // send only updated values, or all if the inverter is NULL
|
||||
snprintf(mSubTopic, 32 + MAX_NAME_LENGTH, "%s/ch%d/%s", mIv->config->name, rec->assign[mPos].ch, fields[rec->assign[mPos].fieldId]);
|
||||
snprintf(mVal, 40, "%g", ah::round3(mIv->getValue(mPos, rec)));
|
||||
mPublish(mSubTopic, mVal, retained);
|
||||
}
|
||||
mPos++;
|
||||
} else
|
||||
mState = FIND_NXT_IV;
|
||||
|
@ -195,7 +204,7 @@ class PubMqttIvData {
|
|||
bool mSendTotals;
|
||||
float mTotal[4];
|
||||
|
||||
Inverter<> *mIv;
|
||||
Inverter<> *mIv, *mIvSend;
|
||||
uint8_t mPos;
|
||||
uint32_t mIvLastRTRpub[MAX_NUM_INVERTERS];
|
||||
bool mRTRDataHasBeenSent;
|
||||
|
@ -203,7 +212,7 @@ class PubMqttIvData {
|
|||
char mSubTopic[32 + MAX_NAME_LENGTH + 1];
|
||||
char mVal[40];
|
||||
|
||||
std::queue<uint8_t> *mSendList;
|
||||
std::queue<sendListCmdIv> *mSendList;
|
||||
};
|
||||
|
||||
#endif /*__PUB_MQTT_IV_DATA_H__*/
|
||||
|
|
|
@ -206,6 +206,7 @@ class RestApi {
|
|||
|
||||
void getSysInfo(AsyncWebServerRequest *request, JsonObject obj) {
|
||||
obj[F("ssid")] = mConfig->sys.stationSsid;
|
||||
obj[F("hidd")] = mConfig->sys.isHidden;
|
||||
obj[F("device_name")] = mConfig->sys.deviceName;
|
||||
obj[F("dark_mode")] = (bool)mConfig->sys.darkMode;
|
||||
|
||||
|
@ -467,7 +468,7 @@ class RestApi {
|
|||
|
||||
JsonArray warn = obj.createNestedArray(F("warnings"));
|
||||
if(!mRadio->isChipConnected())
|
||||
warn.add(F("your NRF24 module can't be reached, check the wiring and pinout"));
|
||||
warn.add(F("your NRF24 module can't be reached, check the wiring, pinout and enable"));
|
||||
else if(!mRadio->isPVariant())
|
||||
warn.add(F("your NRF24 module isn't a plus version(+), maybe incompatible"));
|
||||
if(!mApp->getSettingsValid())
|
||||
|
|
|
@ -72,7 +72,11 @@
|
|||
</div>
|
||||
<div class="row mb-2 mb-sm-3">
|
||||
<div class="col-12 col-sm-3 my-2">SSID</div>
|
||||
<div class="col-12 col-sm-9"><input type="text" name="ssid"/></div>
|
||||
<div class="col-12 col-sm-9"><input type="text" name="ssid"/><div>
|
||||
</div>
|
||||
<div class="row mb-2 mb-sm-3">
|
||||
<div class="col-12 col-sm-3 my-2">hidden SSID</div>
|
||||
<div class="col-12 col-sm-9"><input type="checkbox" name="hidd"/><div>
|
||||
</div>
|
||||
<div class="row mb-2 mb-sm-3">
|
||||
<div class="col-12 col-sm-3 my-2">Password</div>
|
||||
|
@ -617,6 +621,7 @@
|
|||
function parseSys(obj) {
|
||||
for(var i of [["device", "device_name"], ["ssid", "ssid"]])
|
||||
document.getElementsByName(i[0])[0].value = obj[i[1]];
|
||||
document.getElementsByName("hidd")[0].checked = obj["hidd"];
|
||||
document.getElementsByName("darkMode")[0].checked = obj["dark_mode"];
|
||||
e = document.getElementsByName("adminpwd")[0];
|
||||
if(!obj["pwd_set"])
|
||||
|
|
|
@ -448,6 +448,7 @@ class Web {
|
|||
request->arg("ssid").toCharArray(mConfig->sys.stationSsid, SSID_LEN);
|
||||
if (request->arg("pwd") != "{PWD}")
|
||||
request->arg("pwd").toCharArray(mConfig->sys.stationPwd, PWD_LEN);
|
||||
mConfig->sys.isHidden = (request->arg("hidd") == "on");
|
||||
if (request->arg("device") != "")
|
||||
request->arg("device").toCharArray(mConfig->sys.deviceName, DEVNAME_LEN);
|
||||
mConfig->sys.darkMode = (request->arg("darkMode") == "on");
|
||||
|
|
|
@ -104,10 +104,15 @@ void ahoywifi::tickWifiLoop() {
|
|||
DBGPRINTLN(String(mConfig->sys.stationSsid));
|
||||
mScanCnt = 0;
|
||||
mScanActive = true;
|
||||
uint8_t *ssid = ([this] () {
|
||||
if(mConfig->sys.isHidden)
|
||||
return (uint8_t *)NULL;
|
||||
return (uint8_t *)(mConfig->sys.stationSsid);
|
||||
})();
|
||||
#if defined(ESP8266)
|
||||
WiFi.scanNetworks(true, false, 0U, (uint8_t *)mConfig->sys.stationSsid);
|
||||
WiFi.scanNetworks(true, true, 0U, ssid);
|
||||
#else
|
||||
WiFi.scanNetworks(true, false, false, 300U, 0U, mConfig->sys.stationSsid);
|
||||
WiFi.scanNetworks(true, true, false, 300U, 0U, ssid);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue