mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Moved all src files into the src directory
Also fixed the "isNetworkConnected" for ESP8266
This commit is contained in:
		| @@ -16,7 +16,7 @@ | ||||
|   }, | ||||
|   "homepage": "https://github.com/vshymanskyy/TinyGSM", | ||||
|   "export": { | ||||
|     "exclude": [ "extras", "tools" ] | ||||
|     "exclude": [ "extras/*", "tools/*" ] | ||||
|   }, | ||||
|   "frameworks": [ "arduino", "energia", "wiringpi" ], | ||||
|   "platforms": "*", | ||||
|   | ||||
| @@ -268,22 +268,25 @@ public: | ||||
|     streamSkipUntil(',');  // Skip BSSID/MAC address
 | ||||
|     streamSkipUntil(',');  // Skip Chanel number
 | ||||
|     int res2 = stream.parseInt();  // Read RSSI
 | ||||
|     waitResponse(); | ||||
|     waitResponse();  // Returns an OK after the value
 | ||||
|     return res2; | ||||
|   } | ||||
| 
 | ||||
|   bool isNetworkConnected() { | ||||
|     sendAT(GF("+CIPSTATUS")); | ||||
|     int res1 = waitResponse(3000, GF("STATUS:")); | ||||
|     int res2; | ||||
|     if (res1 == 1) { | ||||
|       int res2 = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5")); | ||||
|       if (res2 == 2 || res2 == 3 || res2 == 4) return true; | ||||
|       res2 = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5")); | ||||
|     } | ||||
|     // <stat> status of ESP8266 station interface
 | ||||
|     // 2 : ESP8266 station connected to an AP and has obtained IP
 | ||||
|     // 3 : ESP8266 station created a TCP or UDP transmission
 | ||||
|     // 4 : the TCP or UDP transmission of ESP8266 station disconnected (but AP is connected)
 | ||||
|     // 5 : ESP8266 station did NOT connect to an AP
 | ||||
|     waitResponse();  // Returns an OK after the status
 | ||||
|     if (res2 == 2 || res2 == 3 || res2 == 4) return true; | ||||
|     else return false; | ||||
|   } | ||||
| 
 | ||||
|   bool waitForNetwork(unsigned long timeout = 60000L) { | ||||
| @@ -373,9 +376,19 @@ protected: | ||||
| 
 | ||||
|   bool modemGetConnected(uint8_t mux) { | ||||
|     sendAT(GF("+CIPSTATUS="), mux); | ||||
|     int res = waitResponse(GF(",\"CONNECTED\""), GF(",\"CLOSED\""), GF(",\"CLOSING\""), GF(",\"INITIAL\"")); | ||||
|     waitResponse(); | ||||
|     return 1 == res; | ||||
|     int res1 = waitResponse(3000, GF("STATUS:")); | ||||
|     int res2; | ||||
|     if (res1 == 1) { | ||||
|       res2 = waitResponse(GFP(GSM_ERROR), GF("2"), GF("3"), GF("4"), GF("5")); | ||||
|     } | ||||
|     // <stat> status of ESP8266 station interface
 | ||||
|     // 2 : ESP8266 station connected to an AP and has obtained IP
 | ||||
|     // 3 : ESP8266 station created a TCP or UDP transmission
 | ||||
|     // 4 : the TCP or UDP transmission of ESP8266 station disconnected (but AP is connected)
 | ||||
|     // 5 : ESP8266 station did NOT connect to an AP
 | ||||
|     waitResponse();  // Returns an OK after the status
 | ||||
|     if (res2 == 2 || res2 == 3 || res2 == 4) return true; | ||||
|     else return false; | ||||
|   } | ||||
| 
 | ||||
| public: | ||||
							
								
								
									
										45
									
								
								tools/AT_Spy/AT_Spy.ino
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								tools/AT_Spy/AT_Spy.ino
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | ||||
| /************************************************************** | ||||
|  * | ||||
|  * This script just listens in on the communication between an Arduino and the | ||||
|  * modem. | ||||
|  * | ||||
|  * TinyGSM Getting Started guide: | ||||
|  *   http://tiny.cc/tiny-gsm-readme | ||||
|  * | ||||
|  **************************************************************/ | ||||
|  | ||||
| // Set the baud rate between the modem and the board | ||||
| #define BAUD_RATE 9600 | ||||
|  | ||||
| // Set serial printing out the communication | ||||
| #define SPY Serial | ||||
|  | ||||
| // Set serial for input from modem | ||||
| #define MODEM_TX Serial1 | ||||
|  | ||||
| // Set serial for AT commands (to the module) | ||||
| // Use Hardware Serial on Mega, Leonardo, Micro | ||||
| // #define BOARD_TX Serial1 | ||||
|  | ||||
| // or AltSoftware | ||||
| #include <AltSoftSerial.h> | ||||
| AltSoftSerial BOARD_TX; | ||||
|  | ||||
|  | ||||
| void setup() { | ||||
|   // Set console baud rate | ||||
|   SPY.begin(57600); | ||||
|   MODEM_TX.begin(BAUD_RATE); | ||||
|   BOARD_TX.begin(BAUD_RATE); | ||||
|   delay(5000); | ||||
| } | ||||
|  | ||||
| void loop() | ||||
| { | ||||
|     while (MODEM_TX.available()) { | ||||
|       SPY.write(MODEM_TX.read()); | ||||
|     } | ||||
|     while (BOARD_TX.available()) { | ||||
|       SPY.write(BOARD_TX.read()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user