zhaohe 1 year ago
parent
commit
c1730253b4
  1. 2
      README.md
  2. 2
      usrc/project_configs.h
  3. 21
      usrc/service/network_service.c

2
README.md

@ -12,6 +12,8 @@ V3
3.修改xsynctimecode消息上报格式
4.添加dhcp支持
5.dhcp失败自动触发LLA,生成随机本地IP
V3.1
1.电源部分的指示灯显示IP获取状态
```

2
usrc/project_configs.h

@ -1,6 +1,6 @@
#pragma once
#define PC_VERSION (3 | 0 | 0 | 0) // main/sub/fix
#define PC_VERSION (3 | 1 | 0 | 0) // main/sub/fix
#define PC_MANUFACTURER0 ('i' | 'f' << 8 | 'l' << 16 | 'y' << 24)
#define PC_MANUFACTURER1 ('t' | 'o' << 8 | 'p' << 16 | '\0' << 24)
#define PC_PROJECT_NAME "xsync"

21
usrc/service/network_service.c

@ -94,12 +94,19 @@ void netif_ext_callback(struct netif *netif, netif_nsc_reason_t reason, const ne
if (reason & LWIP_NSC_LINK_CHANGED) {
ZLOGI(TAG, "DHCP_MODE: LWIP_NSC_LINK_CHANGED %d", args->link_changed.state);
if (!args->link_changed.state) {
IP4_ADDR(&ipaddr, 0, 0, 0, 0);
IP4_ADDR(&netmask, 0, 0, 0, 0);
IP4_ADDR(&gw, 0, 0, 0, 0);
netif_set_addr(netif, &ipaddr, &netmask, &gw);
m_networkisready = false;
// if (!args->link_changed.state) {
// IP4_ADDR(&ipaddr, 0, 0, 0, 0);
// IP4_ADDR(&netmask, 0, 0, 0, 0);
// IP4_ADDR(&gw, 0, 0, 0, 0);
// netif_set_addr(netif, &ipaddr, &netmask, &gw);
// m_networkisready = false;
// }
if (args->link_changed.state) {
if (netif->ip_addr.addr != 0) {
m_networkisready = true;
}
}else{
m_networkisready = false;
}
}
@ -164,7 +171,7 @@ void network_service_init() {
netif_set_link_callback(&gnetif, ethernet_link_status_updated);
netif_set_status_callback(&gnetif, ethernet_status_updated);
netif_add_ext_callback(&extcb, netif_ext_callback);
osThreadDef(EthLink, ethernet_link_thread, NETWORK_REPORT_TASK_LEVEL, 0, 512);
osThreadDef(EthLink, ethernet_link_thread, NETWORK_REPORT_TASK_LEVEL, 0, 1024);
osThreadCreate(osThread(EthLink), &gnetif);
while (!netif_is_up(&gnetif)) {

Loading…
Cancel
Save