-->
Page 1 of 1

mdns causes restarting on esp8266

PostPosted: Tue Jan 08, 2019 9:14 am
by adamhala007
Hi!

I am working on esp8266. I have builded and flashed the esphttpd webserver.
Then I have added a piece of code to start mdns on esp8266:

Code: Select allstatic void ICACHE_FLASH_ATTR mdns()
{
    struct ip_info ipConfig;
     struct mdns_info *info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info));
     
     wifi_get_ip_info(STATION_IF, &ipConfig);
     if (!(wifi_station_get_connect_status() == STATION_GOT_IP && ipConfig.ip.addr != 0)) {
     os_printf("Cannot read station configuration\n");
     return;
     }
     
     info->host_name = (char *) "lienka";
     info->ipAddr = ipConfig.ip.addr; //ESP8266 station IP
     info->server_name = "module01";
     info->server_port = 80;
     info->txt_data[0] = "version = now";
     info->txt_data[1] = "user1 = data1";
     info->txt_data[2] = "user2 = data2";
     
     info->txt_data[3] = "vendor = me";
    espconn_mdns_init(info);
     //espconn_mdns_server_register();
    espconn_mdns_enable();
}

static void ICACHE_FLASH_ATTR testTimerCb(void *arg) {
    mdns();
}


In the user_init function the following code was added:

Code: Select all
os_timer_disarm(&testTimer);
os_timer_setfn(&testTimer, testTimerCb, NULL);
os_timer_arm(&testTimer, 10000, 0);



The problem that since I have added the mdns functionality, the esp8266 is restarting every minute. When these 3 lines of code in user_init function is commented out, esp8266 stops restarting itself. Could anybody help me, what should I do? Thanks