Skip to content

GSM Library: minor modifications and bug fix #2546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libraries/GSM/src/GSM.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ The latest version of this library can always be found at
#include <GSM3ShieldV1ClientProvider.h>
#include <GSM3ShieldV1DataNetworkProvider.h>
#include <GSM3ShieldV1ModemVerification.h>
#include <GSM3ShieldV1CellManagement.h>
#include <GSM3ShieldV1PinManagement.h>
#include <GSM3ShieldV1ScanNetworks.h>
#include <GSM3SMSService.h>
Expand All @@ -61,7 +62,7 @@ The latest version of this library can always be found at

#define GSMPIN GSM3ShieldV1PinManagement
#define GSMModem GSM3ShieldV1ModemVerification
#define GSMCell GSM3CellManagement
#define GSMCell GSM3ShieldV1CellManagement
#define GSMBand GSM3ShieldV1BandManagement
#define GSMScanner GSM3ShieldV1ScanNetworks

Expand Down
4 changes: 2 additions & 2 deletions libraries/GSM/src/GSM3CircularBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
The latest version of this library can always be found at
https://github.com/BlueVia/Official-Arduino
*/
#include "GSM3CircularBuffer.h"
#include <HardwareSerial.h>
#include <GSM3CircularBuffer.h>
#include <Arduino.h>

GSM3CircularBuffer::GSM3CircularBuffer(GSM3CircularBufferManager* mgr)
{
Expand Down
26 changes: 26 additions & 0 deletions libraries/GSM/src/GSM3IO.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifdef TTOPEN_V1
#define __POWERPIN__ 5
#define __RESETPIN__ 6
#else
#define __RESETPIN__ 7
#endif

#if defined(__AVR_ATmega328P__)
#ifdef TTOPEN_V1
#define __TXPIN__ 3
#define __RXPIN__ 4
#define __RXINT__ 3
#else
#define __TXPIN__ 3
#define __RXPIN__ 2
#define __RXINT__ 3
#endif
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
#define __TXPIN__ 3
#define __RXPIN__ 10
#define __RXINT__ 4
#elif defined(__AVR_ATmega32U4__)
#define __TXPIN__ 3
#define __RXPIN__ 8
#define __RXINT__ 3
#endif
7 changes: 6 additions & 1 deletion libraries/GSM/src/GSM3MobileAccessProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ The latest version of this library can always be found at
#ifndef _GSM3MOBILEACCESSPROVIDER_
#define _GSM3MOBILEACCESSPROVIDER_

enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED};
enum GSM3_NetworkStatus_t { ERROR, IDLE, CONNECTING, GSM_READY, GPRS_READY, TRANSPARENT_CONNECTED, OFF};

class GSM3MobileAccessProvider
{
Expand All @@ -59,6 +59,11 @@ class GSM3MobileAccessProvider
*/
virtual inline bool shutdown()=0;

/** Secure shutdown the modem (power off really)
@return always true
*/
virtual inline bool secureShutdown()=0;

/** Get last command status
@return returns 0 if last command is still executing, 1 success, >1 error
*/
Expand Down
1 change: 1 addition & 0 deletions libraries/GSM/src/GSM3MobileMockupProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ The latest version of this library can always be found at
#include <GSM3MobileMockupProvider.h>
#include <inttypes.h>
#include <HardwareSerial.h>
#include <Arduino.h>


GSM3MobileMockupProvider::GSM3MobileMockupProvider()
Expand Down
1 change: 0 additions & 1 deletion libraries/GSM/src/GSM3MobileNetworkProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ The latest version of this library can always be found at
https://github.com/BlueVia/Official-Arduino
*/
#include <GSM3MobileNetworkProvider.h>
#include <HardwareSerial.h>

GSM3MobileNetworkProvider* theProvider;

Expand Down
33 changes: 30 additions & 3 deletions libraries/GSM/src/GSM3ShieldV1AccessProvider.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <GSM3ShieldV1AccessProvider.h>
#include <Arduino.h>
#include "GSM3IO.h"

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

#ifdef TTOPEN_V1
pinMode(__POWERPIN__, OUTPUT);
digitalWrite(__POWERPIN__, HIGH);
#endif

// If asked for modem restart, restart
if (restart)
HWrestart();
Expand All @@ -60,7 +65,11 @@ GSM3_NetworkStatus_t GSM3ShieldV1AccessProvider::begin(char* pin, bool restart,
//HWrestart.
int GSM3ShieldV1AccessProvider::HWrestart()
{

#ifdef TTOPEN_V1
digitalWrite(__POWERPIN__, HIGH);
delay(1000);
#endif

theGSM3ShieldV1ModemCore.setStatus(IDLE);
digitalWrite(__RESETPIN__, HIGH);
delay(12000);
Expand Down Expand Up @@ -292,5 +301,23 @@ bool GSM3ShieldV1AccessProvider::shutdown()
return resp;
}
return false;
}
}

