mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-30 01:06:11 +02:00
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:
parent
5b3b9ca88e
commit
ac0c93cb40
8 changed files with 72 additions and 44 deletions
21
src/app.cpp
21
src/app.cpp
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue