Skip to content

Commit 5e33ca4

Browse files
committed
Merge pull request #2546 from zorzano/ide-1.5.x.GSM.1
Minor modifications aligning internal and Arduino versions
2 parents e4c8f98 + 2b14a93 commit 5e33ca4

16 files changed

+83
-35
lines changed

libraries/GSM/src/GSM.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ The latest version of this library can always be found at
4747
#include <GSM3ShieldV1ClientProvider.h>
4848
#include <GSM3ShieldV1DataNetworkProvider.h>
4949
#include <GSM3ShieldV1ModemVerification.h>
50+
#include <GSM3ShieldV1CellManagement.h>
5051
#include <GSM3ShieldV1PinManagement.h>
5152
#include <GSM3ShieldV1ScanNetworks.h>
5253
#include <GSM3SMSService.h>
@@ -61,7 +62,7 @@ The latest version of this library can always be found at
6162

6263
#define GSMPIN GSM3ShieldV1PinManagement
6364
#define GSMModem GSM3ShieldV1ModemVerification
64-
#define GSMCell GSM3CellManagement
65+
#define GSMCell GSM3ShieldV1CellManagement
6566
#define GSMBand GSM3ShieldV1BandManagement
6667
#define GSMScanner GSM3ShieldV1ScanNetworks
6768

libraries/GSM/src/GSM3CircularBuffer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
3131
The latest version of this library can always be found at
3232
https://github.com/BlueVia/Official-Arduino
3333
*/
34-
#include "GSM3CircularBuffer.h"
35-
#include <HardwareSerial.h>
34+
#include <GSM3CircularBuffer.h>
35+
#include <Arduino.h>
3636

3737
GSM3CircularBuffer::GSM3CircularBuffer(GSM3CircularBufferManager* mgr)
3838
{

libraries/GSM/src/GSM3IO.h

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#ifdef TTOPEN_V1
2+
#define __POWERPIN__ 5
3+
#define __RESETPIN__ 6
4+
#else
5+
#define __RESETPIN__ 7
6+
#endif
7+
8+
#if defined(__AVR_ATmega328P__)
9+
#ifdef TTOPEN_V1
10+
#define __TXPIN__ 3
11+
#define __RXPIN__ 4
12+
#define __RXINT__ 3
13+
#else
14+
#define __TXPIN__ 3
15+
#define __RXPIN__ 2
16+
#define __RXINT__ 3
17+
#endif
18+
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
19+
#define __TXPIN__ 3
20+
#define __RXPIN__ 10
21+
#define __RXINT__ 4
22+
#elif defined(__AVR_ATmega32U4__)
23+
#define __TXPIN__ 3
24+
#define __RXPIN__ 8
25+
#define __RXINT__ 3
26+
#endif

libraries/GSM/src/GSM3MobileAccessProvider.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The latest version of this library can always be found at
3434
#ifndef _GSM3MOBILEACCESSPROVIDER_
3535
#define _GSM3MOBILEACCESSPROVIDER_
3636

37-
enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED};
37+
enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED, OFF};
3838

3939
class GSM3MobileAccessProvider
4040
{
@@ -59,6 +59,11 @@ class GSM3MobileAccessProvider
5959
*/
6060
virtual inline bool shutdown()=0;
6161

62+
/** Secure shutdown the modem (power off really)
63+
@return always true
64+
*/
65+
virtual inline bool secureShutdown()=0;
66+
6267
/** Get last command status
6368
@return returns 0 if last command is still executing, 1 success, >1 error
6469
*/

libraries/GSM/src/GSM3MobileMockupProvider.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ The latest version of this library can always be found at
3535
#include <GSM3MobileMockupProvider.h>
3636
#include <inttypes.h>
3737
#include <HardwareSerial.h>
38+
#include <Arduino.h>
3839

3940

4041
GSM3MobileMockupProvider::GSM3MobileMockupProvider()

libraries/GSM/src/GSM3MobileNetworkProvider.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ The latest version of this library can always be found at
3232
https://github.com/BlueVia/Official-Arduino
3333
*/
3434
#include <GSM3MobileNetworkProvider.h>
35-
#include <HardwareSerial.h>
3635

3736
GSM3MobileNetworkProvider* theProvider;
3837

libraries/GSM/src/GSM3ShieldV1AccessProvider.cpp

+30-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include <GSM3ShieldV1AccessProvider.h>
22
#include <Arduino.h>
3+
#include "GSM3IO.h"
34

4-
#define __RESETPIN__ 7
55
#define __TOUTSHUTDOWN__ 5000
66
#define __TOUTMODEMCONFIGURATION__ 5000//equivalent to 30000 because of time in interrupt routine.
77
#define __TOUTAT__ 1000
@@ -38,6 +38,11 @@ GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart,
3838
{
3939
pinMode(__RESETPIN__, OUTPUT);
4040

41+
#ifdef TTOPEN_V1
42+
pinMode(__POWERPIN__, OUTPUT);
43+
digitalWrite(__POWERPIN__, HIGH);
44+
#endif
45+
4146
// If asked for modem restart, restart
4247
if (restart)
4348
HWrestart();
@@ -60,7 +65,11 @@ GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart,
6065
//HWrestart.
6166
int GSM3ShieldV1AccessProvider::HWrestart()
6267
{
63-
68+
#ifdef TTOPEN_V1
69+
digitalWrite(__POWERPIN__, HIGH);
70+
delay(1000);
71+
#endif
72+
6473
theGSM3ShieldV1ModemCore.setStatus(IDLE);
6574
digitalWrite(__RESETPIN__, HIGH);
6675
delay(12000);
@@ -292,5 +301,23 @@ bool GSM3ShieldV1AccessProvider::shutdown()
292301
return resp;
293302
}
294303
return false;
295-
}
304+
}
296305

