Browse Source

Touchup on 5360

v_master
Sara Damiano 5 years ago
parent
commit
93690952d3
5 changed files with 47 additions and 39 deletions
  1. +1
    -1
      library.json
  2. +1
    -1
      library.properties
  3. +3
    -1
      src/TinyGsmClient.h
  4. +41
    -35
      src/TinyGsmClientSIM5360.h
  5. +1
    -1
      src/TinyGsmCommon.h

+ 1
- 1
library.json View File

@ -1,6 +1,6 @@
{
"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.",
"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":


+ 1
- 1
library.properties View File

@ -1,5 +1,5 @@
name=TinyGSM
version=0.9.5
version=0.9.6
author=Volodymyr Shymanskyy
maintainer=Volodymyr Shymanskyy
sentence=A small Arduino library for GPRS modules, that just works.


+ 3
- 1
src/TinyGsmClient.h View File

@ -40,7 +40,9 @@
typedef TinyGsmSim7000::GsmClient TinyGsmClient;
// 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
#include <TinyGsmClientSIM5360.h>
typedef TinyGsmSim5360 TinyGsm;


+ 41
- 35
src/TinyGsmClientSIM5360.h View File

@ -316,49 +316,46 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
// Define the PDP context
// Using CGDCONT sets up an "external" PCP context, i.e. a data connection
// using the external IP stack (e.g. Windows dial up) and PPP link over the
// serial interface. Is this preferred?
// The CGDCONT commands set up the "external" PDP context
// Set the authentication
// Set the external authentication
if (user && strlen(user) > 0) {
sendAT(GF("+CGAUTH=1,0,\""), user, GF("\",\""), pwd, '"');
waitResponse();
}
// Define PDP context 1
sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"');
sendAT(GF("+CGDCONT=1,\"IP\",\""), apn, '"',",\"0.0.0.0\",0,0");
waitResponse();
sendAT(GF("+CGACT=1,1")); // activate PDP profile/context 1
if (waitResponse(75000L) != 1) {
return false;
}
// Using CGSOCKCONT commands defines a PDP context for Embedded TCP/IP application
// CGDCONT commands could be used for an external PDP context
// The CGSOCKCONT commands define the "embedded" PDP context for TCP/IP
// ?? Unsure if this step is needed - redundant with +CGDCONT
// Define the socket PDP context
sendAT(GF("+CGSOCKCONT=1,\"IP\",\""), apn, '"');
waitResponse();
// Set the user name and password
// ?? Unsure if this step is needed - redundant with +CGAUTH
// Set the embedded authentication
if (user && strlen(user) > 0) {
sendAT(GF("+CSOCKAUTH=1,1,\""), user, "\",\"", pwd, '"');
waitResponse();
}
// Set active PDP contexts 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"));
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
sendAT(GF("+CIPSENDMODE=0"));
waitResponse();
// Configure TCP parameters
// Configure socket parameters
//AT+CIPCCFG= [<NmRetry>][,[<DelayTm>][,[<Ack>][,[<errMode>][,]<HeaderType>][,[[<AsyncMode>][,[<TimeoutVal>]]]]]]]]
// 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)
@ -372,23 +369,16 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return false;
}
// Select TCP/IP application mode (command mode)
sendAT(GF("+CIPMODE=0"));
waitResponse();
// Configure timeouts for open and close socket
// Configure timeouts for opening and closing sockets
// AT+CIPTIMEOUT=[<netopen_timeout>][, [<cipopen_timeout>][, [<cipsend_timeout>]]]
sendAT(GF("+CIPTIMEOUT="), 75000, ',', 15000, ',', 15000);
waitResponse();
// attach to GPRS
sendAT(GF("+CGATT=1"));
if (waitResponse(360000L) != 1) {
return false;
}
// 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
// URC to show it's really connected.
sendAT(GF("+NETOPEN"));
@ -415,12 +405,14 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
return false;
}
sendAT(GF("+CGACT=1,0")); // Deactivate PDP context 1
// Deactivate PDP context 1
sendAT(GF("+CGACT=1,0"));
if (waitResponse(40000L) != 1) {
return false;
}
sendAT(GF("+CGATT=0")); // detach from GPRS
// Detach from GPRS
sendAT(GF("+CGATT=0"));
if (waitResponse(360000L) != 1) {
return false;
}
@ -438,8 +430,9 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
sendAT(GF("+IPADDR")); // Inquire Socket PDP address
// sendAT(GF("+CGPADDR=1")); // Show PDP address
if (waitResponse() != 1)
if (waitResponse() != 1) {
return false;
}
return true;
}
@ -624,6 +617,10 @@ TINY_GSM_MODEM_WAIT_FOR_NETWORK()
}
float getTemperature() TINY_GSM_ATTR_NOT_AVAILABLE;
// ToDo:
// # Enable Temparature Reading:
//AT+CMTE=1
//AT+CMTE?
/*
* Client related functions
@ -639,9 +636,9 @@ protected:
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);
// reply is +CIPOPEN: ## of socket created
// The reply is +CIPOPEN: ## of socket created
if (waitResponse(15000L, GF(GSM_NL "+CIPOPEN:")) != 1) {
return false;
}
@ -696,6 +693,7 @@ protected:
#endif
sockets[mux]->rx.put(c);
}
DBG("### READ:", len_requested, "from", mux);
// sockets[mux]->sock_available = modemGetAvailable(mux);
sockets[mux]->sock_available = len_confirmed;
@ -722,7 +720,7 @@ protected:
bool modemGetConnected(uint8_t mux) {
// Read the status of all sockets at once
sendAT(GF("+CIPCLOSE?"), mux);
if (waitResponse(GFP(GSM_OK), GF(GSM_NL "+CIPCLOSE: ")) != 2)
if (waitResponse(GFP(GSM_OK), GF("+CIPCLOSE: ")) != 2)
return false;
for (int muxNo = 0; muxNo <= TINY_GSM_MUX_COUNT; muxNo++) {
// +CIPCLOSE:<link0_state>,<link1_state>,...,<link9_state>
@ -805,6 +803,14 @@ TINY_GSM_MODEM_STREAM_UTILITIES()
}
data = "";
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);


+ 1
- 1
src/TinyGsmCommon.h View File

@ -10,7 +10,7 @@
#define TinyGsmCommon_h
// The current library version number
#define TINYGSM_VERSION "0.9.5"
#define TINYGSM_VERSION "0.9.6"
#if defined(SPARK) || defined(PARTICLE)
#include "Particle.h"


Loading…
Cancel
Save