Browse Source

[Add][Modularization][Module_4g]

2022.04.21 / Folus Wen

Actions:
1. Quectel force connect to APN by specific radio type, currently as auto detect.

Files:
1. As follow commit history

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

Hardware PWB P/N : XXXXXXX
Hardware Version : XXXXXXX
FolusWen 2 years ago
parent
commit
07f3abffe5

+ 57 - 4
EVSE/Modularization/Module_4g.c

@@ -55,6 +55,19 @@ enum CONNECT_STEP
 	CONNECT_STEP_DISCONNECTED
 };
 
+enum NETWORK_MODE
+{
+	NETWORK_MODE_AUTO=0,
+	NETWORK_MODE_GSM,
+	NETWORK_MODE_WCDMA,
+	NETWORK_MODE_LTE,
+	NETWORK_MODE_TDSCDMA,
+	NETWORK_MODE_UMTS,
+	NETWORK_MODE_CDMA,
+	NETWORK_MODE_HDR,
+	NETWORK_MODE_CDMA_HDR
+};
+
 // Define Module network mode
 #define NET_MODE_NO_SERVICE		0
 #define NET_MODE_CDMA			1
@@ -67,6 +80,7 @@ enum CONNECT_STEP
 #define NET_MODE_UNKNOWN		9
 
 // Define interval
+#define DefaultInterval				5	// Seconds
 #define SystemInterval				30	// Seconds
 #define CheckModemInterval			30	// Seconds
 #define CheckSimInterval			30 	// Seconds
@@ -98,7 +112,7 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
 
 char *portName[3] 				= {"/dev/ttyUSB2", "/dev/ttyACM2", "/dev/ttyACM2"};
 char *valid_Internet[2] 		= {"8.8.8.8", "180.76.76.76"};
-char *Version_And_Date[2]		= {"V0.12","2021-12-06"};
+char *Version_And_Date[2]		= {"V0.13","2022-04-21"};
 pid_t	pid;
 
 struct dongle_info
@@ -1327,6 +1341,34 @@ int csq2rssi(int csq)
 	return result;
 }
 
+void configNetworkMode(uint8_t actReq)
+{
+	FILE *fpOrg = fopen("/root/ppp/ppp-on-dialer-org", "r");
+	FILE *fpDst = fopen("/root/ppp/ppp-on-dialer", "w+");
+	char str[512]={0};
+
+	if(Dongle.Model == DONGLE_QUECTEL)
+	{
+		while (fgets(str, ARRAY_SIZE(str), fpOrg) != NULL)
+		{
+			fprintf(fpDst,"%s", str);
+
+			if(strstr(str, "ATE1") != NULL)
+			{
+				fprintf(fpDst, "	OK		\"AT+QCFG=\\\"nwscanmode\\\",%d,1\"	\\\n", actReq);
+			}
+			memset(str, 0x00, ARRAY_SIZE(str));
+		}
+	}
+	else if(Dongle.Model == DONGLE_THALES)
+	{
+		system("cp /root/ppp/ppp-on-dialer-org /root/ppp/ppp-on-dialer");
+	}
+
+	fclose(fpOrg);
+	fclose(fpDst);
+}
+
 //==========================================
 // Main process
 //==========================================
@@ -1335,7 +1377,7 @@ int main(void)
 	unsigned char Previous_Module_Mode = 0xff;
 	int connectStep=0;
 	int preConnectStep=-1;
-	int delayInterval = 5;
+	int delayInterval = DefaultInterval;
 
 	//==========================================
 	//Initialization share memory
@@ -1404,6 +1446,7 @@ int main(void)
 
 						Dongle.cnt_ReadSimInfoFail = 0;
 						connectStep = CONNECT_STEP_READ_SIM_INFO;