306+
//Secure shutdown.
307+
bool GSM3ShieldV1AccessProvider::secureShutdown()
308+
{
309+
// It makes no sense to have an asynchronous shutdown
310+
pinMode(__RESETPIN__, OUTPUT);
311+
digitalWrite(__RESETPIN__, HIGH);
312+
delay(900);
313+
digitalWrite(__RESETPIN__, LOW);
314+
theGSM3ShieldV1ModemCore.setStatus(OFF);
315+
theGSM3ShieldV1ModemCore.gss.close();
316+
317+
#ifdef TTOPEN_V1
318+
_delay_ms(12000);
319+
digitalWrite(__POWERPIN__, LOW);
320+
#endif
321+
322+
return true;
323+
}

libraries/GSM/src/GSM3ShieldV1AccessProvider.h

+5
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ class GSM3ShieldV1AccessProvider : public GSM3MobileAccessProvider, public GSM3S
8989
*/
9090
bool shutdown();
9191

92+
/** Secure shutdown the modem (power off really)
93+
@return true if successful
94+
*/
95+
bool secureShutdown();
96+
9297
/** Returns 0 if last command is still executing
9398
@return 1 if success, >1 if error
9499
*/

libraries/GSM/src/GSM3ShieldV1DataNetworkProvider.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ void GSM3ShieldV1DataNetworkProvider::detachGPRSContinue()
219219
}
220220
else theGSM3ShieldV1ModemCore.closeCommand(3);
221221
}
222+
theGSM3ShieldV1ModemCore.theBuffer().flush();
223+
theGSM3ShieldV1ModemCore.gss.spaceAvailable();
222224
break;
223225
}
224226
}

libraries/GSM/src/GSM3ShieldV1ModemCore.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ void GSM3ShieldV1ModemCore::closeCommand(int code)
7878
void GSM3ShieldV1ModemCore::genericCommand_rq(PGM_P str, bool addCR)
7979
{
8080
theBuffer().flush();
81-
writePGM(str, addCR);
81+
writePGM(str, addCR);
8282
}
8383

8484
//Generic command (const string).

libraries/GSM/src/GSM3ShieldV1ModemVerification.cpp

+3-9
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,13 @@ int GSM3ShieldV1ModemVerification::begin()
6161
// get IMEI
6262
String GSM3ShieldV1ModemVerification::getIMEI()
6363
{
64-
String number;
64+
String number(NULL);
6565
// AT command for obtain IMEI
6666
String modemResponse = modemAccess.writeModemCommand("AT+GSN", 2000);
6767
// Parse and check response
6868
char res_to_compare[modemResponse.length()];
6969
modemResponse.toCharArray(res_to_compare, modemResponse.length());
70-
if(strstr(res_to_compare,"OK") == NULL)
71-
{
72-
return String(NULL);
73-
}
74-
else
75-
{
70+
if(strstr(res_to_compare,"OK") != NULL)
7671
number = modemResponse.substring(1, 17);
77-
return number;
78-
}
72+
return number;
7973
}

libraries/GSM/src/GSM3ShieldV1ModemVerification.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,4 @@ class GSM3ShieldV1ModemVerification
6161

6262
};
6363

64-
#endif;
64+
#endif

libraries/GSM/src/GSM3ShieldV1PinManagement.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,4 @@ class GSM3ShieldV1PinManagement
100100
void setPINUsed(bool used);
101101
};
102102

103-
#endif;
103+
#endif

libraries/GSM/src/GSM3ShieldV1SMSProvider.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ int GSM3ShieldV1SMSProvider::endSMS()
5252
{
5353
theGSM3ShieldV1ModemCore.openCommand(this,ENDSMS);
5454
endSMSContinue();
55+
while(ready()==0) delay(100);
5556
return theGSM3ShieldV1ModemCore.getCommandError();
5657
}
5758

libraries/GSM/src/GSM3ShieldV1ScanNetworks.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ String GSM3ShieldV1ScanNetworks::readNetworks()
9292
String result;
9393
bool inQuotes=false;
9494
int quoteCounter=0;
95-
for(int i=0; i<modemResponse.length();i++)
95+
for(unsigned int i=0; i<modemResponse.length();i++)
9696
{
9797
if(modemResponse[i]=='"')
9898
{

libraries/GSM/src/GSM3SoftSerial.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,13 @@ The latest version of this library can always be found at
3232
https://github.com/BlueVia/Official-Arduino
3333
*/
3434
#include "GSM3SoftSerial.h"
35+
#include "GSM3IO.h"
3536
#include <avr/interrupt.h>
3637
#include <avr/pgmspace.h>
3738
#include "pins_arduino.h"
3839
#include <HardwareSerial.h>
3940
#include <Arduino.h>
4041

41-
#if defined(__AVR_ATmega328P__)
42-
#define __TXPIN__ 3
43-
#define __RXPIN__ 2
44-
#define __RXINT__ 3
45-
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
46-
#define __TXPIN__ 3
47-
#define __RXPIN__ 10
48-
#define __RXINT__ 4
49-
#elif defined(__AVR_ATmega32U4__)
50-
#define __TXPIN__ 3
51-
#define __RXPIN__ 8
52-
#define __RXINT__ 3
53-
#endif
54-
5542
#define __XON__ 0x11
5643
#define __XOFF__ 0x13
5744

0 commit comments

Comments
 (0)