[Feature][ZXW-265]merge P56U03 version
Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No
Change-Id: I873f6df64e2605a77b8b8bfec35b21e7f33c5444
diff --git a/ap/app/zte_amt/amt.c b/ap/app/zte_amt/amt.c
index 57f39b1..8cd888c 100755
--- a/ap/app/zte_amt/amt.c
+++ b/ap/app/zte_amt/amt.c
@@ -57,6 +57,7 @@
#include "amtnv.h"
#include "libcpnv.h"
#include <sys/prctl.h>
+#include "sys/wait.h"
#include "ref_nv_def.h"
#include "nv_api.h"
@@ -1373,12 +1374,48 @@
}
}
+int wfsystem(const char * cmd)
+{
+ pid_t ret = 0 ;
+ ret = soft_system(cmd);
+ AmtPrintf (AMT_ERROR "[%s]ret = %d, WIFEXITED(ret)=%d, WEXITSTATUS(ret) =%d",cmd, ret , WIFEXITED (ret), WEXITSTATUS (ret));
+ if (! (-1 != ret && WIFEXITED (ret) && 0 == WEXITSTATUS (ret))) {
+ return -1;
+ }
+ return 0;
+}
+
+int check_wlan (void)
+{
+ int find_wlan = -1;
+ int i = 0, sum = 0;
+
+ while (-1 == find_wlan) {
+ AmtPrintf (AMT_ERROR "finding wlan i=%d, %d s...", i , sum);
+ find_wlan = wfsystem ("ifconfig wlan0");
+ if (-1==find_wlan) {
+ if (sum >= 60)
+ return -1;
+ sum += 2 * i;
+ sleep (2 * i++);
+ }
+ }
+ return 0;
+}
+
int Amt_ExecuteCmd(char *pcmd, char *pbuffer, int len)
{
FILE *pPipe;
-
+ static int wifi_init = 0;
AmtPrintf(AMT_INFO "%s: execute \"%s\"!\n", __FUNCTION__, pcmd);
-
+ if(0 == wifi_init)
+ {
+ if(0 == strcmp(pcmd, "ifconfig wlan0 up")){
+ check_wlan();
+ wifi_init = 1;
+ }
+ }
+
if ((pPipe = popen(pcmd, "r")) == NULL)
{
AmtPrintf(AMT_ERROR "popen \"%s\" failure.\n", pcmd);