mDNS of SDK API not working

hrsavla
Posts: 5
Joined: Sun May 24, 2015 11:50 am

mDNS of SDK API not working

Postby hrsavla » Sun May 24, 2015 12:12 pm

How is mDNS suppose to work? If we type "trial.local" in web browser then it mDNS will find its IP address like 192.168.1.6. Does this work in every OS (windows, android,etc) ??.
Do I have to install some sofware on Windows / Android to get it work ??
Bellow code is based on Esp8266 SDK API. In Android "Zeroconf Browser", ESP8266 shows up as trial.local. But in browser (chrome, ie) (trial.local) it does not translate ip address.

Code: Select all

void startmdns()
{
        struct mdns_info *info = (struct mdns_info *)os_zalloc(sizeof(struct
        mdns_info));
        info->host_name = (char *) "test";

        info->ipAddr = WifiStation.getIP(); //y; //0;//3232235782;// ESP8266 station IP
        info->server_name = (char *) "iot";
        info->server_port = 80;
        char *xyz = (char *) "version = now";
        info->txt_data = xyz;

        espconn_mdns_init(info);
        espconn_mdns_server_register();
        espconn_mdns_enable();
}

ESP8266 crashes with Fatal error every time Android "Zeroconf Browser" scans for new mDNS adverstisements.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: mDNS of SDK API not working

Postby ESP_Faye » Tue May 26, 2015 10:13 am

Hi,

Thanks for your interest in ESP8266 ,

Could you provide your Android "Zeroconf Browser" to us for debugging ?

And what's the SDK version you are using ?

hrsavla
Posts: 5
Joined: Sun May 24, 2015 11:50 am

Re: mDNS of SDK API not working

Postby hrsavla » Tue May 26, 2015 12:06 pm

You can get ZeroConf browser for Android here ( https://play.google.com/store/apps/deta ... conf&hl=en )

I am using SDK1.01 with Sming Framework by Anakod (https://github.com/anakod/Sming).

I am now able to connect to windows machine (I had not installed Bonjour Service previously).

But Android there is still a problem. Is there a service which can be installed in Android to make mDNS work in Browser ?

Also I want to know that Another ESP8266 module will be able to translate the DNS (test.local) to IP address with espconn_gethostbyname() function.

nver

Re: mDNS of SDK API not working

Postby nver » Wed May 27, 2015 2:42 pm

Ahh replied before reading your post. you already seem to have it working. In that case ignore me :)
--------------------------------------------------------------------------------------------------------------------------------
Hi hrsavla

Apple devices (iOS) have got built-in support for mDNS, after all it Apple's thing.

On Android you can't resolve host name in browser address bar, Android will try to google search your host name instead of try to resolve. The only way is via installing a ZeroConf browser app.

I haven't tried on Linux machines. Let me know if you have.

Windows does not have mDNS support built-in. However you can get it if you install Safari browser for Windows which also installs Bonjour services (you need to check a box at the time of Safari installation). Once this is done you should be able to resolve your .local host name provided that ESP mDNS is configured correctly.
Windows lookup for host names in below order;
- DNS server
- LLMNR (Similar to mDNS but its from Microsoft, uses multicast)
- NBNS (Netbios name resolution, again from Microsoft, uses broadcast )
- mDNS (only if Bonjour service is installed)

Below code from SDK document worked for me but I haven't done detailed testing with ESP mDNS yet.

Code: Select all

      struct ip_info sta_ip;
      wifi_get_ip_info(STATION_IF, &sta_ip);
      struct mdns_info *info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info));
      info->host_name = "myesp8266"; // your device will be accessed using myesp8266.local
      info->ipAddr = sta_ip.ip.addr; //ESP8266 station IP
      info->server_name = "mywebserver";
      info->server_port = 80;
      info->txt_data = "version = myesp8266_v1.0";
      espconn_mdns_init(info);


Hope this helps. Btw I am no mDNS/DNS expert and also I dont work for Espressif :)

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: mDNS of SDK API not working

Postby ESP_Faye » Fri Jun 05, 2015 10:39 am

Hi hrsavla,

Was your problem solved?

tprochazka
Posts: 3
Joined: Mon Jun 15, 2015 4:22 am

Re: mDNS of SDK API not working

Postby tprochazka » Mon Jun 15, 2015 4:34 am

I have the same problem.
I'm using the same code as hrsavla mentioned.
I tested it on SDK 1.0.1 and 1.1.0 and it always crash during scanning by any Android zero config app
I tested it by
https://play.google.com/store/apps/deta ... e.zeroconf
and
https://play.google.com/store/apps/deta ... id.bonjour

Code: Select all

Fatal exception (28):
epc1=0x40224f3c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000

 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x40100000, len 24048, room 16
tail 0
chksum 0x81
load 0x3ffe8000, len 1328, room 8
tail 8
chksum 0xcb
load 0x3ffe8530, len 7300, room 0
tail 4
chksum 0xc6
csum 0xc6


My test code

Code: Select all

void startmdns() {
   struct mdns_info *info = (struct mdns_info *)os_zalloc(sizeof(struct mdns_info));
   info->host_name = (char *) "test";
   info->ipAddr = WifiStation.getIP();
   info->server_name = (char *) "iot";
   info->server_port = 80;

    espconn_mdns_init(info);
    espconn_mdns_server_register();
    espconn_mdns_enable();
}

hrsavla
Posts: 5
Joined: Sun May 24, 2015 11:50 am

Re: mDNS of SDK API not working

Postby hrsavla » Mon Jun 15, 2015 10:34 am

I confirm that MDNS is now working for me. Functions provided in sdk only gives"Advertise " . A support for "listening " and decoding mdns to ip address. Would be great enhancement.

tprochazka
Posts: 3
Joined: Mon Jun 15, 2015 4:22 am

Re: mDNS of SDK API not working

Postby tprochazka » Mon Jun 15, 2015 3:24 pm

But I found if I remove lines with

espconn_mdns_server_register();
espconn_mdns_enable();

and keep only

espconn_mdns_init(info);

It stop crashing.
I don't understand why.
init function did also register and enable?
But for example Bonjour Browser on Android did not found any service, only device itself.
But this one https://play.google.com/store/apps/deta ... e.zeroconf found everything.

Also possibility to scan others services in the network will be great.

ESP_Faye
Posts: 1646
Joined: Mon Oct 27, 2014 11:08 am

Re: mDNS of SDK API not working

Postby ESP_Faye » Mon Jun 15, 2015 4:05 pm

Hi,

So sorry for the inconvenience,

Keep espconn_mdns_init(info); only would be OK,we offer a demo in “2C-ESP8266__SDK__Programming Guide”,mDNS API introduction.

espconn_mdns_server_register();
espconn_mdns_enable();

This two APIs is included in espconn_mdns_init, we offered them for some customer's requirement.
In general, they need not to be called.

Thanks for your reporting, we will optimize these APIs.

marhc_seven
Posts: 44
Joined: Sat Oct 17, 2015 4:49 pm

Re: mDNS of SDK API not working

Postby marhc_seven » Tue Nov 03, 2015 4:34 pm

Hi does RTOS SDK support mdns Function???

or does it should be done by userself!!!????

Who is online

Users browsing this forum: No registered users and 83 guests