Skip to content

Commit afc368b

Browse files
committed
GSM: Backported library from IDE 1.5.x
Fixes #2343
1 parent d63350b commit afc368b

23 files changed

+330
-331
lines changed

build/shared/revisions.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
ARDUINO 1.0.7
3+
4+
[libraries]
5+
* Backported GSM from IDE 1.5.x
6+
27
ARDUINO 1.0.6 - 2014.09.16
38

49
[core]

libraries/GSM/GSM3ShieldV1AccessProvider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#define __TOUTMODEMCONFIGURATION__ 5000//equivalent to 30000 because of time in interrupt routine.
77
#define __TOUTAT__ 1000
88

9-
char _command_AT[] PROGMEM = "AT";
10-
char _command_CGREG[] PROGMEM = "AT+CGREG?";
9+
const char _command_AT[] PROGMEM = "AT";
10+
const char _command_CGREG[] PROGMEM = "AT+CGREG?";
1111

1212

1313
GSM3ShieldV1AccessProvider::GSM3ShieldV1AccessProvider(bool debug)

libraries/GSM/GSM3ShieldV1BaseProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ int GSM3ShieldV1BaseProvider::ready()
1212
return theGSM3ShieldV1ModemCore.getCommandError();
1313
};
1414

15-
void GSM3ShieldV1BaseProvider::prepareAuxLocate(PROGMEM prog_char str[], char auxLocate[])
15+
void GSM3ShieldV1BaseProvider::prepareAuxLocate(PGM_P str, char auxLocate[])
1616
{
1717
int i=0;
1818
char c;

libraries/GSM/GSM3ShieldV1BaseProvider.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class GSM3ShieldV1BaseProvider
5454
@param str PROGMEN
5555
@param auxLocate Buffer where to locate strings
5656
*/
57-
void prepareAuxLocate(PROGMEM prog_char str[], char auxLocate[]);
57+
void prepareAuxLocate(PGM_P str, char auxLocate[]);
5858

5959
/** Manages modem response
6060
@param from Initial byte of buffer
@@ -70,4 +70,4 @@ class GSM3ShieldV1BaseProvider
7070

7171
};
7272

73-
#endif
73+
#endif

libraries/GSM/GSM3ShieldV1DataNetworkProvider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#include <GSM3ShieldV1DataNetworkProvider.h>
22
#include <Arduino.h>
33

4-
char _command_CGATT[] PROGMEM = "AT+CGATT=";
5-
char _command_SEPARATOR[] PROGMEM = "\",\"";
4+
const char _command_CGATT[] PROGMEM = "AT+CGATT=";
5+
const char _command_SEPARATOR[] PROGMEM = "\",\"";
66

77
//Attach GPRS main function.
88
GSM3_NetworkStatus_t GSM3ShieldV1DataNetworkProvider::attachGPRS(char* apn, char* user_name, char* password, bool synchronous)

libraries/GSM/GSM3ShieldV1ModemCore.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void GSM3ShieldV1ModemCore::closeCommand(int code)
7575
}
7676

7777
//Generic command (stored in flash).
78-
void GSM3ShieldV1ModemCore::genericCommand_rq(PROGMEM prog_char str[], bool addCR)
78+
void GSM3ShieldV1ModemCore::genericCommand_rq(PGM_P str, bool addCR)
7979
{
8080
theBuffer().flush();
8181
writePGM(str, addCR);
@@ -157,7 +157,7 @@ void GSM3ShieldV1ModemCore::openCommand(GSM3ShieldV1BaseProvider* provider, GSM3
157157

158158
};
159159

160-
size_t GSM3ShieldV1ModemCore::writePGM(PROGMEM prog_char str[], bool CR)
160+
size_t GSM3ShieldV1ModemCore::writePGM(PGM_P str, bool CR)
161161
{
162162
int i=0;
163163
char c;

libraries/GSM/GSM3ShieldV1ModemCore.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
167167
@param CR Carriadge return adding automatically
168168
@return size
169169
*/
170-
virtual size_t writePGM(PROGMEM prog_char str[], bool CR=true);
170+
virtual size_t writePGM(PGM_P str, bool CR=true);
171171

172172
/** Establish debug mode
173173
@param db Boolean that indicates debug on or off
@@ -182,24 +182,18 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
182182
*/
183183
bool genericParse_rsp(bool& rsp, char* string=0, char* string2=0);
184184

185-
/** Generates a generic AT command request from PROGMEM prog_char buffer
185+
/** Generates a generic AT command request from PROGMEM buffer
186186
@param str Buffer with AT command
187187
@param addCR Carriadge return adding automatically
188188
*/
189-
void genericCommand_rq(PROGMEM prog_char str[], bool addCR=true);
189+
void genericCommand_rq(PGM_P str, bool addCR=true);
190190

191191
/** Generates a generic AT command request from a simple char buffer
192192
@param str Buffer with AT command
193193
@param addCR Carriadge return adding automatically
194194
*/
195195
void genericCommand_rqc(const char* str, bool addCR=true);
196196

197-
/** Generates a generic AT command request from characters buffer
198-
@param str Buffer with AT command
199-
@param addCR Carriadge return adding automatically
200-
*/
201-
void genericCommand_rq(const char* str, bool addCR=true);
202-
203197
/** Returns the circular buffer
204198
@return circular buffer
205199
*/
@@ -257,4 +251,4 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
257251

258252
extern GSM3ShieldV1ModemCore theGSM3ShieldV1ModemCore;
259253

260-
#endif
254+
#endif

libraries/GSM/GSM3ShieldV1ModemVerification.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ String GSM3ShieldV1ModemVerification::getIMEI()
6969
modemResponse.toCharArray(res_to_compare, modemResponse.length());
7070
if(strstr(res_to_compare,"OK") == NULL)
7171
{
72-
return NULL;
72+
return String(NULL);
7373
}
7474
else
7575
{

libraries/GSM/GSM3ShieldV1MultiClientProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <GSM3ShieldV1MultiClientProvider.h>
22
#include <GSM3ShieldV1ModemCore.h>
33

4-
char _command_MultiQISRVC[] PROGMEM = "AT+QISRVC=";
4+
const char _command_MultiQISRVC[] PROGMEM = "AT+QISRVC=";
55

66
#define __TOUTFLUSH__ 10000
77

libraries/GSM/GSM3ShieldV1MultiServerProvider.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
#define __NCLIENTS_MAX__ 3
66

7-
char _command_QILOCIP[] PROGMEM = "AT+QILOCIP";
7+
const char _command_QILOCIP[] PROGMEM = "AT+QILOCIP";
88

99
GSM3ShieldV1MultiServerProvider::GSM3ShieldV1MultiServerProvider()
1010
{

libraries/GSM/GSM3ShieldV1ScanNetworks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ String GSM3ShieldV1ScanNetworks::getCurrentCarrier()
6363
String final_result = ptr_token;
6464
return final_result;
6565
}else{
66-
return NULL;
66+
return String(NULL);
6767
}
6868
}
6969

@@ -82,7 +82,7 @@ String GSM3ShieldV1ScanNetworks::getSignalStrength()
8282
final_result.trim();
8383
return final_result;
8484
}else{
85-
return NULL;
85+
return String(NULL);
8686
}
8787
}
8888

