fix NVS for dst ip
This commit is contained in:
parent
7cc08c3b3a
commit
ea876c5f34
|
|
@ -93,7 +93,7 @@ static void iperf_read_nvs_config(iperf_cfg_t *cfg) {
|
||||||
cfg->burst_count = 1;
|
cfg->burst_count = 1;
|
||||||
cfg->send_len = IPERF_UDP_TX_LEN;
|
cfg->send_len = IPERF_UDP_TX_LEN;
|
||||||
cfg->dport = 5001;
|
cfg->dport = 5001;
|
||||||
cfg->dip = inet_addr("192.168.1.50"); // Default Target
|
cfg->dip = inet_addr("192.168.1.50"); // Default Target if NVS missing
|
||||||
if (cfg->time == 0) cfg->time = UINT32_MAX;
|
if (cfg->time == 0) cfg->time = UINT32_MAX;
|
||||||
|
|
||||||
if (err != ESP_OK) return;
|
if (err != ESP_OK) return;
|
||||||
|
|
@ -106,21 +106,17 @@ static void iperf_read_nvs_config(iperf_cfg_t *cfg) {
|
||||||
cfg->dport = (uint16_t)val;
|
cfg->dport = (uint16_t)val;
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- RESTORED NVS IP LOGIC ---
|
// --- RESTORED NVS IP LOGIC (NO OVERRIDE) ---
|
||||||
if (nvs_get_str(my_handle, NVS_KEY_IPERF_DST_IP, NULL, &required_size) == ESP_OK) {
|
if (nvs_get_str(my_handle, NVS_KEY_IPERF_DST_IP, NULL, &required_size) == ESP_OK) {
|
||||||
char *ip_str = malloc(required_size);
|
char *ip_str = malloc(required_size);
|
||||||
if (ip_str) {
|
if (ip_str) {
|
||||||
nvs_get_str(my_handle, NVS_KEY_IPERF_DST_IP, ip_str, &required_size);
|
nvs_get_str(my_handle, NVS_KEY_IPERF_DST_IP, ip_str, &required_size);
|
||||||
trim_whitespace(ip_str);
|
trim_whitespace(ip_str);
|
||||||
|
|
||||||
// SMART CHECK: Only override if it matches the known bad "Ghost IP"
|
// FIX: Use whatever is in NVS, do not auto-correct
|
||||||
if (strcmp(ip_str, "192.168.1.101") == 0) {
|
cfg->dip = inet_addr(ip_str);
|
||||||
ESP_LOGW(TAG, "Detected legacy/incorrect target %s in NVS. Auto-correcting to 192.168.1.50", ip_str);
|
ESP_LOGI(TAG, "NVS Target IP: %s", ip_str);
|
||||||
cfg->dip = inet_addr("192.168.1.50");
|
|
||||||
} else {
|
|
||||||
cfg->dip = inet_addr(ip_str);
|
|
||||||
ESP_LOGI(TAG, "NVS Target IP: %s", ip_str);
|
|
||||||
}
|
|
||||||
free(ip_str);
|
free(ip_str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue