non blocking - first review

- discord 0.8.5902
- stay longer on expected rx channel to wait for first frame 
- stick to looping over 5 channels for MI (after first frame or timeout)
This commit is contained in:
rejoe2 2024-01-20 10:03:57 +01:00 committed by GitHub
parent 5b3b9ca88e
commit ac0c93cb40
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 72 additions and 44 deletions

View file

@ -106,7 +106,7 @@ void app::setup() {
#endif
// Plugins
#if defined(PLUGIN_DISPLAY)
if (mConfig->plugin.display.type != 0)
if (DISP_TYPE_T0_NONE != mConfig->plugin.display.type)
#if defined(ESP32)
mDisplay.setup(this, &mConfig->plugin.display, &mSys, &mNrfRadio, &mCmtRadio, &mTimestamp);
#else
@ -184,7 +184,7 @@ void app::regularTickers(void) {
everySec(std::bind(&WebType::tickSecond, &mWeb), "webSc");
// Plugins
#if defined(PLUGIN_DISPLAY)
if (mConfig->plugin.display.type != 0)
if (DISP_TYPE_T0_NONE != mConfig->plugin.display.type)
everySec(std::bind(&DisplayType::tickerSecond, &mDisplay), "disp");
#endif
every(std::bind(&PubSerialType::tick, &mPubSerial), 5, "uart");
@ -350,6 +350,14 @@ void app::tickSunrise(void) {
#endif
}
//-----------------------------------------------------------------------------
void app::notAvailChanged(void) {
#if defined(ENABLE_MQTT)
if (mMqttEnabled)
mMqtt.notAvailChanged(mAllIvNotAvail);
#endif
}
//-----------------------------------------------------------------------------
void app::tickZeroValues(void) {
zeroIvValues(!CHECK_AVAIL, SKIP_YIELD_DAY);
@ -401,6 +409,7 @@ void app::tickMidnight(void) {
//-----------------------------------------------------------------------------
void app::tickSend(void) {
bool notAvail = true;
uint8_t fill = mCommunication.getFillState();
uint8_t max = mCommunication.getMaxFill();
if((max-MAX_NUM_INVERTERS) <= fill) {
@ -426,6 +435,9 @@ void app::tickSend(void) {
if(!iv->radio->isChipConnected())
continue;
if(InverterStatus::OFF != iv->status)
notAvail = false;
iv->tickSend([this, iv](uint8_t cmd, bool isDevControl) {
if(isDevControl)
mCommunication.addImportant(iv, cmd);
@ -435,6 +447,10 @@ void app::tickSend(void) {
}
}
if(mAllIvNotAvail != notAvail)
once(std::bind(&app::notAvailChanged, this), 1, "avail");
mAllIvNotAvail = notAvail;
updateLed();
}
@ -533,6 +549,7 @@ void app::resetSystem(void) {
#endif
mSendFirst = true;
mAllIvNotAvail = true;
mSunrise = 0;
mSunset = 0;