From 70275ccacb0b5ccc78fbe2c19a3e4f7dfc1f5f0a Mon Sep 17 00:00:00 2001 From: zhaohe Date: Fri, 29 Mar 2024 11:46:34 +0800 Subject: [PATCH] V3.3 --- README.md | 4 ++++ usrc/project_configs.h | 2 +- usrc/service/network_service.c | 20 ++++++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8d160fe..e389b80 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ V3.1 1.电源部分的指示灯显示IP获取状态 2.调整广播时间,优化复位逻辑 +V3.3 + 1.修改dhcp启动的位置 + 2.修正网卡启动时,如果没有插网线,设备无法初始化的BUG + ``` ··· diff --git a/usrc/project_configs.h b/usrc/project_configs.h index 908a118..200c0a5 100644 --- a/usrc/project_configs.h +++ b/usrc/project_configs.h @@ -1,7 +1,7 @@ #pragma once #define VERSION(main, sub, fix) (main << 16 | sub << 8 | fix << 0) -#define PC_VERSION VERSION(3, 2, 0) +#define PC_VERSION VERSION(3, 3, 0) #define PC_MANUFACTURER0 ('i' | 'f' << 8 | 'l' << 16 | 'y' << 24) #define PC_MANUFACTURER1 ('t' | 'o' << 8 | 'p' << 16 | '\0' << 24) diff --git a/usrc/service/network_service.c b/usrc/service/network_service.c index edb702b..8cbbced 100644 --- a/usrc/service/network_service.c +++ b/usrc/service/network_service.c @@ -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); + // } } }