mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	Touchup on 5360
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "TinyGSM", |   "name": "TinyGSM", | ||||||
|   "version": "0.9.5", |   "version": "0.9.6", | ||||||
|   "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.", |   "description": "A small Arduino library for GPRS modules, that just works. Includes examples for Blynk, MQTT, File Download, and Web Client. Supports many GSM, LTE, and WiFi modules with AT command interfaces.", | ||||||
|   "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M", |   "keywords": "GSM, AT commands, AT, SIM800, SIM900, A6, A7, M590, ESP8266, SIM7000, SIM800A, SIM800C, SIM800L, SIM800H, SIM808, SIM868, SIM900A, SIM900D, SIM908, SIM968, M95, MC60, MC60E, BG96, ublox, Quectel, SIMCOM, AI Thinker, LTE, LTE-M", | ||||||
|   "authors": |   "authors": | ||||||
|   | |||||||
| @@ -1,5 +1,5 @@ | |||||||
| name=TinyGSM | name=TinyGSM | ||||||
| version=0.9.5 | version=0.9.6 | ||||||
| author=Volodymyr Shymanskyy | author=Volodymyr Shymanskyy | ||||||
| maintainer=Volodymyr Shymanskyy | maintainer=Volodymyr Shymanskyy | ||||||
| sentence=A small Arduino library for GPRS modules, that just works. | sentence=A small Arduino library for GPRS modules, that just works. | ||||||
|   | |||||||
| @@ -40,7 +40,9 @@ | |||||||
|   typedef TinyGsmSim7000::GsmClient TinyGsmClient; |   typedef TinyGsmSim7000::GsmClient TinyGsmClient; | ||||||
|   // typedef TinyGsmSim7000::GsmClientSecure TinyGsmClientSecure; TODO! |   // typedef TinyGsmSim7000::GsmClientSecure TinyGsmClientSecure; TODO! | ||||||
|  |  | ||||||
| #elif defined(TINY_GSM_MODEM_SIM5360) || defined(TINY_GSM_MODEM_SIM5320) | #elif defined(TINY_GSM_MODEM_SIM5320) || defined(TINY_GSM_MODEM_SIM5360) || \ | ||||||
|  |       defined(TINY_GSM_MODEM_SIM5300) || defined(TINY_GSM_MODEM_SIM7100) || \ | ||||||
|  |       defined(TINY_GSM_MODEM_SIM7500) || defined(TINY_GSM_MODEM_SIM7600) | ||||||
|   #define TINY_GSM_MODEM_HAS_GPRS |   #define TINY_GSM_MODEM_HAS_GPRS | ||||||
|   #include <TinyGsmClientSIM5360.h> |   #include <TinyGsmClientSIM5360.h> | ||||||
|   typedef TinyGsmSim5360 TinyGsm; |   typedef TinyGsmSim5360 TinyGsm; | ||||||
|   | |||||||
| @@ -316,49 +316,46 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK() | |||||||
|  |  | ||||||
|     // Define the PDP context |     // Define the PDP context | ||||||
|  |  | ||||||
|     // Using CGDCONT sets up an "external" PCP context, i.e. a data connection |     // The CGDCONT commands set up the "external" PDP context | ||||||
|     // using the external IP stack (e.g. Windows dial up) and PPP link over the |  | ||||||
|     // serial interface.  Is this preferred? |  | ||||||
|  |  | ||||||
|     // Set the authentication |     // Set the external authentication | ||||||
|     if (user && strlen(user) > 0) { |     if (user && strlen(user) > 0) { | ||||||
|       sendAT(GF("+CGAUTH=1,0,\""), user, GF("\",\""), pwd, '"'); |       sendAT(GF("+CGAUTH=1,0,\""), user, GF("\",\""), pwd, '"'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Define PDP context 1 |     // Define PDP context 1 | ||||||
|     sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"'); |     sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"',",\"0.0.0.0\",0,0"); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     sendAT(GF("+CGACT=1,1"));  // activate PDP profile/context 1 |     // The CGSOCKCONT commands define the "embedded" PDP context for TCP/IP | ||||||
|     if (waitResponse(75000L) != 1) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // Using CGSOCKCONT commands defines a PDP context for  Embedded  TCP/IP application |     // Define the socket PDP context | ||||||
|     // CGDCONT commands could be used for an external PDP context |  | ||||||
|  |  | ||||||
|     //  ?? Unsure if this step is needed - redundant with +CGDCONT |  | ||||||
|     sendAT(GF("+CGSOCKCONT=1,\"IP\",\""), apn, '"'); |     sendAT(GF("+CGSOCKCONT=1,\"IP\",\""), apn, '"'); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     // Set the user name and password |     // Set the embedded authentication | ||||||
|     //  ?? Unsure if this step is needed - redundant with +CGAUTH |  | ||||||
|     if (user && strlen(user) > 0) { |     if (user && strlen(user) > 0) { | ||||||
|       sendAT(GF("+CSOCKAUTH=1,1,\""), user, "\",\"", pwd, '"'); |       sendAT(GF("+CSOCKAUTH=1,1,\""), user, "\",\"", pwd, '"'); | ||||||
|       waitResponse(); |       waitResponse(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Set active PDP context’s profile number |     // Set active PDP context’s profile number | ||||||
|     //  ?? Unsure if this step is needed - redundant with +CGAUTH |     // This ties the embedded TCP/IP application to the external PDP context | ||||||
|     sendAT(GF("+CSOCKSETPN=1")); |     sendAT(GF("+CSOCKSETPN=1")); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|  |     // Configure TCP parameters | ||||||
|  |  | ||||||
|  |     // Select TCP/IP application mode (command mode) | ||||||
|  |     sendAT(GF("+CIPMODE=0")); | ||||||
|  |     waitResponse(); | ||||||
|  |  | ||||||
|     // Set Sending Mode - send without waiting for peer TCP ACK |     // Set Sending Mode - send without waiting for peer TCP ACK | ||||||
|     sendAT(GF("+CIPSENDMODE=0")); |     sendAT(GF("+CIPSENDMODE=0")); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     // Configure TCP parameters |     // Configure socket parameters | ||||||
|     //AT+CIPCCFG= [<NmRetry>][,[<DelayTm>][,[<Ack>][,[<errMode>][,]<HeaderType>][,[[<AsyncMode>][,[<TimeoutVal>]]]]]]]] |     //AT+CIPCCFG= [<NmRetry>][,[<DelayTm>][,[<Ack>][,[<errMode>][,]<HeaderType>][,[[<AsyncMode>][,[<TimeoutVal>]]]]]]]] | ||||||
|     // NmRetry = number of retransmission to be made for an IP packet = 10 (default) |     // NmRetry = number of retransmission to be made for an IP packet = 10 (default) | ||||||
|     // DelayTm = number of milliseconds to delay to output data of Receiving = 0 (default) |     // DelayTm = number of milliseconds to delay to output data of Receiving = 0 (default) | ||||||
| @@ -372,23 +369,16 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK() | |||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Select TCP/IP application mode (command mode) |     // Configure timeouts for opening and closing sockets | ||||||
|     sendAT(GF("+CIPMODE=0")); |  | ||||||
|     waitResponse(); |  | ||||||
|  |  | ||||||
|     // Configure timeouts for open and close socket |  | ||||||
|     // AT+CIPTIMEOUT=[<netopen_timeout>][, [<cipopen_timeout>][, [<cipsend_timeout>]]] |     // AT+CIPTIMEOUT=[<netopen_timeout>][, [<cipopen_timeout>][, [<cipsend_timeout>]]] | ||||||
|     sendAT(GF("+CIPTIMEOUT="), 75000, ',', 15000, ',', 15000); |     sendAT(GF("+CIPTIMEOUT="), 75000, ',', 15000, ',', 15000); | ||||||
|     waitResponse(); |     waitResponse(); | ||||||
|  |  | ||||||
|     // attach to GPRS |  | ||||||
|     sendAT(GF("+CGATT=1")); |  | ||||||
|     if (waitResponse(360000L) != 1) { |  | ||||||
|       return false; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     // Start the socket service |     // Start the socket service | ||||||
|     // Response may be an immediate "OK" followed later by "+NETOPEN: 1". |  | ||||||
|  |     // This activates and attaches to the external PDP context that is tied | ||||||
|  |     // to the embedded context for TCP/IP (ie AT+CGACT=1,1 and AT+CGATT=1) | ||||||
|  |     // Response may be an immediate "OK" followed later by "+NETOPEN: 0". | ||||||
|     // We to ignore any immediate response and wait for the |     // We to ignore any immediate response and wait for the | ||||||
|     // URC to show it's really connected. |     // URC to show it's really connected. | ||||||
|     sendAT(GF("+NETOPEN")); |     sendAT(GF("+NETOPEN")); | ||||||
| @@ -415,12 +405,14 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK() | |||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     sendAT(GF("+CGACT=1,0"));  // Deactivate PDP context 1 |     // Deactivate PDP context 1 | ||||||
|  |     sendAT(GF("+CGACT=1,0")); | ||||||
|     if (waitResponse(40000L) != 1) { |     if (waitResponse(40000L) != 1) { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     sendAT(GF("+CGATT=0"));  // detach from GPRS |     // Detach from GPRS | ||||||
|  |     sendAT(GF("+CGATT=0")); | ||||||
|     if (waitResponse(360000L) != 1) { |     if (waitResponse(360000L) != 1) { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
| @@ -438,8 +430,9 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK() | |||||||
|  |  | ||||||
|     sendAT(GF("+IPADDR")); // Inquire Socket PDP address |     sendAT(GF("+IPADDR")); // Inquire Socket PDP address | ||||||
|     // sendAT(GF("+CGPADDR=1")); // Show PDP address |     // sendAT(GF("+CGPADDR=1")); // Show PDP address | ||||||
|     if (waitResponse() != 1) |     if (waitResponse() != 1) { | ||||||
|       return false; |       return false; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
| @@ -624,6 +617,10 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK() | |||||||
|   } |   } | ||||||
|  |  | ||||||
|   float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE; |   float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE; | ||||||
|  |     // ToDo: | ||||||
|  |     // # Enable Temparature Reading: | ||||||
|  |     //AT+CMTE=1 | ||||||
|  |     //AT+CMTE? | ||||||
|  |  | ||||||
|   /* |   /* | ||||||
|    * Client related functions |    * Client related functions | ||||||
| @@ -639,9 +636,9 @@ protected: | |||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Establish connection in multi-socket mode |         // Establish a connection in multi-socket mode | ||||||
|     sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); |     sendAT(GF("+CIPOPEN="), mux, ',', GF("\"TCP"), GF("\",\""), host, GF("\","), port); | ||||||
|     // reply is +CIPOPEN: ## of socket created |         // The reply is +CIPOPEN: ## of socket created | ||||||
|     if (waitResponse(15000L, GF(GSM_NL "+CIPOPEN:")) != 1) { |     if (waitResponse(15000L, GF(GSM_NL "+CIPOPEN:")) != 1) { | ||||||
|       return false; |       return false; | ||||||
|     } |     } | ||||||
| @@ -696,6 +693,7 @@ protected: | |||||||
| #endif | #endif | ||||||
|       sockets[mux]->rx.put(c); |       sockets[mux]->rx.put(c); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     DBG("### READ:", len_requested, "from", mux); |     DBG("### READ:", len_requested, "from", mux); | ||||||
|     // sockets[mux]->sock_available = modemGetAvailable(mux); |     // sockets[mux]->sock_available = modemGetAvailable(mux); | ||||||
|     sockets[mux]->sock_available = len_confirmed; |     sockets[mux]->sock_available = len_confirmed; | ||||||
| @@ -722,7 +720,7 @@ protected: | |||||||
|   bool modemGetConnected(uint8_t mux) { |   bool modemGetConnected(uint8_t mux) { | ||||||
|     // Read the status of all sockets at once |     // Read the status of all sockets at once | ||||||
|     sendAT(GF("+CIPCLOSE?"), mux); |     sendAT(GF("+CIPCLOSE?"), mux); | ||||||
|     if (waitResponse(GFP(GSM_OK), GF(GSM_NL "+CIPCLOSE: ")) != 2) |     if (waitResponse(GFP(GSM_OK), GF("+CIPCLOSE: ")) != 2) | ||||||
|       return false; |       return false; | ||||||
|     for (int muxNo = 0; muxNo <= TINY_GSM_MUX_COUNT; muxNo++) { |     for (int muxNo = 0; muxNo <= TINY_GSM_MUX_COUNT; muxNo++) { | ||||||
|       // +CIPCLOSE:<link0_state>,<link1_state>,...,<link9_state> |       // +CIPCLOSE:<link0_state>,<link1_state>,...,<link9_state> | ||||||
| @@ -805,6 +803,14 @@ TINY_GSM_MODEM_STREAM_UTILITIES() | |||||||
|           } |           } | ||||||
|           data = ""; |           data = ""; | ||||||
|           DBG("### Closed: ", mux); |           DBG("### Closed: ", mux); | ||||||
|  |         } else if (data.endsWith(GF("+CIPEVENT:"))) { | ||||||
|  |           // Need to close all open sockets and release the network library. | ||||||
|  |           // User will then need to reconnect. | ||||||
|  |           DBG("### Network error!"); | ||||||
|  |           if (!isGprsConnected()) { | ||||||
|  |             gprsDisconnect(); | ||||||
|  |           } | ||||||
|  |           data = ""; | ||||||
|         } |         } | ||||||
|       } |       } | ||||||
|     } while (millis() - startMillis < timeout_ms); |     } while (millis() - startMillis < timeout_ms); | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ | |||||||
| #define TinyGsmCommon_h | #define TinyGsmCommon_h | ||||||
|  |  | ||||||
| // The current library version number | // The current library version number | ||||||
| #define TINYGSM_VERSION "0.9.5" | #define TINYGSM_VERSION "0.9.6" | ||||||
|  |  | ||||||
| #if defined(SPARK) || defined(PARTICLE) | #if defined(SPARK) || defined(PARTICLE) | ||||||
|   #include "Particle.h" |   #include "Particle.h" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user