Hostname (standard PC-192-168-xxx-xxx)

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

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby ESP_Faye » Tue Aug 18, 2015 9:58 am

Hi,

Sorry that we can not duplicate your problem.

Here is our test code:

Code: Select all

void ICACHE_FLASH_ATTR
user_esp_platform_check_ip(void)
{
    struct ip_info ipconfig;

   //disarm timer first
    os_timer_disarm(&test_timer);

   //get ip info of ESP8266 station
    wifi_get_ip_info(STATION_IF, &ipconfig);

    if (wifi_station_get_connect_status() == STATION_GOT_IP && ipconfig.ip.addr != 0) {

      os_printf("got ip !!! \r\n");

     wifi_station_set_hostname("esp8266");
     espconn_nbns_init();

    } else {
       
        if ((wifi_station_get_connect_status() == STATION_WRONG_PASSWORD ||
                wifi_station_get_connect_status() == STATION_NO_AP_FOUND ||
                wifi_station_get_connect_status() == STATION_CONNECT_FAIL)) {
               
         os_printf("connect fail !!! \r\n");
         
        } else {
       
           //re-arm timer to check ip
            os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
            os_timer_arm(&test_timer, 100, 0);
        }
    }
}

void ICACHE_FLASH_ATTR
user_set_station_config(void)
{
   // Wifi configuration
   char ssid[32] = SSID;
   char password[64] = PASSWORD;
   struct station_config stationConf;

   //need not mac address
   stationConf.bssid_set = 0;
   
   //Set ap settings
   os_memcpy(&stationConf.ssid, ssid, 32);
   os_memcpy(&stationConf.password, password, 64);
   wifi_station_set_config(&stationConf);

   //set a timer to check whether got ip from router succeed or not.
   os_timer_disarm(&test_timer);
   os_timer_setfn(&test_timer, (os_timer_func_t *)user_esp_platform_check_ip, NULL);
   os_timer_arm(&test_timer, 100, 0);

}

void user_init(void)
{
    os_printf("SDK version:%s\n", system_get_sdk_version());
   
   //Set  station mode
   wifi_set_opmode(STATION_MODE);

   // ESP8266 connect to router.
   user_set_station_config();

}


- Do I need to call espconn_nbns_init every time ESP8266 got an IP?
-> Yes.
- Do I need to call espconn_nbns_init every time I change the host name with wifi_station_set_hostname?
-> No. It is enough calling it only once after got an IP.

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby blubb » Tue Aug 18, 2015 7:19 pm

No, does not work.

In the mean time I found a tool that can list NETBIOS nameservers on the local network:
http://www.unixwiz.net/tools/nbtscan.html

All my Windows machines and the Linux machines running Samba show up on the list. ESP8266 does not.

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

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby ESP_Faye » Mon Aug 24, 2015 5:29 pm

Hi,

With the code I provided above, it can ping "esp8266" successfully.

ping hostname.jpg


If your problem is still unsolved, please provide your test code and test steps, we will have a try.

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby blubb » Mon Aug 24, 2015 5:51 pm

"esp8266" might be resolved by DNS, not NBNS on your system. Remove espconn_nbns_init() then try again. If pinging still works, your system uses DNS.
I found out that my Windows 7 machine does this, too. My Windows 10 machine tries NBNS only and cannot ping the module by host name (I have no idea why).

Try

nbtstat -a esp8266

It's a tool that comes with Windows: https://technet.microsoft.com/en-us/library/cc755486(v=ws.10).aspx

If NBNS works, there should be some output (compare it with, for example, a Linux system running Samba).

webself
Posts: 5
Joined: Fri Oct 24, 2014 8:24 pm

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby webself » Fri Sep 25, 2015 2:50 pm

Why SDK 1.4 still does not include this feature?
I check espconn.h for "espconn_nbns_init" and nothing was found...

blubb
Posts: 116
Joined: Mon Jun 22, 2015 5:35 am

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby blubb » Fri Sep 25, 2015 7:09 pm

Did the feature work for you (in SDK 1.3.0)? Were your Windows machines able to resolve the host names?

webself
Posts: 5
Joined: Fri Oct 24, 2014 8:24 pm

Re: Hostname (standard PC-192-168-xxx-xxx)

Postby webself » Fri Sep 25, 2015 7:13 pm

I have not tried.

Who is online

Users browsing this forum: No registered users and 27 guests