|
|
@ -42,6 +42,7 @@ static uint8_t GATEWAY_ADDRESS[4]; |
|
|
|
static bool m_networkisready; |
|
|
|
|
|
|
|
static config_t config_cache; |
|
|
|
static bool dhcp_is_start; |
|
|
|
|
|
|
|
uint8_t g_mac[6]; |
|
|
|
|
|
|
@ -101,12 +102,17 @@ void netif_ext_callback(struct netif *netif, netif_nsc_reason_t reason, const ne |
|
|
|
// netif_set_addr(netif, &ipaddr, &netmask, &gw); |
|
|
|
// m_networkisready = false; |
|
|
|
// } |
|
|
|
if (!dhcp_is_start) { |
|
|
|
dhcp_start(&gnetif); |
|
|
|
dhcp_is_start = true; |
|
|
|
} |
|
|
|
|
|
|
|
if (args->link_changed.state) { |
|
|
|
if (netif->ip_addr.addr != 0) { |
|
|
|
m_networkisready = true; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
m_networkisready = false; |
|
|
|
} else { |
|
|
|
m_networkisready = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@ -174,12 +180,10 @@ void network_service_init() { |
|
|
|
osThreadDef(EthLink, ethernet_link_thread, NETWORK_REPORT_TASK_LEVEL, 0, 1024); |
|
|
|
osThreadCreate(osThread(EthLink), &gnetif); |
|
|
|
|
|
|
|
while (!netif_is_up(&gnetif)) { |
|
|
|
ZLOGI(TAG, "waiting for dhcp"); |
|
|
|
osDelay(100); |
|
|
|
} |
|
|
|
|
|
|
|
dhcp_start(&gnetif); |
|
|
|
// while (!netif_is_up(&gnetif)) { |
|
|
|
// ZLOGI(TAG, "waiting for dhcp"); |
|
|
|
// osDelay(100); |
|
|
|
// } |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|