Browse Source

domoticz: proper datastructure for mask (#2049)

master
Max Prokhorov 5 years ago
committed by GitHub
parent
commit
b059ce9445
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 4 deletions
  1. +2
    -4
      code/espurna/domoticz.ino

+ 2
- 4
code/espurna/domoticz.ino View File

@ -11,10 +11,11 @@ Copyright (C) 2016-2019 by Xose Pérez <xose dot perez at gmail dot com>
#include "relay.h" #include "relay.h"
#include "broker.h" #include "broker.h"
#include <bitset>
#include <ArduinoJson.h> #include <ArduinoJson.h>
bool _dcz_enabled = false; bool _dcz_enabled = false;
std::vector<bool> _dcz_relay_state;
std::bitset<RELAYS_MAX> _dcz_relay_state;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// Private methods // Private methods
@ -41,12 +42,10 @@ void _domoticzMqttSubscribe(bool value) {
} }
bool _domoticzStatus(unsigned char id) { bool _domoticzStatus(unsigned char id) {
if (id >= _dcz_relay_state.size()) return false;
return _dcz_relay_state[id]; return _dcz_relay_state[id];
} }
void _domoticzStatus(unsigned char id, bool status) { void _domoticzStatus(unsigned char id, bool status) {
if (id >= _dcz_relay_state.size()) return;
_dcz_relay_state[id] = status; _dcz_relay_state[id] = status;
relayStatus(id, status); relayStatus(id, status);
} }
@ -220,7 +219,6 @@ void _domoticzWebSocketOnConnected(JsonObject& root) {
#endif // WEB_SUPPORT #endif // WEB_SUPPORT
void _domoticzRelayConfigure(size_t size) { void _domoticzRelayConfigure(size_t size) {
_dcz_relay_state.reserve(size);
for (size_t n = 0; n < size; ++n) { for (size_t n = 0; n < size; ++n) {
_dcz_relay_state[n] = relayStatus(n); _dcz_relay_state[n] = relayStatus(n);
} }


Loading…
Cancel
Save