//Secure shutdown.
bool GSM3ShieldV1AccessProvider::secureShutdown()
{
// It makes no sense to have an asynchronous shutdown
pinMode(__RESETPIN__, OUTPUT);
digitalWrite(__RESETPIN__, HIGH);
delay(900);
digitalWrite(__RESETPIN__, LOW);
theGSM3ShieldV1ModemCore.setStatus(OFF);
theGSM3ShieldV1ModemCore.gss.close();

#ifdef TTOPEN_V1
_delay_ms(12000);
digitalWrite(__POWERPIN__, LOW);
#endif

return true;
}
5 changes: 5 additions & 0 deletions libraries/GSM/src/GSM3ShieldV1AccessProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ class GSM3ShieldV1AccessProvider : public GSM3MobileAccessProvider, public GSM3S
*/
bool shutdown();

/** Secure shutdown the modem (power off really)
@return true if successful
*/
bool secureShutdown();

/** Returns 0 if last command is still executing
@return 1 if success, >1 if error
*/
Expand Down
2 changes: 2 additions & 0 deletions libraries/GSM/src/GSM3ShieldV1DataNetworkProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,8 @@ void GSM3ShieldV1DataNetworkProvider::detachGPRSContinue()
}
else theGSM3ShieldV1ModemCore.closeCommand(3);
}
theGSM3ShieldV1ModemCore.theBuffer().flush();
theGSM3ShieldV1ModemCore.gss.spaceAvailable();
break;
}
}
Expand Down
2 changes: 1 addition & 1 deletion libraries/GSM/src/GSM3ShieldV1ModemCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void GSM3ShieldV1ModemCore::closeCommand(int code)
void GSM3ShieldV1ModemCore::genericCommand_rq(PGM_P str, bool addCR)
{
theBuffer().flush();
writePGM(str, addCR);
writePGM(str, addCR);
}

//Generic command (const string).
Expand Down
12 changes: 3 additions & 9 deletions libraries/GSM/src/GSM3ShieldV1ModemVerification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,13 @@ int GSM3ShieldV1ModemVerification::begin()
// get IMEI
String GSM3ShieldV1ModemVerification::getIMEI()
{
String number;
String number(NULL);
// AT command for obtain IMEI
String modemResponse = modemAccess.writeModemCommand("AT+GSN", 2000);
// Parse and check response
char res_to_compare[modemResponse.length()];
modemResponse.toCharArray(res_to_compare, modemResponse.length());
if(strstr(res_to_compare,"OK") == NULL)
{
return String(NULL);
}
else
{
if(strstr(res_to_compare,"OK") != NULL)
number = modemResponse.substring(1, 17);
return number;
}
return number;
}
2 changes: 1 addition & 1 deletion libraries/GSM/src/GSM3ShieldV1ModemVerification.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ class GSM3ShieldV1ModemVerification

};

#endif;
#endif
2 changes: 1 addition & 1 deletion libraries/GSM/src/GSM3ShieldV1PinManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,4 @@ class GSM3ShieldV1PinManagement
void setPINUsed(bool used);
};

#endif;
#endif
1 change: 1 addition & 0 deletions libraries/GSM/src/GSM3ShieldV1SMSProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ int GSM3ShieldV1SMSProvider::endSMS()
{
theGSM3ShieldV1ModemCore.openCommand(this,ENDSMS);
endSMSContinue();
while(ready()==0) delay(100);
return theGSM3ShieldV1ModemCore.getCommandError();
}

Expand Down
2 changes: 1 addition & 1 deletion libraries/GSM/src/GSM3ShieldV1ScanNetworks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ String GSM3ShieldV1ScanNetworks::readNetworks()
String result;
bool inQuotes=false;
int quoteCounter=0;
for(int i=0; i<modemResponse.length();i++)
for(unsigned int i=0; i<modemResponse.length();i++)
{
if(modemResponse[i]=='"')
{
Expand Down
15 changes: 1 addition & 14 deletions libraries/GSM/src/GSM3SoftSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,26 +32,13 @@ The latest version of this library can always be found at
https://github.com/BlueVia/Official-Arduino
*/
#include "GSM3SoftSerial.h"
#include "GSM3IO.h"
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#include "pins_arduino.h"
#include <HardwareSerial.h>
#include <Arduino.h>

#if defined(__AVR_ATmega328P__)
#define __TXPIN__ 3
#define __RXPIN__ 2
#define __RXINT__ 3
#elif defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1280__)
#define __TXPIN__ 3
#define __RXPIN__ 10
#define __RXINT__ 4
#elif defined(__AVR_ATmega32U4__)
#define __TXPIN__ 3
#define __RXPIN__ 8
#define __RXINT__ 3
#endif

#define __XON__ 0x11
#define __XOFF__ 0x13

Expand Down