check for error when fetching hostname in case its not set
This commit is contained in:
parent
e8fc417c83
commit
66a2d21065
1 changed files with 3 additions and 3 deletions
|
@ -46,9 +46,9 @@ void cmd_hostname_register(lora32_cfg_t *lora) {
|
||||||
size_t hostname_len;
|
size_t hostname_len;
|
||||||
|
|
||||||
printf("nvs_handle: %d\n\n\n", lorcomm_cfg.nvs_handle);
|
printf("nvs_handle: %d\n\n\n", lorcomm_cfg.nvs_handle);
|
||||||
nvs_get_str(lorcomm_cfg.nvs_handle, "hostname", NULL, &hostname_len);
|
esp_err_t err = nvs_get_str(lorcomm_cfg.nvs_handle, "hostname", NULL, &hostname_len);
|
||||||
|
|
||||||
if(hostname_len > 0) {
|
if(err == ESP_OK && hostname_len > 0) {
|
||||||
printf("hostname_len: %d\n", hostname_len);
|
printf("hostname_len: %d\n", hostname_len);
|
||||||
lorcomm_cfg.hostname = malloc(hostname_len);
|
lorcomm_cfg.hostname = malloc(hostname_len);
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ void cmd_hostname_register(lora32_cfg_t *lora) {
|
||||||
printf("hostname: %s\n", lorcomm_cfg.hostname);
|
printf("hostname: %s\n", lorcomm_cfg.hostname);
|
||||||
} else {
|
} else {
|
||||||
lorcomm_cfg.hostname = malloc(7);
|
lorcomm_cfg.hostname = malloc(7);
|
||||||
memcpy(lorcomm_cfg.hostname, "lorcomm", 7);
|
memcpy(lorcomm_cfg.hostname, "lorcomm\0", 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
const esp_console_cmd_t hostname_cmd = {
|
const esp_console_cmd_t hostname_cmd = {
|
||||||
|
|
Loading…
Reference in a new issue