mirror of
https://github.com/openshwprojects/OpenBK7231T_App.git
synced 2026-02-08 00:15:40 +00:00
LN882H - static ip (#1342)
* First changes for static IP on LN882H - WiP - need to set DNS server IP
Needs change in SDK in components/net/lwip-2.1.3/src/port/ln_osal/netif/ethernetif.c
to make sure, DHCP isn't called after we set the IP:
diff --git a/components/net/lwip-2.1.3/src/port/ln_osal/netif/ethernetif.c b/components/net/lwip-2.1.3/src/port/ln_osal/netif/ethernetif.c
index e2b485e..2884ef3 100644
--- a/components/net/lwip-2.1.3/src/port/ln_osal/netif/ethernetif.c
+++ b/components/net/lwip-2.1.3/src/port/ln_osal/netif/ethernetif.c
@@ -16,6 +16,7 @@
#define IF_NAME_STA "ST" // Only support two ascii characters
#define IF_NAME_AP "AP" // Only support two ascii characters
+static int STA_USE_DHCP = 1;
typedef struct {
struct netif nif;
@@ -267,9 +268,10 @@ int netdev_set_state(netif_idx_t nif_idx, netdev_state_t state)
netif_set_status_callback(nif, sta_netif_status_changed_cb);
netif_set_link_callback(nif, sta_netif_link_changed_cb);
-
netifapi_dhcp_stop(nif);
+ if (STA_USE_DHCP) {
netifapi_dhcp_start(nif);
+ }
}
else
{
@@ -362,6 +364,8 @@ int netdev_set_ip_info(netif_idx_t nif_idx, tcpip_ip_info_t *ip_info)
if (ndev && ip_info) {
netifapi_netif_set_addr(netdev2netif(ndev), &ip_info->ip, &ip_info->netmask, &ip_info->gw);
+ // we set an IP in STA mode? --> disable DHCP, or it will be overwritten
+ if (nif_idx == NETIF_IDX_STA) STA_USE_DHCP = 0;
return 0;
}
return -1;
* set DNS with dns_setserver()
* Changed code so during STA init a golbal variable is set, wheter static IP is used.
This will be respected in netif (see OpenLN882H PR#17)
This commit is contained in:
@ -987,18 +987,22 @@ int http_fn_cfg_ip(http_request_t* request) {
|
||||
|
||||
if (http_getArg(request->url, "IP", tmp, sizeof(tmp))) {
|
||||
str_to_ip(tmp, g_cfg.staticIP.localIPAddr);
|
||||
//hprintf255(request, "<br>IP=%s (%02x %02x %02x %02x)<br>",tmp,g_cfg.staticIP.localIPAddr[0],g_cfg.staticIP.localIPAddr[1],g_cfg.staticIP.localIPAddr[2],g_cfg.staticIP.localIPAddr[3]);
|
||||
g_changes++;
|
||||
}
|
||||
if (http_getArg(request->url, "mask", tmp, sizeof(tmp))) {
|
||||
str_to_ip(tmp, g_cfg.staticIP.netMask);
|
||||
//hprintf255(request, "<br>Mask=%s (%02x %02x %02x %02x)<br>",tmp, g_cfg.staticIP.netMask[0], g_cfg.staticIP.netMask[1], g_cfg.staticIP.netMask[2], g_cfg.staticIP.netMask[3]);
|
||||
g_changes++;
|
||||
}
|
||||
if (http_getArg(request->url, "dns", tmp, sizeof(tmp))) {
|
||||
str_to_ip(tmp, g_cfg.staticIP.dnsServerIpAddr);
|
||||
//hprintf255(request, "<br>DNS=%s (%02x %02x %02x %02x)<br>",tmp, g_cfg.staticIP.dnsServerIpAddr[0], g_cfg.staticIP.dnsServerIpAddr[1], g_cfg.staticIP.dnsServerIpAddr[2], g_cfg.staticIP.dnsServerIpAddr[3]);
|
||||
g_changes++;
|
||||
}
|
||||
if (http_getArg(request->url, "gate", tmp, sizeof(tmp))) {
|
||||
str_to_ip(tmp, g_cfg.staticIP.gatewayIPAddr);
|
||||
//hprintf255(request, "<br>GW=%s (%02x %02x %02x %02x)<br>",tmp, g_cfg.staticIP.gatewayIPAddr[0], g_cfg.staticIP.gatewayIPAddr[1], g_cfg.staticIP.gatewayIPAddr[2], g_cfg.staticIP.gatewayIPAddr[3]);
|
||||
g_changes++;
|
||||
}
|
||||
if (g_changes) {
|
||||
|
||||
Reference in New Issue
Block a user