feat(settings): Felder fuer den Standalone-AP-Modus
This commit is contained in:
@@ -275,6 +275,55 @@ static void test_record_without_layout_gets_the_default(void)
|
||||
TEST_ASSERT_EQUAL_UINT8(1, out.sacn_layout);
|
||||
}
|
||||
|
||||
static void test_standalone_defaults(void)
|
||||
{
|
||||
nl_settings_t s;
|
||||
TEST_ASSERT_FALSE(nl_settings_load(&s));
|
||||
TEST_ASSERT_EQUAL_UINT8(0, s.standalone);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, s.ap_channel); /* 0 heisst "Vorgabe 6" */
|
||||
TEST_ASSERT_EQUAL_UINT8(1, s.standalone_pulse);
|
||||
TEST_ASSERT_EQUAL_STRING("", s.ap_ssid);
|
||||
TEST_ASSERT_EQUAL_STRING("", s.ap_pass);
|
||||
}
|
||||
|
||||
static void test_standalone_roundtrip(void)
|
||||
{
|
||||
nl_settings_t in = sample("ap"), out;
|
||||
in.standalone = 1;
|
||||
in.ap_channel = 11;
|
||||
in.standalone_pulse = 0;
|
||||
strcpy(in.ap_ssid, "Wohnzimmerlampe");
|
||||
strcpy(in.ap_pass, "geheim123");
|
||||
TEST_ASSERT_EQUAL_INT(0, nl_settings_save(&in));
|
||||
TEST_ASSERT_TRUE(nl_settings_load(&out));
|
||||
TEST_ASSERT_EQUAL_UINT8(1, out.standalone);
|
||||
TEST_ASSERT_EQUAL_UINT8(11, out.ap_channel);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, out.standalone_pulse);
|
||||
TEST_ASSERT_EQUAL_STRING("Wohnzimmerlampe", out.ap_ssid);
|
||||
TEST_ASSERT_EQUAL_STRING("geheim123", out.ap_pass);
|
||||
}
|
||||
|
||||
/* Ein Datensatz aus einer Firmware VOR dem Standalone-Modus: die neuen Felder muessen
|
||||
* als echte Vorgaben zurueckkommen, nicht als Null. Sonst stuende standalone_pulse nach
|
||||
* dem Update auf jeder Lampe auf 0 - der Startpuls waere still abgeschaltet. */
|
||||
static void test_record_without_standalone_gets_defaults(void)
|
||||
{
|
||||
nl_settings_t in = sample("alt"), out;
|
||||
uint32_t crc;
|
||||
nl_settings_save(&in);
|
||||
{
|
||||
uint16_t shorter = 220u; /* sizeof(nl_settings_t) vor diesem Zweig */
|
||||
memset(&fake_flash_mem[NL_FL_SETTINGS_A + 12 + 217], 0, 3); /* Fuellbytes */
|
||||
memcpy(&fake_flash_mem[NL_FL_SETTINGS_A + 6], &shorter, 2);
|
||||
crc = nl_crc32(0, &fake_flash_mem[NL_FL_SETTINGS_A], 12 + shorter);
|
||||
memcpy(&fake_flash_mem[NL_FL_SETTINGS_A + 12 + shorter], &crc, 4);
|
||||
}
|
||||
TEST_ASSERT_TRUE(nl_settings_load(&out));
|
||||
TEST_ASSERT_EQUAL_STRING("alt", out.name);
|
||||
TEST_ASSERT_EQUAL_UINT8(0, out.standalone);
|
||||
TEST_ASSERT_EQUAL_UINT8(1, out.standalone_pulse);
|
||||
}
|
||||
|
||||
static void test_record_size_stays_aligned(void)
|
||||
{
|
||||
TEST_ASSERT_EQUAL_UINT(0, sizeof(nl_settings_t) % 4u);
|
||||
@@ -301,5 +350,8 @@ int main(void)
|
||||
RUN_TEST(test_sacn_layout_roundtrip);
|
||||
RUN_TEST(test_record_without_layout_gets_the_default);
|
||||
RUN_TEST(test_record_size_stays_aligned);
|
||||
RUN_TEST(test_standalone_defaults);
|
||||
RUN_TEST(test_standalone_roundtrip);
|
||||
RUN_TEST(test_record_without_standalone_gets_defaults);
|
||||
return UNITY_END();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user