2022-12-14 12:04:09 +01:00

28 lines
940 B
C

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "configuration.h"
#include "scd4x_data.h"
#include "nvs_flash.h"
#include "sdkconfig.h"
#include "esp_log.h"
void init_conf_from_nvs(configuration_data_t* conf){
nvs_handle_t nvs;
ESP_ERROR_CHECK(nvs_open("battms", NVS_READONLY, &nvs));
conf->battery_conf = get_battery_configuration(nvs);
ESP_ERROR_CHECK(nvs_open("leds", NVS_READONLY, &nvs));
conf->leds = get_led_configuration(nvs);
nvs_get_u8(nvs, "led_nb", &conf->led_nb);
ESP_ERROR_CHECK(nvs_open("main", NVS_READONLY, &nvs)); // todo: move to namespaces
conf->sensor = get_sensor_configuration(nvs);
conf->measure = conf->sensor->measure;
nvs_get_u8(nvs, "wireless_conf", &conf->wireless);
conf->wifi_config = get_ap_config(nvs);
size_t str_size = sizeof(conf->hostname);
ESP_ERROR_CHECK(nvs_get_str(nvs, "name", conf->hostname, &str_size));
ESP_LOGI("AAA", "%d", str_size);
}