fix error DHCP mode

This commit is contained in:
pvvx 2017-06-04 05:54:39 +03:00
parent 36ee138705
commit 0cd01e4dc1

View file

@ -406,15 +406,10 @@ LOCAL rtw_result_t StartStDHCPClient(void)
struct netif * pnetif = &xnetif[WLAN_ST_NETIF_NUM]; struct netif * pnetif = &xnetif[WLAN_ST_NETIF_NUM];
DHCP_CONFIG *p = (dhcp_cfg *)&wifi_st_dhcp; DHCP_CONFIG *p = (dhcp_cfg *)&wifi_st_dhcp;
unsigned char mode = p->mode; unsigned char mode = p->mode;
if((mode == 3) // Auto fix if(mode == 2 && p->ip != IP4ADDR(255,255,255,255) && p->ip != IP4ADDR(0,0,0,0)) { // fixed ip
&& p->ip != IP4ADDR(255,255,255,255) netif_set_addr(pnetif, (ip_addr_t *)&p->ip, (ip_addr_t *)&p->mask, (ip_addr_t *)&p->gw);
&& p->ip != IP4ADDR(0,0,0,0)) {
} }
else mode = 1; // DHCP On else if(mode) { // DHCP On
if(mode == 2) { // fixed ip
netif_set_addr(pnetif, (ip_addr_t *)&p->ip, (ip_addr_t *)&p->mask, (ip_addr_t *)&p->gw);
}
else if(mode) {
UBaseType_t savePriority = uxTaskPriorityGet(NULL); UBaseType_t savePriority = uxTaskPriorityGet(NULL);
/* If not rise priority, LwIP DHCP may timeout */ /* If not rise priority, LwIP DHCP may timeout */
vTaskPrioritySet(NULL, tskIDLE_PRIORITY + 3); vTaskPrioritySet(NULL, tskIDLE_PRIORITY + 3);
@ -425,7 +420,7 @@ LOCAL rtw_result_t StartStDHCPClient(void)
p->ip = pnetif->ip_addr.addr; p->ip = pnetif->ip_addr.addr;
p->gw = pnetif->gw.addr; p->gw = pnetif->gw.addr;
p->mask = pnetif->netmask.addr; p->mask = pnetif->netmask.addr;
if(p->mode == 3) { // Auto fix if(p->mode > 2) { // 3+ Auto fix
p->mode = 2; // fixed ip p->mode = 2; // fixed ip
write_wifi_cfg(BID_ST_DHCP_CFG); write_wifi_cfg(BID_ST_DHCP_CFG);
} }