Hi
Could anybody tell me how to free DNS result. I'm using following code and I only get the result for the first time. Subsequent call returns from local host list and doesn't query DNS server to check internet connection and when I turn off my router's WiFi it tells me there is an internet connection wrongly. I also tried to use malloc() to assign memory to ip_address and then free it using free(), it doesn't work, too. I also plan to query DNS server every 20 seconds(because I need fast recovery after connection problem is solved). Is it advisable or DNS server protection system prevents me from doing so. I'm going to use 8.8.8.8 google's DNS server.
Code: Select all
void dns_found_cb(const char *name, const ip_addr_t *ipaddr, void *callback_arg)
{
ip_address = *ipaddr;
ESP_LOGE(TAG , "google.com ip is = %d" , ip_address.u_addr.ip4.addr);
ESP_LOGI(TAG , "internet connection : %s and ip : %d" , error ? "false" : "true" , ip_address.u_addr.ip4.addr);
}
void connection_status_task(void * parm){
while(1){
xEventGroupWaitBits(event_group, CONNECTED_BIT, pdFALSE, pdFALSE, portMAX_DELAY);
error = dns_gethostbyname(url , &ip_address , dns_found_cb , NULL);
ESP_LOGE(TAG , "dns_gethostbyname return value = %d" , error);
while( !DNSFound ) ;
vTaskDelay(30000/portTICK_PERIOD_MS);
}
}