11#include < PPP.h>
22
3- #define PPP_MODEM_APN " internet"
4- #define PPP_MODEM_PIN " 0000" // or NULL
3+ #define PPP_MODEM_APN " internet"
4+ #define PPP_MODEM_PIN " 0000" // or NULL
55
66// WaveShare SIM7600 HW Flow Control
7- #define PPP_MODEM_RST 25
8- #define PPP_MODEM_RST_LOW false // active HIGH
9- #define PPP_MODEM_TX 21
10- #define PPP_MODEM_RX 22
11- #define PPP_MODEM_RTS 26
12- #define PPP_MODEM_CTS 27
13- #define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW
14- #define PPP_MODEM_MODEL PPP_MODEM_SIM7600
7+ #define PPP_MODEM_RST 25
8+ #define PPP_MODEM_RST_LOW false // active HIGH
9+ #define PPP_MODEM_TX 21
10+ #define PPP_MODEM_RX 22
11+ #define PPP_MODEM_RTS 26
12+ #define PPP_MODEM_CTS 27
13+ #define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_HW
14+ #define PPP_MODEM_MODEL PPP_MODEM_SIM7600
1515
1616// SIM800 basic module with just TX,RX and RST
1717// #define PPP_MODEM_RST 0
2323// #define PPP_MODEM_FC ESP_MODEM_FLOW_CONTROL_NONE
2424// #define PPP_MODEM_MODEL PPP_MODEM_SIM800
2525
26- void onEvent (arduino_event_id_t event, arduino_event_info_t info)
27- {
26+ void onEvent (arduino_event_id_t event, arduino_event_info_t info) {
2827 switch (event) {
2928 case ARDUINO_EVENT_PPP_START:
3029 Serial.println (" PPP Started" );
@@ -49,16 +48,17 @@ void onEvent(arduino_event_id_t event, arduino_event_info_t info)
4948 }
5049}
5150
52- void testClient (const char * host, uint16_t port) {
51+ void testClient (const char * host, uint16_t port) {
5352 NetworkClient client;
5453 if (!client.connect (host, port)) {
5554 Serial.println (" Connection Failed" );
5655 return ;
5756 }
5857 client.printf (" GET / HTTP/1.1\r\n Host: %s\r\n\r\n " , host);
59- while (client.connected () && !client.available ());
58+ while (client.connected () && !client.available ())
59+ ;
6060 while (client.available ()) {
61- client.read ();// Serial.write(client.read());
61+ client.read (); // Serial.write(client.read());
6262 }
6363
6464 Serial.println (" Connection Success" );
@@ -70,7 +70,7 @@ void setup() {
7070
7171 // Listen for modem events
7272 Network.onEvent (onEvent);
73-
73+
7474 // Configure the modem
7575 PPP.setApn (PPP_MODEM_APN);
7676 PPP.setPin (PPP_MODEM_PIN);
@@ -80,16 +80,19 @@ void setup() {
8080 Serial.println (" Starting the modem. It might take a while!" );
8181 PPP.begin (PPP_MODEM_MODEL);
8282
83- Serial.print (" Manufacturer: " ); Serial.println (PPP.cmd (" AT+CGMI" , 10000 ));
84- Serial.print (" Model: " ); Serial.println (PPP.moduleName ());
85- Serial.print (" IMEI: " ); Serial.println (PPP.IMEI ());
86-
83+ Serial.print (" Manufacturer: " );
84+ Serial.println (PPP.cmd (" AT+CGMI" , 10000 ));
85+ Serial.print (" Model: " );
86+ Serial.println (PPP.moduleName ());
87+ Serial.print (" IMEI: " );
88+ Serial.println (PPP.IMEI ());
89+
8790 bool attached = PPP.attached ();
88- if (!attached){
89- int i= 0 ;
91+ if (!attached) {
92+ int i = 0 ;
9093 unsigned int s = millis ();
9194 Serial.print (" Waiting to connect to network" );
92- while (!attached && ((++i) < 600 )){
95+ while (!attached && ((++i) < 600 )) {
9396 Serial.print (" ." );
9497 delay (100 );
9598 attached = PPP.attached ();
@@ -98,22 +101,29 @@ void setup() {
98101 Serial.println (" s" );
99102 attached = PPP.attached ();
100103 }
101-
102- Serial.print (" Attached: " ); Serial.println (attached);
103- Serial.print (" State: " ); Serial.println (PPP.radioState ());
104- if (attached){
105- Serial.print (" Operator: " ); Serial.println (PPP.operatorName ());
106- Serial.print (" IMSI: " ); Serial.println (PPP.IMSI ());
107- Serial.print (" RSSI: " ); Serial.println (PPP.RSSI ());
104+
105+ Serial.print (" Attached: " );
106+ Serial.println (attached);
107+ Serial.print (" State: " );
108+ Serial.println (PPP.radioState ());
109+ if (attached) {
110+ Serial.print (" Operator: " );
111+ Serial.println (PPP.operatorName ());
112+ Serial.print (" IMSI: " );
113+ Serial.println (PPP.IMSI ());
114+ Serial.print (" RSSI: " );
115+ Serial.println (PPP.RSSI ());
108116 int ber = PPP.BER ();
109- if (ber > 0 ){
110- Serial.print (" BER: " ); Serial.println (ber);
111- Serial.print (" NetMode: " ); Serial.println (PPP.networkMode ());
117+ if (ber > 0 ) {
118+ Serial.print (" BER: " );
119+ Serial.println (ber);
120+ Serial.print (" NetMode: " );
121+ Serial.println (PPP.networkMode ());
112122 }
113-
123+
114124 Serial.println (" Switching to data mode..." );
115- PPP.mode (ESP_MODEM_MODE_CMUX); // Data and Command mixed mode
116- if (!PPP.waitStatusBits (ESP_NETIF_CONNECTED_BIT, 1000 )){
125+ PPP.mode (ESP_MODEM_MODE_CMUX); // Data and Command mixed mode
126+ if (!PPP.waitStatusBits (ESP_NETIF_CONNECTED_BIT, 1000 )) {
117127 Serial.println (" Failed to connect to internet!" );
118128 } else {
119129 Serial.println (" Connected to internet!" );
0 commit comments