65 lines
3.4 KiB
C
65 lines
3.4 KiB
C
#ifndef NL_SETTINGS_H
|
|
#define NL_SETTINGS_H
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
|
|
#define NL_SSID_LEN 33
|
|
#define NL_PASS_LEN 65
|
|
#define NL_TOKEN_LEN 65
|
|
#define NL_NAME_LEN 33
|
|
|
|
typedef struct {
|
|
char wifi_ssid[NL_SSID_LEN];
|
|
char wifi_pass[NL_PASS_LEN];
|
|
char token[NL_TOKEN_LEN];
|
|
char name[NL_NAME_LEN];
|
|
uint8_t auth_all;
|
|
uint8_t power_on_behaviour; /* nl_pob_t */
|
|
uint16_t fade_in_ms;
|
|
uint16_t fade_out_ms;
|
|
uint8_t ota_pending; /* set before an OTA; the next boot restores the last state */
|
|
/* Appended fields: read_rec() in nl_settings.c pre-fills the struct with
|
|
* nl_settings_defaults() and only overwrites the bytes actually stored, so records
|
|
* written by an older firmware pick up the real default here, not zero. Keep adding new
|
|
* fields at the end for that to keep working. */
|
|
uint16_t transition_ms; /* default transition (ms) for a color/brightness/CT change
|
|
* while the lamp stays on; fade_in/fade_out still win when
|
|
* switching on or off. */
|
|
uint8_t wake_on_change; /* if set, such a change also switches the lamp on when it was
|
|
* off, unless the same call says "on": false. */
|
|
uint8_t _legacy_pad; /* war Fuellbyte im 208-Byte-Satz: neue Felder muessen
|
|
* bei oder hinter dem vorherigen sizeof beginnen, sonst
|
|
* ueberschreibt das Fuellbyte eines alten Datensatzes sie */
|
|
uint8_t sacn_enabled; /* Offset 208 - sACN/E1.31-Empfang aktiv (Vorgabe 1) */
|
|
uint16_t sacn_universe; /* 1..63999 (Vorgabe 1) */
|
|
uint16_t sacn_start_slot; /* 1..512 (Vorgabe 1) */
|
|
uint8_t sacn_hold; /* 0 = nach dem Timeout zurueck zum HA-Zustand, 1 = halten */
|
|
uint8_t _padding[1]; /* haelt sizeof auf einem Vielfachen von 4 */
|
|
uint8_t sacn_layout; /* Offset 216 - 0 = Dimmer voran, 1 = nur R,G,B (Vorgabe 1).
|
|
* Dieselbe Regel wie oben: neue Felder beginnen bei oder hinter
|
|
* dem vorherigen sizeof (216), sonst ueberschreibt das Fuellbyte
|
|
* eines aelteren Satzes sie. */
|
|
uint8_t _padding2[3]; /* haelt sizeof auf einem Vielfachen von 4 */
|
|
uint8_t standalone; /* Offset 220 - 1 = eigener AP statt Station. Dieselbe Regel
|
|
* wie oben: neue Felder beginnen bei oder hinter dem
|
|
* vorherigen sizeof (220), sonst ueberschreibt das
|
|
* Fuellbyte eines aelteren Satzes sie. */
|
|
uint8_t ap_channel; /* 0 = Vorgabe (6), sonst 1..13 */
|
|
uint8_t standalone_pulse; /* 1 = beim Start kurz pulsen (Vorgabe) */
|
|
uint8_t _padding3;
|
|
char ap_ssid[NL_SSID_LEN]; /* leer = "ninlight-<mac4>" */
|
|
char ap_pass[NL_PASS_LEN]; /* leer = einkompiliertes AP-Passwort. Taucht in keiner
|
|
* Antwort und in keiner Protokollzeile auf. */
|
|
uint8_t _padding4[2]; /* haelt sizeof auf einem Vielfachen von 4 (324) */
|
|
} nl_settings_t;
|
|
|
|
void nl_settings_defaults(nl_settings_t *s);
|
|
void nl_settings_init(uint32_t addr_a, uint32_t addr_b);
|
|
/* Returns false (and fills defaults) when no valid record exists. */
|
|
bool nl_settings_load(nl_settings_t *out);
|
|
int nl_settings_save(const nl_settings_t *s);
|
|
int nl_settings_erase(void);
|
|
|
|
#endif
|