Add SSID and PSK config items

This commit is contained in:
2023-05-15 12:10:51 +01:00
parent 81dfa7fe1c
commit 87c9ca3c81
3 changed files with 103 additions and 2 deletions

View File

@@ -19,6 +19,8 @@
typedef enum {
HOSTNAME,
SSID,
PSK,
ITEM_COUNT,
} ItemIndex;
@@ -37,6 +39,14 @@ static Item state[ITEM_COUNT] = {
.id = "hostname",
.default_value = CONFIG_DEFAULT_HOSTNAME,
},
[SSID] = {
.id = "ssid",
.default_value = CONFIG_DEFAULT_SSID,
},
[PSK] = {
.id = "psk",
.default_value = CONFIG_DEFAULT_PSK,
},
};
static bool load(ItemIndex item)
@@ -185,3 +195,33 @@ void config_add_hostname_callback(ConfigCallback callback)
{
add_callback(HOSTNAME, callback);
}
void config_set_ssid(const char *ssid)
{
set(SSID, ssid);
}
size_t config_get_ssid(char *buffer, size_t buffer_size)
{
return get(SSID, buffer, buffer_size);
}
void config_add_ssid_callback(ConfigCallback callback)
{
add_callback(SSID, callback);
}
void config_set_psk(const char *psk)
{
set(PSK, psk);
}
size_t config_get_psk(char *buffer, size_t buffer_size)
{
return get(PSK, buffer, buffer_size);
}
void config_add_psk_callback(ConfigCallback callback)
{
add_callback(PSK, callback);
}