From 04569c6a10afe2a662a22c77c7977746f72ea7e1 Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Mon, 8 Mar 2021 20:58:41 +0300 Subject: [PATCH] relay: stable configuration IDs Custom provider cannot 'shadow' the relays from the config. e.g. lights will use the id=0 when relay control is enabled, and we should not use relayGpio0, relayPulse0, relayBoot0 and etc. --- code/espurna/relay.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/espurna/relay.cpp b/code/espurna/relay.cpp index abca2633..0db68037 100644 --- a/code/espurna/relay.cpp +++ b/code/espurna/relay.cpp @@ -1985,9 +1985,10 @@ RelayProviderBasePtr _relaySetupProvider(unsigned char index) { } void _relaySetup() { - _relays.reserve(_relayAdhocPins()); + auto relays = _relays.size(); + _relays.reserve(relays + _relayAdhocPins()); - for (unsigned char id = 0; id < RelaysMax; ++id) { + for (unsigned char id = relays; id < RelaysMax; ++id) { auto impl = _relaySetupProvider(id); if (!impl) { break;