libraries/GSM/examples/GsmWebClient/GsmWebClient.ino

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/*
22
Web client
3-
3+
44
This sketch connects to a website through a GSM shield. Specifically,
5-
this example downloads the URL "http://arduino.cc/asciilogo.txt" and
5+
this example downloads the URL "http://arduino.cc/asciilogo.txt" and
66
prints it to the Serial monitor.
7-
7+
88
Circuit:
99
* GSM shield attached to an Arduino
1010
* SIM card with a data plan
11-
11+
1212
created 8 Mar 2012
1313
by Tom Igoe
14-
14+
1515
http://arduino.cc/en/Tutorial/GSMExamplesWebClient
16-
16+
1717
*/
1818

1919
// libraries
@@ -30,7 +30,7 @@
3030
// initialize the library instance
3131
GSMClient client;
3232
GPRS gprs;
33-
GSM gsmAccess;
33+
GSM gsmAccess;
3434

3535
// URL, path & port (for example: arduino.cc)
3636
char server[] = "arduino.cc";
@@ -51,10 +51,10 @@ void setup()
5151

5252
// After starting the modem with GSM.begin()
5353
// attach the shield to the GPRS network with the APN, login and password
54-
while(notConnected)
54+
while (notConnected)
5555
{
56-
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
57-
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
56+
if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
57+
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
5858
notConnected = false;
5959
else
6060
{
@@ -77,7 +77,7 @@ void setup()
7777
client.println(server);
7878
client.println("Connection: close");
7979
client.println();
80-
}
80+
}
8181
else
8282
{
8383
// if you didn't get a connection to the server:
@@ -87,7 +87,7 @@ void setup()
8787

8888
void loop()
8989
{
90-
// if there are incoming bytes available
90+
// if there are incoming bytes available
9191
// from the server, read them and print them:
9292
if (client.available())
9393
{
@@ -103,7 +103,7 @@ void loop()
103103
client.stop();
104104

105105
// do nothing forevermore:
106-
for(;;)
106+
for (;;)
107107
;
108108
}
109109
}

libraries/GSM/examples/GsmWebServer/GsmWebServer.ino

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
/*
22
GSM Web Server
3-
3+
44
A simple web server that shows the value of the analog input pins.
55
using a GSM shield.
66
77
Circuit:
88
* GSM shield attached
99
* Analog inputs attached to pins A0 through A5 (optional)
10-
10+
1111
created 8 Mar 2012
1212
by Tom Igoe
1313
*/
@@ -30,7 +30,7 @@ GSM gsmAccess; // include a 'true' parameter for debug enabled
3030
GSMServer server(80); // port 80 (http default)
3131

3232
// timeout
33-
const unsigned long __TIMEOUT__ = 10*1000;
33+
const unsigned long __TIMEOUT__ = 10 * 1000;
3434

3535
void setup()
3636
{
@@ -39,29 +39,29 @@ void setup()
3939
while (!Serial) {
4040
; // wait for serial port to connect. Needed for Leonardo only
4141
}
42-
42+
4343
// connection state
4444
boolean notConnected = true;
45-
45+
4646
// Start GSM shield
4747
// If your SIM has PIN, pass it as a parameter of begin() in quotes
48-
while(notConnected)
48+
while (notConnected)
4949
{
50-
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
51-
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
50+
if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
51+
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
5252
notConnected = false;
5353
else
5454
{
5555
Serial.println("Not connected");
5656
delay(1000);
5757
}
5858
}
59-
59+
6060
Serial.println("Connected to GPRS network");
61-
61+
6262
// start server
6363
server.begin();
64-
64+
6565
//Get IP.
6666
IPAddress LocalIP = gprs.getIPAddress();
6767
Serial.println("Server IP address=");
@@ -77,21 +77,21 @@ void loop() {
7777

7878

7979
if (client)
80-
{
80+
{
8181
while (client.connected())
8282
{
8383
if (client.available())
8484
{
8585
Serial.println("Receiving request!");
8686
bool sendResponse = false;
87-
while(char c=client.read()) {
87+
while (char c = client.read()) {
8888
if (c == '\n') sendResponse = true;
8989
}
9090

91-
// if you've gotten to the end of the line (received a newline
92-
// character)
93-
if (sendResponse)
94-
{
91+
// if you've gotten to the end of the line (received a newline
92+
// character)
93+
if (sendResponse)
94+
{
9595
// send a standard http response header
9696
client.println("HTTP/1.1 200 OK");
9797
client.println("Content-Type: text/html");
@@ -103,7 +103,7 @@ void loop() {
103103
client.print(analogChannel);
104104
client.print(" is ");
105105
client.print(analogRead(analogChannel));
106-
client.println("<br />");
106+
client.println("<br />");
107107
}
108108
client.println("</html>");
109109
//necessary delay

0 commit comments

Comments
 (0)