mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
Merge pull request #2546 from zorzano/ide-1.5.x.GSM.1
Minor modifications aligning internal and Arduino versions
This commit is contained in:
commit
5e33ca4cd4
@ -47,6 +47,7 @@ https://github.com/BlueVia/Official-Arduino
|
||||
#include <GSM3ShieldV1ClientProvider.h>
|
||||
#include <GSM3ShieldV1DataNetworkProvider.h>
|
||||
#include <GSM3ShieldV1ModemVerification.h>
|
||||
#include <GSM3ShieldV1CellManagement.h>
|
||||
#include <GSM3ShieldV1PinManagement.h>
|
||||
#include <GSM3ShieldV1ScanNetworks.h>
|
||||
#include <GSM3SMSService.h>
|
||||
@ -61,7 +62,7 @@ https://github.com/BlueVia/Official-Arduino
|
||||
|
||||
#define GSMPIN GSM3ShieldV1PinManagement
|
||||
#define GSMModem GSM3ShieldV1ModemVerification
|
||||
#define GSMCell GSM3CellManagement
|
||||
#define GSMCell GSM3ShieldV1CellManagement
|
||||
#define GSMBand GSM3ShieldV1BandManagement
|
||||
#define GSMScanner GSM3ShieldV1ScanNetworks
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
26
libraries/GSM/src/GSM3IO.h
Normal file
26
libraries/GSM/src/GSM3IO.h
Normal file
@ -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
|
@ -34,7 +34,7 @@ https://github.com/BlueVia/Official-Arduino
|
||||
#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
|
||||
{
|
||||
@ -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
|
||||
*/
|
||||
|
@ -35,6 +35,7 @@ https://github.com/BlueVia/Official-Arduino
|
||||
#include <GSM3MobileMockupProvider.h>
|
||||
#include <inttypes.h>
|
||||
#include <HardwareSerial.h>
|
||||
#include <Arduino.h>
|
||||
|
||||
|
||||
GSM3MobileMockupProvider::GSM3MobileMockupProvider()
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
@ -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();
|
||||
@ -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);
|
||||
@ -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;
|
||||
}
|
@ -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
|
||||
*/
|
||||
|
@ -219,6 +219,8 @@ void GSM3ShieldV1DataNetworkProvider::detachGPRSContinue()
|
||||
}
|
||||
else theGSM3ShieldV1ModemCore.closeCommand(3);
|
||||
}
|
||||
theGSM3ShieldV1ModemCore.theBuffer().flush();
|
||||
theGSM3ShieldV1ModemCore.gss.spaceAvailable();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -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).
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -61,4 +61,4 @@ class GSM3ShieldV1ModemVerification
|
||||
|
||||
};
|
||||
|
||||
#endif;
|
||||
#endif
|
@ -100,4 +100,4 @@ class GSM3ShieldV1PinManagement
|
||||
void setPINUsed(bool used);
|
||||
};
|
||||
|
||||
#endif;
|
||||
#endif
|
@ -52,6 +52,7 @@ int GSM3ShieldV1SMSProvider::endSMS()
|
||||
{
|
||||
theGSM3ShieldV1ModemCore.openCommand(this,ENDSMS);
|
||||
endSMSContinue();
|
||||
while(ready()==0) delay(100);
|
||||
return theGSM3ShieldV1ModemCore.getCommandError();
|
||||
}
|
||||
|
||||
|
@ -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]=='"')
|
||||
{
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user