ESP8266 Developer Zone The Official ESP8266 Forum 2017-05-28T23:07:42+08:00 https://bbs.espressif.com:443/feed.php?f=7&t=4551 2017-05-28T23:07:42+08:00 2017-05-28T23:07:42+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13489#p13489 <![CDATA[Re: Need help for fast connection in station mode]]> Statistics: Posted by Guest — Sun May 28, 2017 11:07 pm


]]>
2017-05-25T19:14:09+08:00 2017-05-25T19:14:09+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13390#p13390 <![CDATA[Re: Need help for fast connection in station mode]]> :cry:

Statistics: Posted by electr0dave — Thu May 25, 2017 7:14 pm


]]>
2017-05-22T16:52:23+08:00 2017-05-22T16:52:23+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13329#p13329 <![CDATA[Re: Need help for fast connection in station mode]]>
pratik wrote:
You may use the API wifi_softap_set_dhcps_lease_time() and wifi_softap_gset_dhcps_lease_time() to set and get the DHCP server lease time respectively. The default time is 120 min.


But these APIs isn't just for softAP?
If I use wifi_softap_get_dhcps_lease_time(), in station mode, will I get the lease time of my IP?

What I'm looking for is something that should be called "wifi_station_get_dhcps_lease_time()" ...

Statistics: Posted by electr0dave — Mon May 22, 2017 4:52 pm


]]>
2017-05-19T17:33:31+08:00 2017-05-19T17:33:31+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13252#p13252 <![CDATA[Re: Need help for fast connection in station mode]]> Statistics: Posted by Guest — Fri May 19, 2017 5:33 pm


]]>
2017-05-18T22:12:37+08:00 2017-05-18T22:12:37+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13240#p13240 <![CDATA[Re: Need help for fast connection in station mode]]>
Do you know any way to know the lease time using the ESP8266?
When DHCP does offer, the message brings a lease time, but I can not access that value ...

Statistics: Posted by electr0dave — Thu May 18, 2017 10:12 pm


]]>
2017-05-18T12:45:06+08:00 2017-05-18T12:45:06+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13225#p13225 <![CDATA[Re: Need help for fast connection in station mode]]> You can connect faster to saved APs I think, if their channel has not changed. That's why you get lucky sometimes I guess, with short connection time.
Try not to save AP settings to flash and see if that helps (use current_config APIs, not default_config).

Statistics: Posted by Guest — Thu May 18, 2017 12:45 pm


]]>
2017-05-15T21:44:01+08:00 2017-05-15T21:44:01+08:00 https://bbs.espressif.com:443/viewtopic.php?t=4551&p=13135#p13135 <![CDATA[Need help for fast connection in station mode]]>
I need to make a very low power application. I need to connect maybe, every 30min, to an AP and do the data uploads. The ESP8266 will be controlled by another MCU and so only when the other MCU gives power to ESP it starts up.

But I'm taking about 2.5s (or more) until I get IP.

Can you guys help me get in the way of connecting faster?

I can not have static IP because the final equipment will be mobile and may have to "jump" between AP's.


PS: I noticed that if I connect to the AP once and then reprogram the ESP with the init_user empty, in the terminal the information appears, after 0.8s, that I have IP (in the best cases) ... but it is not constant.


Thank you.


Code:

static void ICACHE_FLASH_ATTR wifi_check_ip(void *arg)
{
   struct ip_info ipConfig;

   os_printf("TIMER callback\r\n");

   //verifica o estado da ligação
   switch(wifi_station_get_connect_status())
   {
      case STATION_GOT_IP:

         os_timer_disarm(&tim0);

         wifi_get_ip_info(STATION_IF, &ipConfig);

         os_printf("IP:" IPSTR ", MASK:" IPSTR ", GATEWAY:" IPSTR,
                  IP2STR(&ipConfig.ip),
                  IP2STR(&ipConfig.netmask),
                  IP2STR(&ipConfig.gw));
                  os_printf("\n");

         wifi_set_sleep_type(LIGHT_SLEEP_T);

         os_timer_setfn(&tim0, (os_timer_func_t *)setup_wifi_st_mode, NULL);
         os_timer_arm(&tim0, 10000, 0);

         break;
   }
}

//setup do wifi em station mode
void setup_wifi_st_mode(void)
{
        os_timer_disarm(&tim0);

   if(wifi_get_opmode() != STATION_MODE)
   {
      os_printf("-> OpMode != STATION MODE\r\n");
      wifi_set_opmode(STATION_MODE);
   }
   else
      os_printf("-> OpMode == STATION MODE\r\n");

   struct station_config stconfig;
   os_printf("-> Read stored config\r\n");
   wifi_station_get_config(&stconfig);
   os_printf("SSID (flash): %s\r\n", stconfig.ssid);
   os_printf("PASSWORD (flash): %s\r\n", stconfig.password);

   //bad configuration in memory?
   if(os_strcmp(stconfig.ssid, WIFI_CLIENTSSID) != 0)
   {
      os_printf("-> Stored config is wrong!\r\n");
      //stop all
      wifi_station_disconnect();
      wifi_station_dhcpc_stop();

      //conigure connection
      os_memset(stconfig.ssid, 0, sizeof(stconfig.ssid));
      os_memset(stconfig.password, 0, sizeof(stconfig.password));
      os_sprintf(stconfig.ssid, "%s", WIFI_CLIENTSSID);
      os_sprintf(stconfig.password, "%s", WIFI_CLIENTPASSWORD);
      wifi_station_set_config(&stconfig);

      //init station
      wifi_station_connect();
      wifi_station_dhcpc_start();
      wifi_station_set_auto_connect(1);
   }
   else
      os_printf("-> Stored config is right!\r\n");

   //init timer to verify the connection
   //os_timer_disarm(&tim0);
   os_timer_setfn(&tim0, (os_timer_func_t *)wifi_check_ip, NULL);
   os_timer_arm(&tim0, IP_SCAN_MS, 1);   //repetição a 500mS

}


uint32 ICACHE_FLASH_ATTR user_rf_cal_sector_set(void)
{
    enum flash_size_map size_map = system_get_flash_size_map();
    uint32 rf_cal_sec = 0;

    switch (size_map) {
        case FLASH_SIZE_4M_MAP_256_256:
            rf_cal_sec = 128 - 8;
            break;

        case FLASH_SIZE_8M_MAP_512_512:
            rf_cal_sec = 256 - 5;
            break;

        case FLASH_SIZE_16M_MAP_512_512:
        case FLASH_SIZE_16M_MAP_1024_1024:
            rf_cal_sec = 512 - 5;
            break;

        case FLASH_SIZE_32M_MAP_512_512:
        case FLASH_SIZE_32M_MAP_1024_1024:
            rf_cal_sec = 1024 - 5;
            break;

        default:
            rf_cal_sec = 0;
            break;
    }

    return rf_cal_sec;
}

void ICACHE_FLASH_ATTR user_rf_pre_init(void)
{
   //No RF calibration after deep-sleep wake up; this reduces the current consumption
   system_phy_set_rfoption(2);
}

void ICACHE_FLASH_ATTR user_init(void)
{
    uart_init(115200, 115200);
    os_delay_us(100);

    os_printf("\r\nSDK version: %s \r\n", system_get_sdk_version());

    os_printf("GET auto connect: %d\r\n",wifi_station_get_auto_connect());

    wifi_set_sleep_type(LIGHT_SLEEP_T);

    os_printf("-> Setup WIFI in STATION mode\n");
    setup_wifi_st_mode();
}

Statistics: Posted by electr0dave — Mon May 15, 2017 9:44 pm


]]>