|
|
@ -102,16 +102,22 @@ 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 (!dhcp_is_start) { |
|
|
|
// dhcp_start(&gnetif); |
|
|
|
// dhcp_is_start = true; |
|
|
|
// ZLOGI(TAG, "start dhcp"); |
|
|
|
// } |
|
|
|
if (netif->ip_addr.addr != 0) { |
|
|
|
m_networkisready = true; |
|
|
|
} |
|
|
|
} else { |
|
|
|
ZLOGI(TAG, "stop dhcp"); |
|
|
|
if (dhcp_is_start) { |
|
|
|
dhcp_stop(&gnetif); |
|
|
|
dhcp_is_start = false; |
|
|
|
} |
|
|
|
m_networkisready = false; |
|
|
|
} |
|
|
|
} |
|
|
@ -179,9 +185,16 @@ void network_service_init() { |
|
|
|
} |
|
|
|
osThreadDef(EthLink, ethernet_link_thread, NETWORK_REPORT_TASK_LEVEL, 0, 1024); |
|
|
|
osThreadCreate(osThread(EthLink), &gnetif); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void network_service_schedule() { |
|
|
|
if (!dhcp_is_start && netif_is_up(&gnetif)) { |
|
|
|
err_t err = dhcp_start(&gnetif); |
|
|
|
if (err != 0) { |
|
|
|
return; |
|
|
|
} |
|
|
|
dhcp_is_start = true; |
|
|
|
ZLOGI(TAG, "start dhcp"); |
|
|
|
} |
|
|
|
} |
|
|
|
bool network_service_network_is_ready() { return m_networkisready; } |