Add setting for SNTP server

This commit is contained in:
2023-05-15 23:21:47 +01:00
parent 7d84b95ad5
commit 62405149ad
3 changed files with 51 additions and 0 deletions

View File

@@ -23,6 +23,7 @@ typedef enum {
SSID,
PSK,
TIMEZONE,
SNTP_SERVER,
ITEM_COUNT,
} ItemIndex;
@@ -53,6 +54,10 @@ static Item state[ITEM_COUNT] = {
.id = "timezone",
.default_value = CONFIG_DEFAULT_TIMEZONE,
},
[SNTP_SERVER] = {
.id = "sntp-server",
.default_value = CONFIG_DEFAULT_SNTP_SERVER,
},
};
static bool load(ItemIndex item)
@@ -281,3 +286,18 @@ void settings_add_timezone_callback(SettingsCallback callback)
{
add_callback(TIMEZONE, callback);
}
void settings_set_sntp_server(const char *sntp_server)
{
set(SNTP_SERVER, sntp_server);
}
size_t settings_get_sntp_server(char *buffer, size_t buffer_size)
{
return get(SNTP_SERVER, buffer, buffer_size);
}
void settings_add_sntp_server_callback(SettingsCallback callback)
{
add_callback(SNTP_SERVER, callback);
}