+						delayInterval = DefaultInterval;
 					}
 					else
 					{
@@ -1462,6 +1505,7 @@ int main(void)
 
 						Dongle.cnt_ReadSimInfoFail = 0;
 						connectStep = CONNECT_STEP_CONNECTING;
+						delayInterval = DefaultInterval;
 					}
 					else
 					{
@@ -1511,6 +1555,7 @@ int main(void)
 
 						Dongle.cnt_pppFail = 0;
 						connectStep = CONNECT_STEP_CONNECTED;
+						delayInterval = DefaultInterval;
 					}
 					else
 					{
@@ -1548,6 +1593,12 @@ int main(void)
 							system("killall pppd");
 							sleep(2);
 
+
+							/*
+							 *	TODO:
+							 *	1. Act priority check
+							 */
+							configNetworkMode(NETWORK_MODE_AUTO);
 							if(Dongle.Model == DONGLE_QUECTEL)
 							{
 								system("/root/ppp/4GDetection /dev/ttyUSB3 &");
@@ -1574,7 +1625,7 @@ int main(void)
 						DEBUG_INFO("Into CONNECT_STEP_CONNECTED.\n");
 					}
 
-					if((isReachableInternet() == PASS) && (isReadInfo(connectStep) == PASS))
+					if((isReadInfo(connectStep) == PASS) && (isReachableInternet() == PASS))
 					{
 						ShmStatusCodeData->AlarmCode.AlarmEvents.bits.Telecom4GModuleCommFail = 0;
 						ShmStatusCodeData->InfoCode.InfoEvents.bits.InternetDisconnectVia4Gi = 0;
@@ -1640,9 +1691,11 @@ int main(void)
 
 					if(((Dongle.Model = Check4GModem()) != FAIL))
 					{
+						ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode = 0;
 						ShmStatusCodeData->FaultCode.FaultEvents.bits.Telecom4GModuleBroken = 0;
 						Dongle.cnt_SearchModuleFail = 0;
 						connectStep = CONNECT_STEP_READ_MODULE_INFO;
+						delayInterval = DefaultInterval;
 					}
 					else
 					{
@@ -1720,7 +1773,7 @@ int main(void)
 			}
 
 			connectStep = CONNECT_STEP_CHECK_MODULE;
-			delayInterval = SystemInterval;
+			delayInterval = DefaultInterval;
 		}
 
 		sleep(delayInterval);

+ 0 - 80
EVSE/rootfs/root/ppp/ppp-on-dialer

@@ -1,80 +0,0 @@
-#!/bin/sh
-
-auto_apn_conf="/root/ppp/auto-apn.conf"
-c3g_gprs_conf="/root/ppp/3g-gprs.conf"
-
-sim-auth -f "$c3g_gprs_conf" &>/dev/null
-auto-apn &>/dev/null
-
-if [ -f "$auto_apn_conf" ]; then
-	source "$auto_apn_conf"
-fi
-
-if [ -f "$c3g_gprs_conf" ]; then
-	source "$c3g_gprs_conf"
-fi
-
-#
-# This is part 2 of the ppp-on script. It will perform the connection
-# protocol for the desired connection.
-#
-if [ "$ACCOUNT" == "" ] || [ "$PASSWORD" == "" ]; then
-exec /root/ppp/chat -v						\
-	SAY		"BEGIN\n"			\
-        TIMEOUT         22                              \
-	ECHO		ON				\
-	ABORT           '\nBUSY\r'                      \
-	ABORT           '\nERROR\r'                     \
-	ABORT           '\nNO ANSWER\r'                 \
-	ABORT           '\nNO CARRIER\r'                \
-	ABORT           '\nNO DIALTONE\r'               \
-	ABORT           '\nRINGING\r\n\r\nRINGING\r'    \
-	SAY             "Press CTRL-C to close the connection at any stage!"    \
-	SAY             "\ndefining PDP context...\n"   \
-	""              \\d 				\
-        ""              "AT+CPIN?"                      \
-        TIMEOUT         5                               \
-        READY-AT+CPIN=\"$PIN\"-OK "AT"                  \
-	OK              \\d\\d\\d  	                \
-	""              "ATZ" 				\
-	OK              "ATE1" 				\
-	OK              "AT+CGDCONT=1,\"IP\",\"$APN\" " \
-        TIMEOUT         22                              \
-	OK             	\\d\\d\\d			\
-	""		ATD$TELEPHONE      	 	\
-	TIMEOUT         22 		                \
-	SAY             "\nwaiting for connect...\n"    \
-        CONNECT		""				\
-	SAY             "\nConnected." 			\
-	SAY             "\nIf the following ppp negotiations fail,\n"   \
-	SAY             "try restarting the phone.\n"
-else
-exec /root/ppp/chat -v						\
-	SAY		"BEGIN\n"			\
-        TIMEOUT         22                              \
-	ECHO		ON				\
-	ABORT           '\nBUSY\r'                      \
-	ABORT           '\nERROR\r'                     \
-	ABORT           '\nNO ANSWER\r'                 \
-	ABORT           '\nNO CARRIER\r'                \
-	ABORT           '\nNO DIALTONE\r'               \
-	ABORT           '\nRINGING\r\n\r\nRINGING\r'    \
-	SAY             "Press CTRL-C to close the connection at any stage!"    \
-	SAY             "\ndefining PDP context...\n"   \
-	""              \\d 				\
-        ""              "AT+CPIN?"                      \
-        TIMEOUT         5                               \
-        READY-AT+CPIN=\"$PIN\"-OK "AT"                  \
-	OK              \\d\\d\\d  	                \
-	""              "ATZ" 				\
-	OK              "ATE1" 				\
-	OK              "AT+CGDCONT=1,\"IP\",\"$APN\" " \
-        TIMEOUT         22                              \
-	OK             	\\d\\d\\d			\
-	""		ATD$TELEPHONE      	 	\
-	TIMEOUT         22 		                \
-	SAY             "\nwaiting for connect...\n"    \
-        CONNECT		""				\
-	#ogin:--ogin:	$ACCOUNT			\
-	#assword:	$PASSWORD
-fi

+ 80 - 0
EVSE/rootfs/root/ppp/ppp-on-dialer-org

@@ -0,0 +1,80 @@
+#!/bin/sh
+
+auto_apn_conf="/root/ppp/auto-apn.conf"
+c3g_gprs_conf="/root/ppp/3g-gprs.conf"
+
+sim-auth -f "$c3g_gprs_conf" &>/dev/null
+auto-apn &>/dev/null
+
+if [ -f "$auto_apn_conf" ]; then
+	source "$auto_apn_conf"
+fi
+
+if [ -f "$c3g_gprs_conf" ]; then
+	source "$c3g_gprs_conf"
+fi
+
+#
+# This is part 2 of the ppp-on script. It will perform the connection
+# protocol for the desired connection.
+#
+if [ "$ACCOUNT" == "" ] || [ "$PASSWORD" == "" ]; then
+exec /root/ppp/chat -v						\
+	SAY		"BEGIN\n"			\
+        TIMEOUT         22                              \
+	ECHO		ON				\
+	ABORT           '\nBUSY\r'                      \
+	ABORT           '\nERROR\r'                     \
+	ABORT           '\nNO ANSWER\r'                 \
+	ABORT           '\nNO CARRIER\r'                \
+	ABORT           '\nNO DIALTONE\r'               \
+	ABORT           '\nRINGING\r\n\r\nRINGING\r'    \
+	SAY             "Press CTRL-C to close the connection at any stage!"    \
+	SAY             "\ndefining PDP context...\n"   \
+	""              \\d 				\
+        ""              "AT+CPIN?"                      \
+        TIMEOUT         5                               \
+        READY-AT+CPIN=\"$PIN\"-OK "AT"                  \
+	OK              \\d\\d\\d  	                \
+	""              "ATZ" 				\
+	OK              "ATE1" 				\
+	OK              "AT+CGDCONT=1,\"IP\",\"$APN\" " \
+        TIMEOUT         22                              \
+	OK             	\\d\\d\\d			\
+	""		ATD$TELEPHONE      	 	\
+	TIMEOUT         22 		                \
+	SAY             "\nwaiting for connect...\n"    \
+        CONNECT		""				\
+	SAY             "\nConnected." 			\
+	SAY             "\nIf the following ppp negotiations fail,\n"   \
+	SAY             "try restarting the phone.\n"
+else
+exec /root/ppp/chat -v						\
+	SAY		"BEGIN\n"			\
+        TIMEOUT         22                              \
+	ECHO		ON				\
+	ABORT           '\nBUSY\r'                      \
+	ABORT           '\nERROR\r'                     \
+	ABORT           '\nNO ANSWER\r'                 \
+	ABORT           '\nNO CARRIER\r'                \
+	ABORT           '\nNO DIALTONE\r'               \
+	ABORT           '\nRINGING\r\n\r\nRINGING\r'    \
+	SAY             "Press CTRL-C to close the connection at any stage!"    \
+	SAY             "\ndefining PDP context...\n"   \
+	""              \\d 				\
+        ""              "AT+CPIN?"                      \
+        TIMEOUT         5                               \
+        READY-AT+CPIN=\"$PIN\"-OK "AT"                  \
+	OK              \\d\\d\\d  	                \
+	""              "ATZ" 				\
+	OK              "ATE1" 				\
+	OK              "AT+CGDCONT=1,\"IP\",\"$APN\" " \
+        TIMEOUT         22                              \
+	OK             	\\d\\d\\d			\
+	""		ATD$TELEPHONE      	 	\
+	TIMEOUT         22 		                \
+	SAY             "\nwaiting for connect...\n"    \
+        CONNECT		""				\
+	#ogin:--ogin:	$ACCOUNT			\
+	#assword:	$PASSWORD
+fi