mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Added SIM7000(A/E/C/G)
First version - clone of SIM800 with changed values including /example folder
This commit is contained in:
		| @@ -10,9 +10,10 @@ | |||||||
|  **************************************************************/ |  **************************************************************/ | ||||||
|  |  | ||||||
| // Select your modem: | // Select your modem: | ||||||
| #define TINY_GSM_MODEM_SIM800 | //#define TINY_GSM_MODEM_SIM800 | ||||||
| // #define TINY_GSM_MODEM_SIM808 | // #define TINY_GSM_MODEM_SIM808 | ||||||
| // #define TINY_GSM_MODEM_SIM900 | // #define TINY_GSM_MODEM_SIM900 | ||||||
|  | #define TINY_GSM_MODEM_SIM7000 | ||||||
| // #define TINY_GSM_MODEM_UBLOX | // #define TINY_GSM_MODEM_UBLOX | ||||||
| // #define TINY_GSM_MODEM_BG96 | // #define TINY_GSM_MODEM_BG96 | ||||||
| // #define TINY_GSM_MODEM_A6 | // #define TINY_GSM_MODEM_A6 | ||||||
| @@ -199,4 +200,3 @@ void loop() { | |||||||
|     modem.maintain(); |     modem.maintain(); | ||||||
|   } |   } | ||||||
| } | } | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										187
									
								
								examples/SIM7000-ESP32/Diagnostics/Diagnostics.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										187
									
								
								examples/SIM7000-ESP32/Diagnostics/Diagnostics.ino
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,187 @@ | |||||||
|  | /************************************************************** | ||||||
|  |  * | ||||||
|  |  * To run this tool you need StreamDebugger library: | ||||||
|  |  *   https://github.com/vshymanskyy/StreamDebugger | ||||||
|  |  *   or from http://librarymanager/all#StreamDebugger | ||||||
|  |  * | ||||||
|  |  * TinyGSM Getting Started guide: | ||||||
|  |  *   https://tiny.cc/tinygsm-readme | ||||||
|  |  * | ||||||
|  |  **************************************************************/ | ||||||
|  |  | ||||||
|  | // Select your modem: | ||||||
|  | //#define TINY_GSM_MODEM_SIM800 | ||||||
|  | // #define TINY_GSM_MODEM_SIM808 | ||||||
|  | // #define TINY_GSM_MODEM_SIM900 | ||||||
|  | #define TINY_GSM_MODEM_SIM7000 | ||||||
|  | // #define TINY_GSM_MODEM_UBLOX | ||||||
|  | // #define TINY_GSM_MODEM_BG96 | ||||||
|  | // #define TINY_GSM_MODEM_A6 | ||||||
|  | // #define TINY_GSM_MODEM_A7 | ||||||
|  | // #define TINY_GSM_MODEM_M590 | ||||||
|  | // #define TINY_GSM_MODEM_ESP8266 | ||||||
|  | // #define TINY_GSM_MODEM_XBEE | ||||||
|  |  | ||||||
|  | // Increase the buffer | ||||||
|  | #define TINY_GSM_RX_BUFFER 512 | ||||||
|  |  | ||||||
|  | // Define the serial console for debug prints, if needed | ||||||
|  | //#define TINY_GSM_DEBUG Serial | ||||||
|  |  | ||||||
|  | #include <TinyGsmClient.h> | ||||||
|  |  | ||||||
|  | // Your GPRS credentials | ||||||
|  | // Leave empty, if missing user or pass | ||||||
|  | const char apn[]  = "drei.at"; | ||||||
|  | const char user[] = ""; | ||||||
|  | const char pass[] = ""; | ||||||
|  |  | ||||||
|  | // Set serial for debug console (to the Serial Monitor, speed 115200) | ||||||
|  | #define SerialMon Serial | ||||||
|  |  | ||||||
|  | // Set serial for AT commands (to the module) | ||||||
|  | // Use Hardware Serial on Mega, Leonardo, Micro, Esp32 | ||||||
|  | #include "HardwareSerial.h" | ||||||
|  | #define SerialAT Serial2 | ||||||
|  |  | ||||||
|  | // or Software Serial on Uno, Nano | ||||||
|  | //#include <SoftwareSerial.h> | ||||||
|  | //SoftwareSerial SerialAT(2, 3); // RX, TX | ||||||
|  |  | ||||||
|  | #include <StreamDebugger.h> | ||||||
|  | StreamDebugger debugger(SerialAT, SerialMon); | ||||||
|  | TinyGsm modem(debugger); | ||||||
|  |  | ||||||
|  | const char server[] = "vsh.pp.ua"; | ||||||
|  | const char resource[] = "/TinyGSM/logo.txt"; | ||||||
|  |  | ||||||
|  | const int  port = 80; | ||||||
|  | TinyGsmClient client(modem); | ||||||
|  |  | ||||||
|  | // For SSL: | ||||||
|  | //const int  port = 443; | ||||||
|  | //TinyGsmClientSecure client(modem); | ||||||
|  |  | ||||||
|  | void setup() { | ||||||
|  |   // Set console baud rate | ||||||
|  |   Serial.println("Starting Serial"); | ||||||
|  |   SerialMon.begin(115200); | ||||||
|  |   delay(10); | ||||||
|  |  | ||||||
|  |   // Set GSM module baud rate | ||||||
|  |   SerialAT.begin(9600); | ||||||
|  |   delay(3000); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void loop() { | ||||||
|  |   // Restart takes quite some time | ||||||
|  |   // To skip it, call init() instead of restart() | ||||||
|  |   SerialMon.print("Initializing modem..."); | ||||||
|  |   if (!modem.restart()) { | ||||||
|  |     SerialMon.println(F(" [fail]")); | ||||||
|  |     SerialMon.println(F("************************")); | ||||||
|  |     SerialMon.println(F(" Is your modem connected properly?")); | ||||||
|  |     SerialMon.println(F(" Is your serial speed (baud rate) correct?")); | ||||||
|  |     SerialMon.println(F(" Is your modem powered on?")); | ||||||
|  |     SerialMon.println(F(" Do you use a good, stable power source?")); | ||||||
|  |     SerialMon.println(F(" Try useing File -> Examples -> TinyGSM -> tools -> AT_Debug to find correct configuration")); | ||||||
|  |     SerialMon.println(F("************************")); | ||||||
|  |     delay(10000); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |   SerialMon.println(F(" [OK]")); | ||||||
|  |  | ||||||
|  |   String modemInfo = modem.getModemInfo(); | ||||||
|  |   SerialMon.print("Modem: "); | ||||||
|  |   SerialMon.println(modemInfo); | ||||||
|  |  | ||||||
|  |   // Unlock your SIM card with a PIN | ||||||
|  |   //modem.simUnlock("1234"); | ||||||
|  |  | ||||||
|  |   SerialMon.print("Waiting for network..."); | ||||||
|  |   if (!modem.waitForNetwork()) { | ||||||
|  |     SerialMon.println(F(" [fail]")); | ||||||
|  |     SerialMon.println(F("************************")); | ||||||
|  |     SerialMon.println(F(" Is your sim card locked?")); | ||||||
|  |     SerialMon.println(F(" Do you have a good signal?")); | ||||||
|  |     SerialMon.println(F(" Is antenna attached?")); | ||||||
|  |     SerialMon.println(F(" Does the SIM card work with your phone?")); | ||||||
|  |     SerialMon.println(F("************************")); | ||||||
|  |     delay(10000); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |   SerialMon.println(F(" [OK]")); | ||||||
|  |  | ||||||
|  |   SerialMon.print("Connecting to "); | ||||||
|  |   SerialMon.print(apn); | ||||||
|  |   if (!modem.gprsConnect(apn, user, pass)) { | ||||||
|  |     SerialMon.println(F(" [fail]")); | ||||||
|  |     SerialMon.println(F("************************")); | ||||||
|  |     SerialMon.println(F(" Is GPRS enabled by network provider?")); | ||||||
|  |     SerialMon.println(F(" Try checking your card balance.")); | ||||||
|  |     SerialMon.println(F("************************")); | ||||||
|  |     delay(10000); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |   SerialMon.println(F(" [OK]")); | ||||||
|  |  | ||||||
|  |   IPAddress local = modem.localIP(); | ||||||
|  |   SerialMon.print("Local IP: "); | ||||||
|  |   SerialMon.println(local); | ||||||
|  |  | ||||||
|  |   SerialMon.print(F("Connecting to ")); | ||||||
|  |   SerialMon.print(server); | ||||||
|  |   if (!client.connect(server, port)) { | ||||||
|  |     SerialMon.println(F(" [fail]")); | ||||||
|  |     delay(10000); | ||||||
|  |     return; | ||||||
|  |   } | ||||||
|  |   SerialMon.println(F(" [OK]")); | ||||||
|  |  | ||||||
|  |   // Make a HTTP GET request: | ||||||
|  |   client.print(String("GET ") + resource + " HTTP/1.0\r\n"); | ||||||
|  |   client.print(String("Host: ") + server + "\r\n"); | ||||||
|  |   client.print("Connection: close\r\n\r\n"); | ||||||
|  |  | ||||||
|  |   // Wait for data to arrive | ||||||
|  |   while (client.connected() && !client.available()) { | ||||||
|  |     delay(100); | ||||||
|  |     SerialMon.print('.'); | ||||||
|  |   }; | ||||||
|  |   SerialMon.println(); | ||||||
|  |  | ||||||
|  |   // Skip all headers | ||||||
|  |   client.find("\r\n\r\n"); | ||||||
|  |  | ||||||
|  |   // Read data | ||||||
|  |   unsigned long timeout = millis(); | ||||||
|  |   unsigned long bytesReceived = 0; | ||||||
|  |   while (client.connected() && millis() - timeout < 10000L) { | ||||||
|  |     while (client.available()) { | ||||||
|  |       char c = client.read(); | ||||||
|  |       //SerialMon.print(c); | ||||||
|  |       bytesReceived += 1; | ||||||
|  |       timeout = millis(); | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   client.stop(); | ||||||
|  |   SerialMon.println(F("Server disconnected")); | ||||||
|  |  | ||||||
|  |   modem.gprsDisconnect(); | ||||||
|  |   SerialMon.println(F("GPRS disconnected")); | ||||||
|  |  | ||||||
|  |   SerialMon.println(); | ||||||
|  |   SerialMon.println(F("************************")); | ||||||
|  |   SerialMon.print  (F(" Received: ")); | ||||||
|  |   SerialMon.print(bytesReceived); | ||||||
|  |   SerialMon.println(F(" bytes")); | ||||||
|  |   SerialMon.print  (F(" Test:     ")); | ||||||
|  |   SerialMon.println((bytesReceived == 121) ? "PASSED" : "FAILED"); | ||||||
|  |   SerialMon.println(F("************************")); | ||||||
|  |  | ||||||
|  |   // Do nothing forevermore | ||||||
|  |   while (true) { | ||||||
|  |     delay(1000); | ||||||
|  |   } | ||||||
|  | } | ||||||
| @@ -9,11 +9,11 @@ | |||||||
| #ifndef TinyGsmClient_h | #ifndef TinyGsmClient_h | ||||||
| #define TinyGsmClient_h | #define TinyGsmClient_h | ||||||
|  |  | ||||||
| #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM868) || defined(TINY_GSM_MODEM_UBLOX) || defined(TINY_GSM_MODEM_ESP8266) | #if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_SIM868) || defined(TINY_GSM_MODEM_UBLOX) || defined(TINY_GSM_MODEM_ESP8266) || defined(TINY_GSM_MODEM_SIM7000) | ||||||
|   #define TINY_GSM_MODEM_HAS_SSL |   #define TINY_GSM_MODEM_HAS_SSL | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if defined(TINY_GSM_MODEM_SIM808) || defined(TINY_GSM_MODEM_SIM868) || defined(TINY_GSM_MODEM_A7) | #if defined(TINY_GSM_MODEM_SIM808) || defined(TINY_GSM_MODEM_SIM868) || defined(TINY_GSM_MODEM_A7) || defined(TINY_GSM_MODEM_SIM7000) | ||||||
|   #define TINY_GSM_MODEM_HAS_GPS |   #define TINY_GSM_MODEM_HAS_GPS | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -24,6 +24,13 @@ | |||||||
|   typedef TinyGsmSim800::GsmClient TinyGsmClient; |   typedef TinyGsmSim800::GsmClient TinyGsmClient; | ||||||
|   typedef TinyGsmSim800::GsmClientSecure TinyGsmClientSecure; |   typedef TinyGsmSim800::GsmClientSecure TinyGsmClientSecure; | ||||||
|  |  | ||||||
|  | #elif   defined(TINY_GSM_MODEM_SIM7000) | ||||||
|  |   #define TINY_GSM_MODEM_HAS_GPRS | ||||||
|  |   #include <TinyGsmClientSIM7000.h> | ||||||
|  |   typedef TinyGsmSim7000 TinyGsm; | ||||||
|  |   typedef TinyGsmSim7000::GsmClient TinyGsmClient; | ||||||
|  |   typedef TinyGsmSim7000::GsmClientSecure TinyGsmClientSecure; | ||||||
|  |  | ||||||
| #elif defined(TINY_GSM_MODEM_SIM808) || defined(TINY_GSM_MODEM_SIM868) | #elif defined(TINY_GSM_MODEM_SIM808) || defined(TINY_GSM_MODEM_SIM868) | ||||||
|   #define TINY_GSM_MODEM_HAS_GPRS |   #define TINY_GSM_MODEM_HAS_GPRS | ||||||
|   #include <TinyGsmClientSIM808.h> |   #include <TinyGsmClientSIM808.h> | ||||||
|   | |||||||
							
								
								
									
										1000
									
								
								src/TinyGsmClientSIM7000.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1000
									
								
								src/TinyGsmClientSIM7000.h
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user