But, can you please tell me, do I actually need to manually change PHY mode? In my case I need STA mode in "N" and AP mode in "G" (because AP does not work in "N" per specification). Or it will be enough to call wifi_set_phy_mode(PHY_MODE_11N) after platform start and it will automatically fallback to "G" mode when switched to AP and back to "N" when switched to STA?
Statistics: Posted by DarkSide — Thu Jul 07, 2016 5:22 pm
In particular I want to configure the host's DNS server via the offer option number 6 of the dhcp server.
Code:
wifi_set_opmode(STATIONAP_MODE);
wifi_softap_set_dhcps_offer_option
espconn_dns_setserver
Statistics: Posted by ESP_Faye — Wed Jun 22, 2016 11:54 am
Statistics: Posted by DG2016 — Mon Jun 20, 2016 10:42 pm
Statistics: Posted by DarkSide — Sat Jun 18, 2016 12:53 am
Statistics: Posted by ESP_Faye — Fri Jun 17, 2016 2:55 pm
Code:
4022a9f8 <netif_set_up>:
4022a9f8: f0c112 addi a1, a1, -16
4022a9fb: 0161c2 s32i a12, a1, 4
4022a9fe: 006102 s32i a0, a1, 0
4022aa01: 02cd mov.n a12, a2
4022aa03: 390202 l8ui a0, a2, 57
4022aa06: 120c movi.n a2, 1
4022aa08: 1de007 bbsi a0, 0, 4022aa29 <netif_set_up+0x31>
4022aa0b: 200020 or a0, a0, a2
4022aa0e: 394c02 s8i a0, a12, 57
4022aa11: 146047 bbci a0, 4, 4022aa29 <netif_set_up+0x31>
4022aa14: 096057 bbci a0, 5, 4022aa21 <netif_set_up+0x29>
4022aa17: 0c2d mov.n a2, a12
4022aa19: 3c4b addi.n a3, a12, 4
4022aa1b: fee485 call0 40229864 <etharp_request>
4022aa1e: 390c02 l8ui a0, a12, 57
4022aa21: 046077 bbci a0, 7, 4022aa29 <netif_set_up+0x31>
4022aa24: 0c2d mov.n a2, a12
4022aa26: fef9c5 call0 402299c4 <igmp_report_groups>
4022aa29: 11c8 l32i.n a12, a1, 4
4022aa2b: 0108 l32i.n a0, a1, 0
4022aa2d: 10c112 addi a1, a1, 16
4022aa30: f00d ret.n
Code:
LOCAL bool ICACHE_FLASH_ATTR setup_wifi_ap_mode()
{
struct softap_config apconfig;
if(wifi_softap_get_config(&apconfig))
{
if (wifi_get_opmode() == STATION_MODE)
{
wifi_station_disconnect();
wifi_station_dhcpc_stop();
}
wifi_set_opmode(SOFTAP_MODE);
wifi_set_phy_mode(PHY_MODE_11G); // N only supported in STA
wifi_set_sleep_type(NONE_SLEEP_T);
os_memset(apconfig.ssid, 0, sizeof(apconfig.ssid));
os_memset(apconfig.password, 0, sizeof(apconfig.password));
apconfig.ssid_len = os_sprintf(apconfig.ssid, _sys_cfg.ap_ssid);
os_sprintf(apconfig.password, "%s", _sys_cfg.ap_pass);
apconfig.authmode = _sys_cfg.ap_authmode;
apconfig.ssid_hidden = _sys_cfg.ap_hidden;
apconfig.channel = _sys_cfg.ap_channel;
apconfig.max_connection = 4;
apconfig.beacon_interval = 100;
if(wifi_softap_set_config(&apconfig))
{
wifi_softap_dhcps_stop();
struct ip_info ipinfo;
wifi_get_ip_info(SOFTAP_IF, &ipinfo);
char *ip = (char *)_sys_cfg.ap_ip;
char *mask = (char *)_sys_cfg.ap_mask;
char *gw = (char *)_sys_cfg.ap_gw;
if (ip) ipinfo.ip.addr = ipaddr_addr(ip);
if (mask) ipinfo.netmask.addr = ipaddr_addr(mask);
if (gw) ipinfo.gw.addr = ipaddr_addr(gw);
wifi_set_ip_info(SOFTAP_IF, &ipinfo);
wifi_softap_dhcps_start();
return true;
}
}
return false;
}
LOCAL bool ICACHE_FLASH_ATTR setup_wifi_station_mode()
{
struct station_config stconfig;
if(wifi_station_get_config(&stconfig))
{
if (wifi_get_opmode() == SOFTAP_MODE)
{
wifi_softap_dhcps_stop();
}
wifi_set_opmode(STATION_MODE);
wifi_set_phy_mode(PHY_MODE_11N); // N only supported in STA
wifi_set_sleep_type(NONE_SLEEP_T);
os_memset(stconfig.ssid, 0, sizeof(stconfig.ssid));
os_memset(stconfig.password, 0, sizeof(stconfig.password));
os_sprintf(stconfig.ssid, "%s", _sys_cfg.sta_ssid);
os_sprintf(stconfig.password, "%s", _sys_cfg.sta_pass);
stconfig.bssid_set = 0;
if(wifi_station_set_config(&stconfig))
{
wifi_station_disconnect();
wifi_station_dhcpc_stop();
wifi_station_set_hostname((char *)_sys_cfg.hostname);
wifi_station_connect();
wifi_station_dhcpc_start();
wifi_station_set_auto_connect(1);
return true;
}
}
return false;
}
Statistics: Posted by DarkSide — Wed Jun 08, 2016 7:03 am