Browse Source

[Add][AX80][main]

2022.03.18 / Folus Wen

Actions:
1. Bridge eth0 and uap0 if local power sharing enable and wifi is AP mode for local power sharing running on ethernet.

Files:
1. As follow commit history

Image version: D0.01.XX.XXXX.XX
Image checksum: XXXXXXXX

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 3 năm trước cách đây
mục cha
commit
7cc77df250
1 tập tin đã thay đổi với 45 bổ sung0 xóa
  1. 45 0
      EVSE/Projects/AX80/Apps/main.c

+ 45 - 0
EVSE/Projects/AX80/Apps/main.c

@@ -454,6 +454,31 @@ int getEth0MacAddress()
 	return result;
 }
 
+int isUap0up(void)
+{
+	int result = FAIL;
+
+	FILE *fp;
+	char cmd[256];
+	char buf[512];
+
+	strcpy(cmd, "ifconfig uap0");;
+	fp = popen(cmd, "r");
+	if(fp != NULL)
+	{
+		while(fgets(buf, sizeof(buf), fp) != NULL)
+		{
+			if(strstr(buf, "uap0") > 0)
+			{
+				result = PASS;
+			}
+		}
+	}
+	pclose(fp);
+
+	return result;
+}
+
 char* getSystemModeName(unsigned char mode)
 {
 	char* result;
@@ -2842,6 +2867,26 @@ void InitEthernet()
 				}
 			}
 
+			// Bridge ethernet to uap0 to get dynamic ip address
+			if(ShmSysConfigAndInfo->SysConfig.isEnableLocalPowerSharging &&
+			  (ShmSysConfigAndInfo->SysConfig.AthInterface.WifiMode == 2) &&
+			  (isUap0up() == PASS) &&
+			  (access("/sys/class/net/br0/address", F_OK) == -1))
+			{
+				sleep(10);
+				system("/sbin/ifconfig br0 down");
+				system("/usr/sbin/brctl delbr br0");
+				system("/usr/sbin/brctl addbr br0");
+				system("/sbin/ifconfig br0 192.168.10.200 up");
+				system("/usr/sbin/brctl addif br0 uap0");
+				system("/usr/sbin/brctl addif br0 eth0");
+				system("/bin/sed -i '/interface/d' /etc/udhcpd.conf");
+				system("/bin/echo 'interface	br0' >> /etc/udhcpd.conf");
+				system("pkill Module_Wifi");
+
+				DEBUG_INFO("Bridge uap0 & eth0 for local power sharing by ethernet.\n");
+			}
+
 			sleep(5);
 		}
 	}