Re-aligned with vshymanskyy-master
This commit is contained in:
		
							
								
								
									
										172
									
								
								examples/AllFunctions/AllFunctions.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										172
									
								
								examples/AllFunctions/AllFunctions.ino
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,172 @@ | ||||
| /************************************************************** | ||||
|  * | ||||
|  * TinyGSM Getting Started guide: | ||||
|  *   http://tiny.cc/tiny-gsm-readme | ||||
|  * | ||||
|  * NOTE: | ||||
|  * Some of the functions may be unavailable for your modem. | ||||
|  * Just comment them out. | ||||
|  * | ||||
|  **************************************************************/ | ||||
|  | ||||
| // Select your modem: | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| // #define TINY_GSM_MODEM_A6 | ||||
| // #define TINY_GSM_MODEM_A7 | ||||
| // #define TINY_GSM_MODEM_M590 | ||||
|  | ||||
| // 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 | ||||
| #define SerialAT Serial1 | ||||
|  | ||||
| // or Software Serial on Uno, Nano | ||||
| //#include <SoftwareSerial.h> | ||||
| //SoftwareSerial SerialAT(2, 3); // RX, TX | ||||
|  | ||||
|  | ||||
| //#define DUMP_AT_COMMANDS | ||||
| #define TINY_GSM_DEBUG SerialMon | ||||
|  | ||||
| // Set phone numbers, if you want to test SMS and Calls | ||||
| //#define SMS_TARGET  "+380xxxxxxxxx" | ||||
| //#define CALL_TARGET "+380xxxxxxxxx" | ||||
|  | ||||
| // Your GPRS credentials | ||||
| // Leave empty, if missing user or pass | ||||
| const char apn[]  = "YourAPN"; | ||||
| const char user[] = ""; | ||||
| const char pass[] = ""; | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
|  | ||||
| #ifdef DUMP_AT_COMMANDS | ||||
|   #include <StreamDebugger.h> | ||||
|   StreamDebugger debugger(SerialAT, SerialMon); | ||||
|   TinyGsm modem(debugger); | ||||
| #else | ||||
|   TinyGsm modem(SerialAT); | ||||
| #endif | ||||
|  | ||||
| void setup() { | ||||
|   // Set console baud rate | ||||
|   SerialMon.begin(115200); | ||||
|   delay(10); | ||||
|  | ||||
|   // Set GSM module baud rate | ||||
|   TinyGsmAutoBaud(SerialAT); | ||||
|   delay(3000); | ||||
| } | ||||
|  | ||||
| void loop() { | ||||
|  | ||||
|   // Restart takes quite some time | ||||
|   // To skip it, call init() instead of restart() | ||||
|   DBG("Initializing modem..."); | ||||
|   if (!modem.restart()) { | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   DBG("Modem:", modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
|  | ||||
|   DBG("Waiting for network..."); | ||||
|   if (!modem.waitForNetwork()) { | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   DBG("Connecting to", apn); | ||||
|   if (!modem.gprsConnect(apn, user, pass)) { | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   bool res; | ||||
|  | ||||
|   String ccid = modem.getSimCCID(); | ||||
|   DBG("CCID:", ccid); | ||||
|  | ||||
|   String imei = modem.getIMEI(); | ||||
|   DBG("IMEI:", imei); | ||||
|  | ||||
|   String cop = modem.getOperator(); | ||||
|   DBG("Operator:", cop); | ||||
|    | ||||
|   IPAddress local = modem.localIP(); | ||||
|   DBG("Local IP:", local); | ||||
|  | ||||
|   int csq = modem.getSignalQuality(); | ||||
|   DBG("Signal quality:", csq); | ||||
|  | ||||
|   // This is NOT supported on M590 | ||||
|   int battLevel = modem.getBattPercent(); | ||||
|   DBG("Battery lavel:", battLevel); | ||||
|  | ||||
|   // This is only supported on SIMxxx series | ||||
|   float battVoltage = modem.getBattVoltage() / 1000.0F; | ||||
|   DBG("Battery voltage:", battVoltage); | ||||
|  | ||||
|   // This is only supported on SIMxxx series | ||||
|   String gsmLoc = modem.getGsmLocation(); | ||||
|   DBG("GSM location:", gsmLoc); | ||||
|  | ||||
|   String ussd_balance = modem.sendUSSD("*111#"); | ||||
|   DBG("Balance (USSD):", ussd_balance); | ||||
|  | ||||
|   String ussd_phone_num = modem.sendUSSD("*161#"); | ||||
|   DBG("Phone number (USSD):", ussd_phone_num); | ||||
|  | ||||
| #if defined(TINY_GSM_MODEM_SIM808) | ||||
|   modem.enableGPS(); | ||||
|   String gps_raw = modem.getGPSraw(); | ||||
|   modem.disableGPS(); | ||||
|   DBG("GPS raw data:", gps_raw); | ||||
| #endif | ||||
|  | ||||
| #if defined(SMS_TARGET) | ||||
|   res = modem.sendSMS(SMS_TARGET, String("Hello from ") + imei); | ||||
|   DBG("SMS:", res ? "OK" : "fail"); | ||||
|  | ||||
|   // This is only supported on SIMxxx series | ||||
|   res = modem.sendSMS_UTF16(SMS_TARGET, u"Привіііт!", 9); | ||||
|   DBG("UTF16 SMS:", res ? "OK" : "fail"); | ||||
| #endif | ||||
|  | ||||
| #if defined(CALL_TARGET) | ||||
|   DBG("Calling:", CALL_TARGET); | ||||
|  | ||||
|   // This is NOT supported on M590 | ||||
|   res = modem.callNumber(CALL_TARGET); | ||||
|   DBG("Call:", res ? "OK" : "fail"); | ||||
|  | ||||
|   if (res) { | ||||
|     delay(5000L); | ||||
|    | ||||
|     res = modem.callHangup(); | ||||
|     DBG("Hang up:", res ? "OK" : "fail"); | ||||
|   } | ||||
| #endif | ||||
|  | ||||
|   modem.gprsDisconnect(); | ||||
|   DBG("GPRS disconnected"); | ||||
|  | ||||
|   // Try to power-off (modem may decide to restart automatically) | ||||
|   // To turn off modem completely, please use Reset/Enable pins | ||||
|   modem.poweroff(); | ||||
|   DBG("Poweroff."); | ||||
|  | ||||
|   // Do nothing forevermore | ||||
|   while (true) { | ||||
|     modem.maintain(); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -30,12 +30,13 @@ | ||||
|  | ||||
| // Select your modem: | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| // #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  | ||||
| // #define TINY_GSM_MODEM_XBEE | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
| #include <BlynkSimpleSIM800.h> | ||||
| @@ -74,6 +75,10 @@ void setup() | ||||
|   Serial.println("Initializing modem..."); | ||||
|   modem.restart(); | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   Serial.print("Modem: "); | ||||
|   Serial.println(modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| /************************************************************** | ||||
|  * | ||||
|  * For this example, you need to install CRC32 library: | ||||
|  *   https://github.com/vshymanskyy/CRC32.git | ||||
|  *   https://github.com/bakercp/CRC32 | ||||
|  *   or from http://librarymanager/all#CRC32+checksum | ||||
|  * | ||||
|  * TinyGSM Getting Started guide: | ||||
| @@ -14,18 +14,19 @@ | ||||
|  | ||||
| // Select your modem: | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| // #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  | ||||
| // #define TINY_GSM_MODEM_XBEE | ||||
|  | ||||
| // Increase RX buffer | ||||
| #define TINY_GSM_RX_BUFFER 1030 | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
| #include <CRC32.h> | ||||
| //#define DUMP_AT_COMMANDS | ||||
| //#define TINY_GSM_DEBUG Serial | ||||
|  | ||||
| // Your GPRS credentials | ||||
| // Leave empty, if missing user or pass | ||||
| @@ -40,12 +41,23 @@ const char pass[] = ""; | ||||
| //#include <SoftwareSerial.h> | ||||
| //SoftwareSerial SerialAT(2, 3); // RX, TX | ||||
|  | ||||
| TinyGsm modem(SerialAT); | ||||
| #include <TinyGsmClient.h> | ||||
| #include <CRC32.h> | ||||
|  | ||||
| #ifdef DUMP_AT_COMMANDS | ||||
|   #include <StreamDebugger.h> | ||||
|   StreamDebugger debugger(SerialAT, Serial); | ||||
|   TinyGsm modem(debugger); | ||||
| #else | ||||
|   TinyGsm modem(SerialAT); | ||||
| #endif | ||||
| TinyGsmClient client(modem); | ||||
|  | ||||
| const char server[] = "cdn.rawgit.com"; | ||||
| const char resource[] = "/vshymanskyy/tinygsm/master/extras/test_1k.bin"; | ||||
| uint32_t knownCRC32 = 0x6f50d767; | ||||
| const int  port     = 80; | ||||
|  | ||||
| const char resource[]  = "/vshymanskyy/tinygsm/master/extras/test_1k.bin"; | ||||
| uint32_t knownCRC32    = 0x6f50d767; | ||||
| uint32_t knownFileSize = 1024;   // In case server does not send it | ||||
|  | ||||
| void setup() { | ||||
| @@ -62,6 +74,10 @@ void setup() { | ||||
|   Serial.println("Initializing modem..."); | ||||
|   modem.restart(); | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   Serial.print("Modem: "); | ||||
|   Serial.println(modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
| } | ||||
| @@ -99,7 +115,7 @@ void loop() { | ||||
|   Serial.print(server); | ||||
|  | ||||
|   // if you get a connection, report back via serial: | ||||
|   if (!client.connect(server, 80)) { | ||||
|   if (!client.connect(server, port)) { | ||||
|     Serial.println(" fail"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   | ||||
							
								
								
									
										152
									
								
								examples/HttpClient/HttpClient.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										152
									
								
								examples/HttpClient/HttpClient.ino
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,152 @@ | ||||
| /************************************************************** | ||||
|  * | ||||
|  * This sketch connects to a website and downloads a page. | ||||
|  * It can be used to perform HTTP/RESTful API calls. | ||||
|  * | ||||
|  * For this example, you need to install ArduinoHttpClient library: | ||||
|  *   https://github.com/arduino-libraries/ArduinoHttpClient | ||||
|  *   or from http://librarymanager/all#ArduinoHttpClient | ||||
|  * | ||||
|  * TinyGSM Getting Started guide: | ||||
|  *   http://tiny.cc/tiny-gsm-readme | ||||
|  * | ||||
|  **************************************************************/ | ||||
|  | ||||
| // Select your modem: | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| // #define TINY_GSM_MODEM_A6 | ||||
| // #define TINY_GSM_MODEM_A7 | ||||
| // #define TINY_GSM_MODEM_M590 | ||||
| // #define TINY_GSM_MODEM_ESP8266 | ||||
|  | ||||
| // Increase RX buffer | ||||
| #define TINY_GSM_RX_BUFFER 512 | ||||
|  | ||||
| // Use Hardware Serial on Mega, Leonardo, Micro | ||||
| #define SerialAT Serial1 | ||||
|  | ||||
| // or Software Serial on Uno, Nano | ||||
| //#include <SoftwareSerial.h> | ||||
| //SoftwareSerial SerialAT(2, 3); // RX, TX | ||||
|  | ||||
| //#define DUMP_AT_COMMANDS | ||||
| //#define TINY_GSM_DEBUG Serial | ||||
|  | ||||
|  | ||||
| // Your GPRS credentials | ||||
| // Leave empty, if missing user or pass | ||||
| const char apn[]  = "YourAPN"; | ||||
| const char user[] = ""; | ||||
| const char pass[] = ""; | ||||
|  | ||||
| // Name of the server we want to connect to | ||||
| const char server[] = "cdn.rawgit.com"; | ||||
| const int  port     = 443; | ||||
| // Path to download (this is the bit after the hostname in the URL) | ||||
| const char resource[] = "/vshymanskyy/tinygsm/master/extras/logo.txt"; | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
| #include <ArduinoHttpClient.h> | ||||
|  | ||||
| #ifdef DUMP_AT_COMMANDS | ||||
|   #include <StreamDebugger.h> | ||||
|   StreamDebugger debugger(SerialAT, Serial); | ||||
|   TinyGsm modem(debugger); | ||||
| #else | ||||
|   TinyGsm modem(SerialAT); | ||||
| #endif | ||||
|  | ||||
| TinyGsmClient client(modem); | ||||
| HttpClient http(client, server, port); | ||||
|  | ||||
| void setup() { | ||||
|   // Set console baud rate | ||||
|   Serial.begin(115200); | ||||
|   delay(10); | ||||
|  | ||||
|   // Set GSM module baud rate | ||||
|   SerialAT.begin(115200); | ||||
|   delay(3000); | ||||
|  | ||||
|   // Restart takes quite some time | ||||
|   // To skip it, call init() instead of restart() | ||||
|   Serial.println("Initializing modem..."); | ||||
|   modem.restart(); | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   Serial.print("Modem: "); | ||||
|   Serial.println(modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
| } | ||||
|  | ||||
| void loop() { | ||||
|   Serial.print(F("Waiting for network...")); | ||||
|   if (!modem.waitForNetwork()) { | ||||
|     Serial.println(" fail"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|   Serial.println(" OK"); | ||||
|  | ||||
|   Serial.print(F("Connecting to ")); | ||||
|   Serial.print(apn); | ||||
|   if (!modem.gprsConnect(apn, user, pass)) { | ||||
|     Serial.println(" fail"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|   Serial.println(" OK"); | ||||
|  | ||||
|  | ||||
|   Serial.print(F("Performing HTTP GET request... ")); | ||||
|   int err = http.get(resource); | ||||
|   if (err != 0) { | ||||
|     Serial.println("failed to connect"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   int status = http.responseStatusCode(); | ||||
|   Serial.println(status); | ||||
|   if (!status) { | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   while (http.headerAvailable()) { | ||||
|     String headerName = http.readHeaderName(); | ||||
|     String headerValue = http.readHeaderValue(); | ||||
|     //Serial.println(headerName + " : " + headerValue); | ||||
|   } | ||||
|  | ||||
|   int length = http.contentLength(); | ||||
|   if (length >= 0) { | ||||
|     Serial.println(String("Content length is: ") + length); | ||||
|   } | ||||
|   if (http.isResponseChunked()) { | ||||
|     Serial.println("This response is chunked"); | ||||
|   } | ||||
|  | ||||
|   String body = http.responseBody(); | ||||
|   Serial.println("Response:"); | ||||
|   Serial.println(body); | ||||
|  | ||||
|   Serial.println(String("Body length is: ") + body.length()); | ||||
|  | ||||
|   // Shutdown | ||||
|  | ||||
|   http.stop(); | ||||
|  | ||||
|   modem.gprsDisconnect(); | ||||
|   Serial.println("GPRS disconnected"); | ||||
|  | ||||
|   // Do nothing forevermore | ||||
|   while (true) { | ||||
|     delay(1000); | ||||
|   } | ||||
| } | ||||
|  | ||||
							
								
								
									
										155
									
								
								examples/HttpsClient/HttpsClient.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										155
									
								
								examples/HttpsClient/HttpsClient.ino
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,155 @@ | ||||
| /************************************************************** | ||||
|  * | ||||
|  * This sketch connects to a website and downloads a page. | ||||
|  * It can be used to perform HTTP/RESTful API calls. | ||||
|  * | ||||
|  * For this example, you need to install ArduinoHttpClient library: | ||||
|  *   https://github.com/arduino-libraries/ArduinoHttpClient | ||||
|  *   or from http://librarymanager/all#ArduinoHttpClient | ||||
|  * | ||||
|  * TinyGSM Getting Started guide: | ||||
|  *   http://tiny.cc/tiny-gsm-readme | ||||
|  * | ||||
|  **************************************************************/ | ||||
|  | ||||
| // Select your modem | ||||
| // SSL/TLS is currently supported only with SIM8xx series | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| #define TINY_GSM_MODEM_SIM808 | ||||
|  | ||||
| // Increase RX buffer | ||||
| #define TINY_GSM_RX_BUFFER 64 | ||||
|  | ||||
| // Use Hardware Serial on Mega, Leonardo, Micro | ||||
| #define SerialAT Serial1 | ||||
|  | ||||
| // or Software Serial on Uno, Nano | ||||
| //#include <SoftwareSerial.h> | ||||
| //SoftwareSerial SerialAT(2, 3); // RX, TX | ||||
|  | ||||
| //#define DUMP_AT_COMMANDS | ||||
| //#define TINY_GSM_DEBUG Serial | ||||
|  | ||||
|  | ||||
| // Your GPRS credentials | ||||
| // Leave empty, if missing user or pass | ||||
| const char apn[]  = "YourAPN"; | ||||
| const char user[] = ""; | ||||
| const char pass[] = ""; | ||||
|  | ||||
| // Name of the server we want to connect to | ||||
| const char server[] = "cdn.rawgit.com"; | ||||
| const int  port     = 443; | ||||
| // Path to download (this is the bit after the hostname in the URL) | ||||
| const char resource[] = "/vshymanskyy/tinygsm/master/extras/logo.txt"; | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
| #include <ArduinoHttpClient.h> | ||||
|  | ||||
| #ifdef DUMP_AT_COMMANDS | ||||
|   #include <StreamDebugger.h> | ||||
|   StreamDebugger debugger(SerialAT, Serial); | ||||
|   TinyGsm modem(debugger); | ||||
| #else | ||||
|   TinyGsm modem(SerialAT); | ||||
| #endif | ||||
|  | ||||
| TinyGsmClientSecure client(modem); | ||||
| HttpClient http(client, server, port); | ||||
|  | ||||
| void setup() { | ||||
|   // Set console baud rate | ||||
|   Serial.begin(115200); | ||||
|   delay(10); | ||||
|  | ||||
|   // Set GSM module baud rate | ||||
|   SerialAT.begin(115200); | ||||
|   delay(3000); | ||||
|  | ||||
|   // Restart takes quite some time | ||||
|   // To skip it, call init() instead of restart() | ||||
|   Serial.println("Initializing modem..."); | ||||
|   modem.restart(); | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   Serial.print("Modem: "); | ||||
|   Serial.println(modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
| } | ||||
|  | ||||
| void loop() { | ||||
|   if (!modem.hasSSL()) { | ||||
|     Serial.println("SSL is not supported by this modem"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   Serial.print(F("Waiting for network...")); | ||||
|   if (!modem.waitForNetwork()) { | ||||
|     Serial.println(" fail"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|   Serial.println(" OK"); | ||||
|  | ||||
|   Serial.print(F("Connecting to ")); | ||||
|   Serial.print(apn); | ||||
|   if (!modem.gprsConnect(apn, user, pass)) { | ||||
|     Serial.println(" fail"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|   Serial.println(" OK"); | ||||
|  | ||||
|  | ||||
|   Serial.print(F("Performing HTTP GET request... ")); | ||||
|   http.connectionKeepAlive(); // Currently, this is needed for HTTPS | ||||
|   int err = http.get(resource); | ||||
|   if (err != 0) { | ||||
|     Serial.println("failed to connect"); | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   int status = http.responseStatusCode(); | ||||
|   Serial.println(status); | ||||
|   if (!status) { | ||||
|     delay(10000); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   while (http.headerAvailable()) { | ||||
|     String headerName = http.readHeaderName(); | ||||
|     String headerValue = http.readHeaderValue(); | ||||
|     //Serial.println(headerName + " : " + headerValue); | ||||
|   } | ||||
|  | ||||
|   int length = http.contentLength(); | ||||
|   if (length >= 0) { | ||||
|     Serial.println(String("Content length is: ") + length); | ||||
|   } | ||||
|   if (http.isResponseChunked()) { | ||||
|     Serial.println("This response is chunked"); | ||||
|   } | ||||
|  | ||||
|   String body = http.responseBody(); | ||||
|   Serial.println("Response:"); | ||||
|   Serial.println(body); | ||||
|  | ||||
|   Serial.println(String("Body length is: ") + body.length()); | ||||
|  | ||||
|   // Shutdown | ||||
|  | ||||
|   http.stop(); | ||||
|  | ||||
|   modem.gprsDisconnect(); | ||||
|   Serial.println("GPRS disconnected"); | ||||
|  | ||||
|   // Do nothing forevermore | ||||
|   while (true) { | ||||
|     delay(1000); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @@ -27,12 +27,13 @@ | ||||
|  | ||||
| // Select your modem: | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| // #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  | ||||
| // #define TINY_GSM_MODEM_XBEE | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
| #include <PubSubClient.h> | ||||
| @@ -81,6 +82,10 @@ void setup() { | ||||
|   Serial.println("Initializing modem..."); | ||||
|   modem.restart(); | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   Serial.print("Modem: "); | ||||
|   Serial.println(modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
|  | ||||
|   | ||||
| @@ -10,12 +10,12 @@ | ||||
|  | ||||
| // Select your modem: | ||||
| #define TINY_GSM_MODEM_SIM800 | ||||
| // #define TINY_GSM_MODEM_SIM808 | ||||
| // #define TINY_GSM_MODEM_SIM900 | ||||
| // #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  | ||||
|  | ||||
| #include <TinyGsmClient.h> | ||||
|  | ||||
| @@ -38,7 +38,7 @@ TinyGsmClient client(modem); | ||||
| const char server[] = "cdn.rawgit.com"; | ||||
| const char resource[] = "/vshymanskyy/tinygsm/master/extras/logo.txt"; | ||||
|  | ||||
| int port = 80; | ||||
| const int port = 80; | ||||
|  | ||||
| void setup() { | ||||
|   // Set console baud rate | ||||
| @@ -54,6 +54,10 @@ void setup() { | ||||
|   Serial.println(F("Initializing modem...")); | ||||
|   modem.restart(); | ||||
|  | ||||
|   String modemInfo = modem.getModemInfo(); | ||||
|   Serial.print("Modem: "); | ||||
|   Serial.println(modemInfo); | ||||
|  | ||||
|   // Unlock your SIM card with a PIN | ||||
|   //modem.simUnlock("1234"); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user