diff options
author | Evgeny Zinoviev <me@ch1p.io> | 2022-11-28 05:45:20 +0300 |
---|---|---|
committer | Evgeny Zinoviev <me@ch1p.io> | 2022-12-18 00:00:27 +0300 |
commit | 7bb6daa4bf09947142e38ff468b7f62baae110fd (patch) | |
tree | c120e9ec800525116ad922e6c4cff21064a40538 /platformio/relayctl/src/config.h | |
parent | 16d47968b4938f3b60b97f374d45ad39bb0071b1 (diff) |
esp8266 relay controller wip
Diffstat (limited to 'platformio/relayctl/src/config.h')
-rw-r--r-- | platformio/relayctl/src/config.h | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/platformio/relayctl/src/config.h b/platformio/relayctl/src/config.h new file mode 100644 index 0000000..58a5f25 --- /dev/null +++ b/platformio/relayctl/src/config.h @@ -0,0 +1,34 @@ +#pragma once + +#include <Arduino.h> + +namespace homekit::config { + +struct ConfigFlags { + uint8_t wifi_configured: 1; + uint8_t node_configured: 1; + uint8_t reserved: 6; +} __attribute__((packed)); + +struct ConfigData { + // helpers + uint32_t crc = 0; + uint32_t magic = 0; + char node_id[16] = {0}; + char wifi_ssid[32] = {0}; + char wifi_psk[63] = {0}; + ConfigFlags flags {0}; + + // helper methods + char* escapeNodeId(char* buf, size_t len); +} __attribute__((packed)); + + +ConfigData read(); +bool write(ConfigData& data); +bool erase(); +bool erase(ConfigData& data); +bool isValid(ConfigData& data); +bool isDirty(ConfigData& data); + +}
\ No newline at end of file |