feat: Licht nach einem OTA wie bei power_on_behaviour=last wiederherstellen
Spec 8.2 verlangt, dass ein durch ein Update ausgelöster Neustart nicht wie ein Stromausfall wirkt: Das Flag ota_pending wurde bisher nur geschrieben und beim nächsten Boot wieder gelöscht, nl_boot_state() wendet aber weiterhin das normale power_on_behaviour an. Eine eingeschaltete Lampe mit pob=off kam nach einem Update aus zurück, mit pob=on umgekehrt. nl_boot_state() bekommt dafür ein Argument after_ota; ist ein gespeicherter Zustand vorhanden, wird er unverändert übernommen. Ohne gespeicherten Zustand gelten weiterhin die normalen Regeln. Hosttests: vier neue Fälle in test_boot_state.c (pob=off/on über ein OTA, Sanitisierung bleibt aktiv, kein gespeicherter Zustand).
This commit is contained in:
@@ -20,7 +20,8 @@ nl_light_state_t nl_boot_default_state(const nl_board_t *b)
|
||||
return s;
|
||||
}
|
||||
|
||||
nl_light_state_t nl_boot_state(nl_pob_t pob, const nl_light_state_t *last, const nl_board_t *b)
|
||||
nl_light_state_t nl_boot_state(nl_pob_t pob, const nl_light_state_t *last, const nl_board_t *b,
|
||||
bool after_ota)
|
||||
{
|
||||
nl_light_state_t s = last ? *last : nl_boot_default_state(b);
|
||||
|
||||
@@ -30,6 +31,12 @@ nl_light_state_t nl_boot_state(nl_pob_t pob, const nl_light_state_t *last, const
|
||||
s.mode = NL_MODE_WHITE;
|
||||
s.ct = clamp_ct(s.ct, b);
|
||||
|
||||
/* Spec 8.2: after an OTA the light is restored effectively as power_on_behaviour = last -
|
||||
* a reboot triggered by an update must not look like a power cut to the user. Without a
|
||||
* stored state there is nothing to restore, so the normal rules apply. */
|
||||
if (after_ota && last)
|
||||
return s;
|
||||
|
||||
if (pob == NL_POB_ON)
|
||||
s.on = true;
|
||||
else if (pob == NL_POB_OFF)
|
||||
|
||||
@@ -9,8 +9,12 @@
|
||||
/* Warm white, 100 %, on. */
|
||||
nl_light_state_t nl_boot_default_state(const nl_board_t *b);
|
||||
|
||||
/* State to apply after power-up. last == NULL when nothing is stored. Stored values are sanitised. */
|
||||
nl_light_state_t nl_boot_state(nl_pob_t pob, const nl_light_state_t *last, const nl_board_t *b);
|
||||
/* State to apply after power-up. last == NULL when nothing is stored. Stored values are sanitised.
|
||||
* after_ota: this boot follows a firmware update (settings flag ota_pending). Spec 8.2 - such a
|
||||
* reboot is not a power cut, so the light comes back effectively as power_on_behaviour = last,
|
||||
* whatever pob says. */
|
||||
nl_light_state_t nl_boot_state(nl_pob_t pob, const nl_light_state_t *last, const nl_board_t *b,
|
||||
bool after_ota);
|
||||
|
||||
bool nl_light_state_equal(const nl_light_state_t *a, const nl_light_state_t *b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user