|
@@ -2,9 +2,9 @@
|
|
|
* Module_Wifi.c
|
|
|
*
|
|
|
* Created on: 2020-01-14
|
|
|
- * Update on: 2020-07-23
|
|
|
+ * Update on: 2020-08-18
|
|
|
* Author: Jerry Wang, Eason Yang, Folus Wen
|
|
|
- * Version: D0.07
|
|
|
+ * Version: V0.08
|
|
|
*/
|
|
|
|
|
|
#include <sys/time.h>
|
|
@@ -590,41 +590,35 @@ int isReachableInternet()
|
|
|
char buf[512];
|
|
|
//char tmp[512];
|
|
|
|
|
|
- if(ShmOCPP16Data->OcppConnStatus == PASS)
|
|
|
+ for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
|
|
|
{
|
|
|
- result = PASS;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- for(int idx=0;idx<ARRAY_SIZE(valid_Internet);idx++)
|
|
|
+ sprintf(cmd, "ping -c 1 -w 3 -I %s %s", Wifi.currentInterface, valid_Internet[idx]);
|
|
|
+ fp = popen(cmd, "r");
|
|
|
+ if(fp != NULL)
|
|
|
{
|
|
|
- sprintf(cmd, "ping -c 1 -w 3 -I %s %s", Wifi.currentInterface, valid_Internet[idx]);
|
|
|
- fp = popen(cmd, "r");
|
|
|
- if(fp != NULL)
|
|
|
+ while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
{
|
|
|
- while(fgets(buf, sizeof(buf), fp) != NULL)
|
|
|
+ if(strstr(buf, "transmitted") > 0)
|
|
|
{
|
|
|
- if(strstr(buf, "transmitted") > 0)
|
|
|
- {
|
|
|
- //sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
|
|
|
+ //sscanf(buf, "%*s%*s%*s%*s%*s%*s%s", tmp);
|
|
|
|
|
|
- if(strstr(buf,"100%") != NULL)
|
|
|
- {
|
|
|
+ if(strstr(buf,"100%") != NULL)
|
|
|
+ {
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = PASS;
|
|
|
- }
|
|
|
- //DEBUG_INFO("%s",buf);
|
|
|
- //DEBUG_INFO("%s\n",tmp);
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = PASS;
|
|
|
+ }
|
|
|
+ //DEBUG_INFO("%s",buf);
|
|
|
+ //DEBUG_INFO("%s\n",tmp);
|
|
|
}
|
|
|
}
|
|
|
- pclose(fp);
|
|
|
}
|
|
|
+
|
|
|
+ pclose(fp);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return result;
|
|
|
}
|
|
|
|