Răsfoiți Sursa

2019-12-26 / Folus Wen

Actions:
1. EVSE/rootfs/root/ add dhcp_script folder to save each interface udhcpc script.
2. EVSE/Modularization/Module_Wifi.c udhcpc command modify for script location change.

Files:
1. As follow commit history.
FolusWen 5 ani în urmă
părinte
comite
e0d1282783

BIN
EVSE/Modularization/Module_Wifi


+ 4 - 2
EVSE/Modularization/Module_Wifi.c

@@ -595,7 +595,7 @@ int setWPAconf()
 			// Wifi IP set by DHCP client or static
 			if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient==0)
 			{
-				sprintf(cmdBuf, "/sbin/udhcpc -i %s -s /root/simple.script > /dev/null &", Wifi.currentInterface);
+				sprintf(cmdBuf, "/sbin/udhcpc -i %s -s /root/dhcp_script/wifi.script > /dev/null &", Wifi.currentInterface);
 				system(cmdBuf);
 			}
 			else
@@ -768,7 +768,7 @@ int checkIP(void)
 			system(cmd);
 			if(ShmSysConfigAndInfo->SysConfig.AthInterface.WifiDhcpClient==0)
 			{
-				sprintf(cmd, "/sbin/udhcpc -i %s -s /root/simple.script > /dev/null &", Wifi.currentInterface);
+				sprintf(cmd, "/sbin/udhcpc -i %s -s /root/dhcp_script/wifi.script > /dev/null &", Wifi.currentInterface);
 				system(cmd);
 			}
 			DEBUG_INFO("Sending DHCP request...\n");
@@ -923,6 +923,7 @@ void proc_sta()
 			{
 				DEBUG_INFO("Wifi internet valid result: Pass\n");
 				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi=0;
+				ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn=1;
 				cnt_pingDNS_Fail = 0;
 				sleep(30);
 			}
@@ -936,6 +937,7 @@ void proc_sta()
 			if(cnt_pingDNS_Fail >= 3)
 			{
 				ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectViaWiFi=1;
+				ShmSysConfigAndInfo->SysConfig.AthInterface.WifiNetworkConn=0;
 				cnt_pingDNS_Fail = 0;
 
 				DEBUG_INFO("Ping DNS failed...");

BIN
EVSE/Projects/AW-Regular/Images/ramdisk.gz


BIN
EVSE/rootfs/root/Module_Wifi


+ 0 - 0
EVSE/rootfs/root/simple.script → EVSE/rootfs/root/dhcp_script/eth0.script


+ 38 - 0
EVSE/rootfs/root/dhcp_script/eth1.script

@@ -0,0 +1,38 @@
+#!/bin/sh
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+RESOLV_CONF="/etc/resolv.conf"
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+case "$1" in
+	deconfig)
+		/sbin/ifconfig $interface 192.168.0.10
+		;;
+
+	renew|bound)
+		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+		if [ -n "$router" ] ; then
+			echo "deleting routers"
+			while route del default gw 0.0.0.0 dev $interface ; do
+				:
+			done
+
+			metric=0
+			for i in $router ; do
+				route add default gw $i dev $interface metric $((metric++))
+			done
+		fi
+
+		echo -n > $RESOLV_CONF
+		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
+		for i in $dns ; do
+			echo adding dns $i
+			echo nameserver $i >> $RESOLV_CONF
+		done
+		;;
+esac
+
+exit 0

+ 38 - 0
EVSE/rootfs/root/dhcp_script/simple.script

@@ -0,0 +1,38 @@
+#!/bin/sh
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+RESOLV_CONF="/etc/resolv.conf"
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+case "$1" in
+	deconfig)
+		/sbin/ifconfig $interface 192.168.1.10
+		;;
+
+	renew|bound)
+		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+		if [ -n "$router" ] ; then
+			echo "deleting routers"
+			while route del default gw 0.0.0.0 dev $interface ; do
+				:
+			done
+
+			metric=0
+			for i in $router ; do
+				route add default gw $i dev $interface metric $((metric++))
+			done
+		fi
+
+		echo -n > $RESOLV_CONF
+		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
+		for i in $dns ; do
+			echo adding dns $i
+			echo nameserver $i >> $RESOLV_CONF
+		done
+		;;
+esac
+
+exit 0

+ 38 - 0
EVSE/rootfs/root/dhcp_script/wifi.script

@@ -0,0 +1,38 @@
+#!/bin/sh
+
+[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
+
+RESOLV_CONF="/etc/resolv.conf"
+[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
+[ -n "$subnet" ] && NETMASK="netmask $subnet"
+
+case "$1" in
+	deconfig)
+		/sbin/ifconfig $interface 192.168.2.10
+		;;
+
+	renew|bound)
+		/sbin/ifconfig $interface $ip $BROADCAST $NETMASK
+
+		if [ -n "$router" ] ; then
+			echo "deleting routers"
+			while route del default gw 0.0.0.0 dev $interface ; do
+				:
+			done
+
+			metric=0
+			for i in $router ; do
+				route add default gw $i dev $interface metric $((metric++))
+			done
+		fi
+
+		echo -n > $RESOLV_CONF
+		[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
+		for i in $dns ; do
+			echo adding dns $i
+			echo nameserver $i >> $RESOLV_CONF
+		done
+		;;
+esac
+
+exit 0