Browse Source

fix publish loop

pull/935/head
lumapu 1 year ago
parent
commit
8ead358f4c
  1. 4
      src/app.cpp
  2. 4
      src/defines.h
  3. 23
      src/hm/hmPayload.h
  4. 8
      src/publisher/pubMqttIvData.h

4
src/app.cpp

@ -32,7 +32,7 @@ void app::setup() {
mSys.enableDebug();
mSys.setup(mConfig->nrf.amplifierPower, mConfig->nrf.pinIrq, mConfig->nrf.pinCe, mConfig->nrf.pinCs, mConfig->nrf.pinSclk, mConfig->nrf.pinMosi, mConfig->nrf.pinMiso);
#if defined(AP_ONLY)
#if defined(AP_ONLY)
mInnerLoopCb = std::bind(&app::loopStandard, this);
#else
mInnerLoopCb = std::bind(&app::loopWifi, this);
@ -171,6 +171,8 @@ void app::regularTickers(void) {
if (mConfig->plugin.display.type != 0)
everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp");
every(std::bind(&PubSerialType::tick, &mPubSerial), mConfig->serial.interval, "uart");
// every([this]() {mPayload.simulation();}, 15, "simul");
}
//-----------------------------------------------------------------------------

4
src/defines.h

@ -1,5 +1,5 @@
//-----------------------------------------------------------------------------
// 2023 Ahoy, https://www.mikrocontroller.net/topic/525778
// 2023 Ahoy, https://ahoydtu.de
// Creative Commons - https://creativecommons.org/licenses/by-nc-sa/4.0/deed
//-----------------------------------------------------------------------------
@ -13,7 +13,7 @@
//-------------------------------------
#define VERSION_MAJOR 0
#define VERSION_MINOR 6
#define VERSION_PATCH 9
#define VERSION_PATCH 11
//-------------------------------------
typedef struct {

23
src/hm/hmPayload.h

@ -70,6 +70,29 @@ class HmPayload {
}
}
/*void simulation() {
uint8_t pay[] = {
0x00, 0x01, 0x01, 0x24, 0x02, 0x28, 0x02, 0x33,
0x06, 0x49, 0x06, 0x6a, 0x00, 0x05, 0x5f, 0x1b,
0x00, 0x06, 0x66, 0x9a, 0x03, 0xfd, 0x04, 0x0b,
0x01, 0x23, 0x02, 0x28, 0x02, 0x28, 0x06, 0x41,
0x06, 0x43, 0x00, 0x05, 0xdc, 0x2c, 0x00, 0x06,
0x2e, 0x3f, 0x04, 0x01, 0x03, 0xfb, 0x09, 0x78,
0x13, 0x86, 0x18, 0x15, 0x00, 0xcf, 0x00, 0xfe,
0x03, 0xe7, 0x01, 0x42, 0x00, 0x03
};
Inverter<> *iv = mSys->getInverterByPos(0);
record_t<> *rec = iv->getRecordStruct(0x0b);
rec->ts = *mTimestamp;
for (uint8_t i = 0; i < rec->length; i++) {
iv->addValue(i, pay, rec);
yield();
}
iv->doCalculations();
notify(0x0b);
}*/
void zeroYieldDay(Inverter<> *iv) {
DPRINTLN(DBG_DEBUG, F("zeroYieldDay"));
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);

8
src/publisher/pubMqttIvData.h

@ -85,6 +85,8 @@ class PubMqttIvData {
}
}
mLastIvId++;
mPos = 0;
if(found)
mState = SEND_DATA;
@ -102,8 +104,6 @@ class PubMqttIvData {
pubData &= (lastTs != mIvLastRTRpub[mIv->id]);
if (pubData) {
mIvLastRTRpub[mIv->id] = lastTs;
//for (uint8_t i = 0; i < rec->length; i++) {
if(mPos < rec->length) {
bool retained = false;
if (mCmd == RealTimeRunData_Debug) {
@ -135,7 +135,8 @@ class PubMqttIvData {
break;
}
}
}
} else
mIvLastRTRpub[mIv->id] = lastTs;
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)));
@ -149,7 +150,6 @@ class PubMqttIvData {
void stateSendTotals() {
uint8_t fieldId;
//for (uint8_t i = 0; i < 4; i++) {
if(mPos < 4) {
bool retained = true;
switch (mPos) {

Loading…
Cancel
Save