Add timezone config item
This commit is contained in:
parent
be666164f4
commit
8be7ec1e28
@ -21,6 +21,7 @@ typedef enum {
|
||||
HOSTNAME,
|
||||
SSID,
|
||||
PSK,
|
||||
TIMEZONE,
|
||||
ITEM_COUNT,
|
||||
} ItemIndex;
|
||||
|
||||
@ -47,6 +48,10 @@ static Item state[ITEM_COUNT] = {
|
||||
.id = "psk",
|
||||
.default_value = CONFIG_DEFAULT_PSK,
|
||||
},
|
||||
[TIMEZONE] = {
|
||||
.id = "timezone",
|
||||
.default_value = CONFIG_DEFAULT_TIMEZONE,
|
||||
},
|
||||
};
|
||||
|
||||
static bool load(ItemIndex item)
|
||||
@ -225,3 +230,18 @@ void config_add_psk_callback(ConfigCallback callback)
|
||||
{
|
||||
add_callback(PSK, callback);
|
||||
}
|
||||
|
||||
void config_set_timezone(const char *timezone)
|
||||
{
|
||||
set(TIMEZONE, timezone);
|
||||
}
|
||||
|
||||
size_t config_get_timezone(char *buffer, size_t buffer_size)
|
||||
{
|
||||
return get(TIMEZONE, buffer, buffer_size);
|
||||
}
|
||||
|
||||
void config_add_timezone_callback(ConfigCallback callback)
|
||||
{
|
||||
add_callback(TIMEZONE, callback);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ size_t config_get_hostname(char *buffer, size_t buffer_size);
|
||||
/**
|
||||
* Add a callback for hostname updates.
|
||||
*
|
||||
* The function specified in the argument will be invoked whenever a
|
||||
* The function specified in the argument will be invoked whenever
|
||||
* the hostname is updated, with the new value as its argument. The
|
||||
* lifetime of the passed argument will be static, but the value may
|
||||
* be modified once the callback returns.
|
||||
@ -72,8 +72,8 @@ size_t config_get_ssid(char *buffer, size_t buffer_size);
|
||||
/**
|
||||
* Add a callback for SSID updates.
|
||||
*
|
||||
* The function specified in the argument will be invoked whenever a
|
||||
* the ssid is updated, with the new value as its argument. The
|
||||
* The function specified in the argument will be invoked whenever
|
||||
* the SSID is updated, with the new value as its argument. The
|
||||
* lifetime of the passed argument will be static, but the value may
|
||||
* be modified once the callback returns.
|
||||
*/
|
||||
@ -100,11 +100,40 @@ size_t config_get_psk(char *buffer, size_t buffer_size);
|
||||
/**
|
||||
* Add a callback for PSK updates.
|
||||
*
|
||||
* The function specified in the argument will be invoked whenever a
|
||||
* the psk is updated, with the new value as its argument. The
|
||||
* lifetime of the passed argument will be static, but the value may
|
||||
* be modified once the callback returns.
|
||||
* The function specified in the argument will be invoked whenever the
|
||||
* PSK is updated, with the new value as its argument. The lifetime of
|
||||
* the passed argument will be static, but the value may be modified
|
||||
* once the callback returns.
|
||||
*/
|
||||
void config_add_psk_callback(ConfigCallback callback);
|
||||
|
||||
/**
|
||||
* Set the timezone.
|
||||
*
|
||||
* The argument should be a null-terminated string, containing a
|
||||
* timezone spec in the format expected by tzset(). If the maximum
|
||||
* length is exceeded, the value will still be used, but will be
|
||||
* truncated.
|
||||
*/
|
||||
void config_set_timezone(const char *psk);
|
||||
|
||||
/**
|
||||
* Write the timezone into the given buffer.
|
||||
*
|
||||
* The length of the timezone is returned. If the value's size exceeds
|
||||
* the size of the buffer, nothing will be written to the buffer but
|
||||
* the length is still returned.
|
||||
*/
|
||||
size_t config_get_timezone(char *buffer, size_t buffer_size);
|
||||
|
||||
/**
|
||||
* Add a callback for timezone updates.
|
||||
*
|
||||
* The function specified in the argument will be invoked whenever the
|
||||
* timezone is updated, with the new value as its argument. The
|
||||
* lifetime of the passed argument will be static, but the value may
|
||||
* be modified once the callback returns.
|
||||
*/
|
||||
void config_add_timezone_callback(ConfigCallback callback);
|
||||
|
||||
#endif
|
||||
|
@ -8,4 +8,7 @@ menu "Bedside clock settings"
|
||||
config DEFAULT_PSK
|
||||
string "PSK for default WiFi network"
|
||||
default ""
|
||||
config DEFAULT_TIMEZONE
|
||||
string "Default timezone"
|
||||
default "Europe/London"
|
||||
endmenu
|
||||
|
Loading…
x
Reference in New Issue
Block a user