mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 11:36:59 +03:00
nvs configuration fixes
This commit is contained in:
65
alltags.txt
Normal file
65
alltags.txt
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.15
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.20
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.47
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.49
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.50
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.51
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.52
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.53
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.54
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.55
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.59
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.60
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.61
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.62
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.63
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.64
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.65
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.66
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/I2S-4MFlash-v0.1.67
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/SqueezeAmp-v0.1.13
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/SqueezeAmp-v0.1.14
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/SqueezeAmp-v0.1.15
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/SqueezeAmp-v0.1.20
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/WiFi-Manager/SqueezeAmp-v0.1.66
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.12-I2S-4MFlash
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.12-SqueezeAmp
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.16-I2S-4MFlash
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.16-SqueezeAmp
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.44-I2S-4MFlash
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.44-SqueezeAmp
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.45-I2S-4MFlash
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.45-SqueezeAmp
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.46-I2S-4MFlash
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.46-SqueezeAmp
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.47-I2S-4MFlash
|
||||||
|
d9c6c78df2f3ba49d74d91cf246f300a881af742 refs/tags/v0.1.47-SqueezeAmp
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.5-I2S-4MFlash
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.5-SqueezeAmp
|
||||||
|
c34cf06be18ea4ab14ce28d77e1d48d0a1bb70f7 refs/tags/v0.1.50-I2S-4MFlash
|
||||||
|
c34cf06be18ea4ab14ce28d77e1d48d0a1bb70f7 refs/tags/v0.1.50-SqueezeAmp
|
||||||
|
c34cf06be18ea4ab14ce28d77e1d48d0a1bb70f7 refs/tags/v0.1.51-I2S-4MFlash
|
||||||
|
c34cf06be18ea4ab14ce28d77e1d48d0a1bb70f7 refs/tags/v0.1.51-SqueezeAmp
|
||||||
|
20edae43287b4c2d8942ea4263ccf9547f310946 refs/tags/v0.1.52-I2S-4MFlash
|
||||||
|
20edae43287b4c2d8942ea4263ccf9547f310946 refs/tags/v0.1.52-SqueezeAmp
|
||||||
|
964bb4d57d35bca06badfb504534b42e9b3b8678 refs/tags/v0.1.53-I2S-4MFlash
|
||||||
|
964bb4d57d35bca06badfb504534b42e9b3b8678 refs/tags/v0.1.53-SqueezeAmp
|
||||||
|
71531bcdc20d7c7da254699855eb2e1e7b2bd48f refs/tags/v0.1.54-I2S-4MFlash
|
||||||
|
71531bcdc20d7c7da254699855eb2e1e7b2bd48f refs/tags/v0.1.54-SqueezeAmp
|
||||||
|
9c56cfb1d05862bca5763b3fbe9911b4bab9619a refs/tags/v0.1.55-I2S-4MFlash
|
||||||
|
9c56cfb1d05862bca5763b3fbe9911b4bab9619a refs/tags/v0.1.55-SqueezeAmp
|
||||||
|
53369475dc85471a4d7f2d78c62f37fcd7f6e3da refs/tags/v0.1.57-I2S-4MFlash
|
||||||
|
53369475dc85471a4d7f2d78c62f37fcd7f6e3da refs/tags/v0.1.57-SqueezeAmp
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.6-I2S-4MFlash
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.6-SqueezeAmp
|
||||||
|
eef9ae969cdfd1a62d7057d8edf2c31af60804f3 refs/tags/v0.1.67-WiFi-Manager/I2S-4MFlash
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.71-I2S-4MFlash
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.71-SqueezeAmp
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.72-I2S-4MFlash
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.72-SqueezeAmp
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.73-I2S-4MFlash
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.73-SqueezeAmp
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.74-I2S-4MFlash
|
||||||
|
2cf87d5943caa0d0b15c8692482ff72308c0c0a8 refs/tags/v0.1.74-SqueezeAmp
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.9-I2S-4MFlash
|
||||||
|
3bd886b8dff0fb5bc59079e83f1d283097a14697 refs/tags/v0.1.9-SqueezeAmp
|
||||||
@@ -47,7 +47,7 @@ static const type_str_pair_t type_str_pair[] = {
|
|||||||
|
|
||||||
static const size_t TYPE_STR_PAIR_SIZE = sizeof(type_str_pair) / sizeof(type_str_pair[0]);
|
static const size_t TYPE_STR_PAIR_SIZE = sizeof(type_str_pair) / sizeof(type_str_pair[0]);
|
||||||
static const char *ARG_TYPE_STR = "type can be: i8, u8, i16, u16 i32, u32 i64, u64, str, blob";
|
static const char *ARG_TYPE_STR = "type can be: i8, u8, i16, u16 i32, u32 i64, u64, str, blob";
|
||||||
char current_namespace[] = "squeezelite-esp32";
|
char current_namespace[] = "config";
|
||||||
static const char * TAG = "platform_esp32";
|
static const char * TAG = "platform_esp32";
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
|
|||||||
@@ -139,32 +139,47 @@ char* http_server_search_header(char *request, char *header_name, int *len, char
|
|||||||
*len = 0;
|
*len = 0;
|
||||||
char *ret = NULL;
|
char *ret = NULL;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
|
int currentLength=0;
|
||||||
|
|
||||||
|
ESP_LOGD(TAG, "header name: [%s]\nRequest: %s", header_name, request);
|
||||||
ptr = strstr(request, header_name);
|
ptr = strstr(request, header_name);
|
||||||
if (ptr) {
|
|
||||||
|
|
||||||
|
if (ptr!=NULL) {
|
||||||
ret = ptr + strlen(header_name);
|
ret = ptr + strlen(header_name);
|
||||||
ptr = ret;
|
ptr = ret;
|
||||||
|
currentLength=(int)(ptr-request);
|
||||||
|
ESP_LOGD(TAG, "found string at %d", currentLength);
|
||||||
|
|
||||||
while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r' && *ptr != ':' ) {
|
while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r' && *ptr != ':' ) {
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
if(*ptr==':'){
|
if(*ptr==':'){
|
||||||
|
currentLength=(int)(ptr-ret);
|
||||||
|
ESP_LOGD(TAG, "Found parameter name end, length : %d", currentLength);
|
||||||
// save the parameter name: the string between header name and ":"
|
// save the parameter name: the string between header name and ":"
|
||||||
strncpy(parm_name,ret,(ptr-ret-1>parm_name_max_len?parm_name_max_len:ptr-ret-1));
|
strncpy(parm_name,ret,(currentLength>parm_name_max_len?parm_name_max_len:currentLength));
|
||||||
|
ESP_LOGD(TAG, "Found parameter name : %s ", parm_name);
|
||||||
ptr++;
|
ptr++;
|
||||||
while (*ptr == ' ' ) {
|
while (*ptr == ' ' ) {
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
ret=ptr;
|
||||||
while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r') {
|
while (*ptr != '\0' && *ptr != '\n' && *ptr != '\r') {
|
||||||
(*len)++;
|
(*len)++;
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
// Terminate value inside its actual buffer so we can treat it as individual string
|
// Terminate value inside its actual buffer so we can treat it as individual string
|
||||||
*ptr='\0';
|
*ptr='\0';
|
||||||
*next_position=ptr;
|
currentLength=(int)(ptr-ret);
|
||||||
|
ESP_LOGD(TAG, "Found parameter value end, length : %d, value: %s", currentLength,ret );
|
||||||
|
|
||||||
|
*next_position=++ptr;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
ESP_LOGD(TAG, "No more match for : %s", header_name);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -314,53 +329,48 @@ void http_server_netconn_serve(struct netconn *conn) {
|
|||||||
else if(strstr(line, "POST /config.json ")){
|
else if(strstr(line, "POST /config.json ")){
|
||||||
ESP_LOGI(TAG,"Serving POST config.json");
|
ESP_LOGI(TAG,"Serving POST config.json");
|
||||||
|
|
||||||
if(wifi_manager_lock_json_buffer(( TickType_t ) 10)){
|
int i=1;
|
||||||
int i=1;
|
int lenA=0;
|
||||||
int lenA=0;
|
char * last_parm=save_ptr;
|
||||||
char * last_parm=save_ptr;
|
char * next_parm=save_ptr;
|
||||||
char * next_parm=save_ptr;
|
char last_parm_name[41]={0};
|
||||||
char last_parm_name[41]={0};
|
uint8_t autoexec_flag=0;
|
||||||
uint8_t autoexec_flag=0;
|
bool bErrorFound=false;
|
||||||
bool bErrorFound=false;
|
|
||||||
|
|
||||||
while(last_parm!=NULL){
|
while(last_parm!=NULL){
|
||||||
// Search will return
|
// Search will return
|
||||||
memset(last_parm_name,0x00,sizeof(last_parm_name));
|
ESP_LOGI(TAG, "Getting parameters from X-Custom headers");
|
||||||
last_parm = http_server_search_header(next_parm, "X-Custom- ", &lenA, last_parm_name, sizeof(last_parm_name)-1,&next_parm);
|
memset(last_parm_name,0x00,sizeof(last_parm_name));
|
||||||
ESP_LOGD(TAG, "http_server_netconn_serve: config.json/ call, found parameter %s=%s, length %i", last_parm_name, last_parm, lenA);
|
last_parm = http_server_search_header(next_parm, "X-Custom-", &lenA, last_parm_name, sizeof(last_parm_name)-1,&next_parm);
|
||||||
if(last_parm!=NULL){
|
if(last_parm!=NULL){
|
||||||
if(strstr(last_parm_name, "autoexec")){
|
ESP_LOGI(TAG, "http_server_netconn_serve: config.json/ call, found parameter %s=%s, length %i", last_parm_name, last_parm, lenA);
|
||||||
autoexec_flag = atoi(last_parm);
|
if(strcmp(last_parm_name, "autoexec")==0){
|
||||||
wifi_manager_save_autoexec_flag(autoexec_flag);
|
autoexec_flag = atoi(last_parm);
|
||||||
|
wifi_manager_save_autoexec_flag(autoexec_flag);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(lenA < MAX_COMMAND_LINE_SIZE ){
|
||||||
|
ESP_LOGD(TAG, "http_server_netconn_serve: config.json/ Storing parameter");
|
||||||
|
wifi_manager_save_autoexec_config(last_parm,last_parm_name,lenA);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
if(lenA < MAX_COMMAND_LINE_SIZE ){
|
{
|
||||||
ESP_LOGD(TAG, "http_server_netconn_serve: config.json/ Storing parameter");
|
char szErrorPrefix[]="{ status: \"value length is too long for ";
|
||||||
wifi_manager_save_autoexec_config(last_parm,last_parm_name,lenA);
|
char szErrorSuffix[]="{ status: \"value length is too long for ";
|
||||||
}
|
netconn_write(conn, szErrorPrefix, strlen(szErrorPrefix), NETCONN_NOCOPY);
|
||||||
else
|
ESP_LOGE(TAG,"length is too long : %s = %s", last_parm_name, last_parm);
|
||||||
{
|
last_parm=NULL;
|
||||||
char szErrorPrefix[]="{ status: \"value length is too long for ";
|
|
||||||
char szErrorSuffix[]="{ status: \"value length is too long for ";
|
|
||||||
netconn_write(conn, szErrorPrefix, strlen(szErrorPrefix), NETCONN_NOCOPY);
|
|
||||||
ESP_LOGE(TAG,"length is too long : %s = %s", last_parm_name, last_parm);
|
|
||||||
last_parm=NULL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(bErrorFound){
|
}
|
||||||
netconn_write(conn, http_400_hdr, sizeof(http_400_hdr) - 1, NETCONN_NOCOPY); //400 invalid request
|
if(bErrorFound){
|
||||||
}
|
netconn_write(conn, http_400_hdr, sizeof(http_400_hdr) - 1, NETCONN_NOCOPY); //400 invalid request
|
||||||
else{
|
|
||||||
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); //200ok
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
netconn_write(conn, http_503_hdr, sizeof(http_503_hdr) - 1, NETCONN_NOCOPY);
|
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); //200ok
|
||||||
ESP_LOGE(TAG, "http_server_netconn_serve: GET /status failed to obtain mutex");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(strstr(line, "POST /connect.json ")) {
|
else if(strstr(line, "POST /connect.json ")) {
|
||||||
ESP_LOGI(TAG, "http_server_netconn_serve: POST /connect.json");
|
ESP_LOGI(TAG, "http_server_netconn_serve: POST /connect.json");
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ struct wifi_settings_t wifi_settings = {
|
|||||||
.sta_static_ip = 0,
|
.sta_static_ip = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
const char wifi_manager_nvs_namespace[] = "espwifimgr";
|
|
||||||
|
const char wifi_manager_nvs_namespace[] = "config";
|
||||||
extern char current_namespace[];
|
extern char current_namespace[];
|
||||||
|
|
||||||
EventGroupHandle_t wifi_manager_event_group;
|
EventGroupHandle_t wifi_manager_event_group;
|
||||||
@@ -195,8 +196,11 @@ char * wifi_manager_alloc_get_config(char * name, size_t * l){
|
|||||||
|
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
ESP_LOGD(TAG, "About to get config value %s from flash",name);
|
ESP_LOGD(TAG, "About to get config value %s from flash",name);
|
||||||
|
esp_err_t esp_err=nvs_open(current_namespace, NVS_READWRITE, &handle);
|
||||||
if (nvs_open(current_namespace, NVS_READWRITE, &handle) == ESP_OK) {
|
if(esp_err==ESP_ERR_NVS_NOT_INITIALIZED){
|
||||||
|
ESP_LOGE(TAG,"Unable to open nvs namespace %s. nvs is not initialized.",wifi_manager_nvs_namespace);
|
||||||
|
}
|
||||||
|
else if( esp_err == ESP_OK) {
|
||||||
if (nvs_get_str(handle, name, NULL, &len)==ESP_OK) {
|
if (nvs_get_str(handle, name, NULL, &len)==ESP_OK) {
|
||||||
value=(char *)malloc(len);
|
value=(char *)malloc(len);
|
||||||
memset(value,0x0, len);
|
memset(value,0x0, len);
|
||||||
@@ -212,7 +216,9 @@ char * wifi_manager_alloc_get_config(char * name, size_t * l){
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ESP_LOGE(TAG,"Unable to open nvs namespace %s",wifi_manager_nvs_namespace);
|
char szErrorDesc[101]={0};
|
||||||
|
esp_err_to_name_r(esp_err , szErrorDesc, sizeof(szErrorDesc)-1);
|
||||||
|
ESP_LOGE(TAG,"Unable to open nvs namespace %s. Error: %d, %s", wifi_manager_nvs_namespace,esp_err, szErrorDesc);
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
|
||||||
@@ -221,10 +227,15 @@ char * wifi_manager_alloc_get_config(char * name, size_t * l){
|
|||||||
esp_err_t wifi_manager_save_autoexec_flag(uint8_t flag){
|
esp_err_t wifi_manager_save_autoexec_flag(uint8_t flag){
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
esp_err_t esp_err;
|
esp_err_t esp_err;
|
||||||
ESP_LOGI(TAG, "About to save config to flash");
|
ESP_LOGI(TAG, "About to save autoexec flag to flash");
|
||||||
esp_err=nvs_open(current_namespace, NVS_READWRITE, &handle);
|
esp_err=nvs_open(current_namespace, NVS_READWRITE, &handle);
|
||||||
if (esp_err != ESP_OK) {
|
if(esp_err==ESP_ERR_NVS_NOT_INITIALIZED){
|
||||||
ESP_LOGE(TAG,"Unable to open nvs namespace %s",wifi_manager_nvs_namespace);
|
ESP_LOGE(TAG,"Unable to open nvs namespace %s. nvs is not initialized.",wifi_manager_nvs_namespace);
|
||||||
|
}
|
||||||
|
else if (esp_err != ESP_OK) {
|
||||||
|
char szErrorDesc[101]={0};
|
||||||
|
esp_err_to_name_r(esp_err , szErrorDesc, sizeof(szErrorDesc)-1);
|
||||||
|
ESP_LOGE(TAG,"Unable to open nvs namespace %s. Error: %s", wifi_manager_nvs_namespace, szErrorDesc);
|
||||||
return esp_err;
|
return esp_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -251,13 +262,17 @@ esp_err_t wifi_manager_save_autoexec_flag(uint8_t flag){
|
|||||||
esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
esp_err_t wifi_manager_save_autoexec_config(char * value, char * name, int len){
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
esp_err_t esp_err;
|
esp_err_t esp_err;
|
||||||
ESP_LOGI(TAG, "About to save config to flash");
|
ESP_LOGI(TAG, "About to save config to flash. Name: %s, value: %s", name,value);
|
||||||
esp_err = nvs_open(current_namespace, NVS_READWRITE, &handle);
|
esp_err = nvs_open(current_namespace, NVS_READWRITE, &handle);
|
||||||
if (esp_err != ESP_OK) {
|
if(esp_err==ESP_ERR_NVS_NOT_INITIALIZED){
|
||||||
ESP_LOGE(TAG,"Unable to open nvs namespace %s",current_namespace);
|
ESP_LOGE(TAG,"Unable to open nvs namespace %s. nvs is not initialized.",wifi_manager_nvs_namespace);
|
||||||
return esp_err;
|
|
||||||
}
|
}
|
||||||
|
else if (esp_err != ESP_OK) {
|
||||||
|
char szErrorDesc[101]={0};
|
||||||
|
esp_err_to_name_r(esp_err , szErrorDesc, sizeof(szErrorDesc)-1);
|
||||||
|
ESP_LOGE(TAG,"Unable to open nvs namespace %s. Error: %d, %s", wifi_manager_nvs_namespace, esp_err, szErrorDesc);
|
||||||
|
return esp_err;
|
||||||
|
}
|
||||||
esp_err = nvs_set_str(handle, name, value);
|
esp_err = nvs_set_str(handle, name, value);
|
||||||
if (esp_err != ESP_OK){
|
if (esp_err != ESP_OK){
|
||||||
ESP_LOGE(TAG,"Unable to save value %s=%s",name,value);
|
ESP_LOGE(TAG,"Unable to save value %s=%s",name,value);
|
||||||
|
|||||||
Reference in New Issue
Block a user