Browse Source

relay: fix stm & dual init with external port

pull/2552/head
Maxim Prokhorov 1 year ago
parent
commit
66a351b012
1 changed files with 22 additions and 14 deletions
  1. +22
    -14
      code/espurna/relay.cpp

+ 22
- 14
code/espurna/relay.cpp View File

@ -1367,16 +1367,18 @@ public:
}
bool setup() override {
static bool once { false };
if (!once) {
once = true;
static bool once = ([]() {
const auto port = uartPort(RELAY_PROVIDER_DUAL_PORT - 1);
if (port) {
_port = port->stream;
DualProvider::_port = port->stream;
espurnaRegisterLoop(loop);
return true;
}
}
return true;
return false;
})();
return once;
}
void change(bool) override {
@ -1456,13 +1458,14 @@ public:
}
private:
Stream* _port { nullptr };
size_t _id;
static std::vector<DualProvider*> _instances;
static Stream* _port;
};
std::vector<DualProvider*> DualProvider::_instances;
Stream* DualProvider::_port = nullptr;
#endif // RELAY_PROVIDER_DUAL_SUPPORT
@ -1481,15 +1484,18 @@ public:
}
bool setup() override {
static bool once { false };
if (!once) {
once = true;
static bool once = ([]() {
const auto port = uartPort(RELAY_PROVIDER_STM_PORT - 1);
if (port) {
_port = port->stream;
StmProvider::_port = port->stream;
espurnaRegisterLoop(loop);
return true;
}
}
return true;
return false;
})();
return once;
}
void boot(bool) override {
@ -1514,10 +1520,12 @@ public:
}
private:
Stream* _port;
size_t _id;
static Stream* _port;
};
Stream* StmProvider::_port = nullptr;
#endif // RELAY_PROVIDER_STM_SUPPORT
// -----------------------------------------------------------------------------


Loading…
Cancel
Save