mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-17 11:54:33 +01:00
parent
d63350b506
commit
afc368b01f
@ -1,4 +1,9 @@
|
|||||||
|
|
||||||
|
ARDUINO 1.0.7
|
||||||
|
|
||||||
|
[libraries]
|
||||||
|
* Backported GSM from IDE 1.5.x
|
||||||
|
|
||||||
ARDUINO 1.0.6 - 2014.09.16
|
ARDUINO 1.0.6 - 2014.09.16
|
||||||
|
|
||||||
[core]
|
[core]
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
#define __TOUTMODEMCONFIGURATION__ 5000//equivalent to 30000 because of time in interrupt routine.
|
#define __TOUTMODEMCONFIGURATION__ 5000//equivalent to 30000 because of time in interrupt routine.
|
||||||
#define __TOUTAT__ 1000
|
#define __TOUTAT__ 1000
|
||||||
|
|
||||||
char _command_AT[] PROGMEM = "AT";
|
const char _command_AT[] PROGMEM = "AT";
|
||||||
char _command_CGREG[] PROGMEM = "AT+CGREG?";
|
const char _command_CGREG[] PROGMEM = "AT+CGREG?";
|
||||||
|
|
||||||
|
|
||||||
GSM3ShieldV1AccessProvider::GSM3ShieldV1AccessProvider(bool debug)
|
GSM3ShieldV1AccessProvider::GSM3ShieldV1AccessProvider(bool debug)
|
||||||
|
@ -12,7 +12,7 @@ int GSM3ShieldV1BaseProvider::ready()
|
|||||||
return theGSM3ShieldV1ModemCore.getCommandError();
|
return theGSM3ShieldV1ModemCore.getCommandError();
|
||||||
};
|
};
|
||||||
|
|
||||||
void GSM3ShieldV1BaseProvider::prepareAuxLocate(PROGMEM prog_char str[], char auxLocate[])
|
void GSM3ShieldV1BaseProvider::prepareAuxLocate(PGM_P str, char auxLocate[])
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -54,7 +54,7 @@ class GSM3ShieldV1BaseProvider
|
|||||||
@param str PROGMEN
|
@param str PROGMEN
|
||||||
@param auxLocate Buffer where to locate strings
|
@param auxLocate Buffer where to locate strings
|
||||||
*/
|
*/
|
||||||
void prepareAuxLocate(PROGMEM prog_char str[], char auxLocate[]);
|
void prepareAuxLocate(PGM_P str, char auxLocate[]);
|
||||||
|
|
||||||
/** Manages modem response
|
/** Manages modem response
|
||||||
@param from Initial byte of buffer
|
@param from Initial byte of buffer
|
||||||
@ -70,4 +70,4 @@ class GSM3ShieldV1BaseProvider
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <GSM3ShieldV1DataNetworkProvider.h>
|
#include <GSM3ShieldV1DataNetworkProvider.h>
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
char _command_CGATT[] PROGMEM = "AT+CGATT=";
|
const char _command_CGATT[] PROGMEM = "AT+CGATT=";
|
||||||
char _command_SEPARATOR[] PROGMEM = "\",\"";
|
const char _command_SEPARATOR[] PROGMEM = "\",\"";
|
||||||
|
|
||||||
//Attach GPRS main function.
|
//Attach GPRS main function.
|
||||||
GSM3_NetworkStatus_t GSM3ShieldV1DataNetworkProvider::attachGPRS(char* apn, char* user_name, char* password, bool synchronous)
|
GSM3_NetworkStatus_t GSM3ShieldV1DataNetworkProvider::attachGPRS(char* apn, char* user_name, char* password, bool synchronous)
|
||||||
|
@ -75,7 +75,7 @@ void GSM3ShieldV1ModemCore::closeCommand(int code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Generic command (stored in flash).
|
//Generic command (stored in flash).
|
||||||
void GSM3ShieldV1ModemCore::genericCommand_rq(PROGMEM prog_char str[], bool addCR)
|
void GSM3ShieldV1ModemCore::genericCommand_rq(PGM_P str, bool addCR)
|
||||||
{
|
{
|
||||||
theBuffer().flush();
|
theBuffer().flush();
|
||||||
writePGM(str, addCR);
|
writePGM(str, addCR);
|
||||||
@ -157,7 +157,7 @@ void GSM3ShieldV1ModemCore::openCommand(GSM3ShieldV1BaseProvider* provider, GSM3
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t GSM3ShieldV1ModemCore::writePGM(PROGMEM prog_char str[], bool CR)
|
size_t GSM3ShieldV1ModemCore::writePGM(PGM_P str, bool CR)
|
||||||
{
|
{
|
||||||
int i=0;
|
int i=0;
|
||||||
char c;
|
char c;
|
||||||
|
@ -167,7 +167,7 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
|
|||||||
@param CR Carriadge return adding automatically
|
@param CR Carriadge return adding automatically
|
||||||
@return size
|
@return size
|
||||||
*/
|
*/
|
||||||
virtual size_t writePGM(PROGMEM prog_char str[], bool CR=true);
|
virtual size_t writePGM(PGM_P str, bool CR=true);
|
||||||
|
|
||||||
/** Establish debug mode
|
/** Establish debug mode
|
||||||
@param db Boolean that indicates debug on or off
|
@param db Boolean that indicates debug on or off
|
||||||
@ -182,11 +182,11 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
|
|||||||
*/
|
*/
|
||||||
bool genericParse_rsp(bool& rsp, char* string=0, char* string2=0);
|
bool genericParse_rsp(bool& rsp, char* string=0, char* string2=0);
|
||||||
|
|
||||||
/** Generates a generic AT command request from PROGMEM prog_char buffer
|
/** Generates a generic AT command request from PROGMEM buffer
|
||||||
@param str Buffer with AT command
|
@param str Buffer with AT command
|
||||||
@param addCR Carriadge return adding automatically
|
@param addCR Carriadge return adding automatically
|
||||||
*/
|
*/
|
||||||
void genericCommand_rq(PROGMEM prog_char str[], bool addCR=true);
|
void genericCommand_rq(PGM_P str, bool addCR=true);
|
||||||
|
|
||||||
/** Generates a generic AT command request from a simple char buffer
|
/** Generates a generic AT command request from a simple char buffer
|
||||||
@param str Buffer with AT command
|
@param str Buffer with AT command
|
||||||
@ -194,12 +194,6 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
|
|||||||
*/
|
*/
|
||||||
void genericCommand_rqc(const char* str, bool addCR=true);
|
void genericCommand_rqc(const char* str, bool addCR=true);
|
||||||
|
|
||||||
/** Generates a generic AT command request from characters buffer
|
|
||||||
@param str Buffer with AT command
|
|
||||||
@param addCR Carriadge return adding automatically
|
|
||||||
*/
|
|
||||||
void genericCommand_rq(const char* str, bool addCR=true);
|
|
||||||
|
|
||||||
/** Returns the circular buffer
|
/** Returns the circular buffer
|
||||||
@return circular buffer
|
@return circular buffer
|
||||||
*/
|
*/
|
||||||
@ -257,4 +251,4 @@ class GSM3ShieldV1ModemCore : public GSM3SoftSerialMgr, public Print
|
|||||||
|
|
||||||
extern GSM3ShieldV1ModemCore theGSM3ShieldV1ModemCore;
|
extern GSM3ShieldV1ModemCore theGSM3ShieldV1ModemCore;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -69,7 +69,7 @@ String GSM3ShieldV1ModemVerification::getIMEI()
|
|||||||
modemResponse.toCharArray(res_to_compare, modemResponse.length());
|
modemResponse.toCharArray(res_to_compare, modemResponse.length());
|
||||||
if(strstr(res_to_compare,"OK") == NULL)
|
if(strstr(res_to_compare,"OK") == NULL)
|
||||||
{
|
{
|
||||||
return NULL;
|
return String(NULL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <GSM3ShieldV1MultiClientProvider.h>
|
#include <GSM3ShieldV1MultiClientProvider.h>
|
||||||
#include <GSM3ShieldV1ModemCore.h>
|
#include <GSM3ShieldV1ModemCore.h>
|
||||||
|
|
||||||
char _command_MultiQISRVC[] PROGMEM = "AT+QISRVC=";
|
const char _command_MultiQISRVC[] PROGMEM = "AT+QISRVC=";
|
||||||
|
|
||||||
#define __TOUTFLUSH__ 10000
|
#define __TOUTFLUSH__ 10000
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#define __NCLIENTS_MAX__ 3
|
#define __NCLIENTS_MAX__ 3
|
||||||
|
|
||||||
char _command_QILOCIP[] PROGMEM = "AT+QILOCIP";
|
const char _command_QILOCIP[] PROGMEM = "AT+QILOCIP";
|
||||||
|
|
||||||
GSM3ShieldV1MultiServerProvider::GSM3ShieldV1MultiServerProvider()
|
GSM3ShieldV1MultiServerProvider::GSM3ShieldV1MultiServerProvider()
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ String GSM3ShieldV1ScanNetworks::getCurrentCarrier()
|
|||||||
String final_result = ptr_token;
|
String final_result = ptr_token;
|
||||||
return final_result;
|
return final_result;
|
||||||
}else{
|
}else{
|
||||||
return NULL;
|
return String(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ String GSM3ShieldV1ScanNetworks::getSignalStrength()
|
|||||||
final_result.trim();
|
final_result.trim();
|
||||||
return final_result;
|
return final_result;
|
||||||
}else{
|
}else{
|
||||||
return NULL;
|
return String(NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
Web client
|
Web client
|
||||||
|
|
||||||
This sketch connects to a website through a GSM shield. Specifically,
|
This sketch connects to a website through a GSM shield. Specifically,
|
||||||
this example downloads the URL "http://arduino.cc/asciilogo.txt" and
|
this example downloads the URL "http://arduino.cc/asciilogo.txt" and
|
||||||
prints it to the Serial monitor.
|
prints it to the Serial monitor.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield attached to an Arduino
|
* GSM shield attached to an Arduino
|
||||||
* SIM card with a data plan
|
* SIM card with a data plan
|
||||||
|
|
||||||
created 8 Mar 2012
|
created 8 Mar 2012
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMExamplesWebClient
|
http://arduino.cc/en/Tutorial/GSMExamplesWebClient
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// libraries
|
// libraries
|
||||||
@ -30,7 +30,7 @@
|
|||||||
// initialize the library instance
|
// initialize the library instance
|
||||||
GSMClient client;
|
GSMClient client;
|
||||||
GPRS gprs;
|
GPRS gprs;
|
||||||
GSM gsmAccess;
|
GSM gsmAccess;
|
||||||
|
|
||||||
// URL, path & port (for example: arduino.cc)
|
// URL, path & port (for example: arduino.cc)
|
||||||
char server[] = "arduino.cc";
|
char server[] = "arduino.cc";
|
||||||
@ -51,10 +51,10 @@ void setup()
|
|||||||
|
|
||||||
// After starting the modem with GSM.begin()
|
// After starting the modem with GSM.begin()
|
||||||
// attach the shield to the GPRS network with the APN, login and password
|
// attach the shield to the GPRS network with the APN, login and password
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
|
if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
|
||||||
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
|
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -77,7 +77,7 @@ void setup()
|
|||||||
client.println(server);
|
client.println(server);
|
||||||
client.println("Connection: close");
|
client.println("Connection: close");
|
||||||
client.println();
|
client.println();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if you didn't get a connection to the server:
|
// if you didn't get a connection to the server:
|
||||||
@ -87,7 +87,7 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// if there are incoming bytes available
|
// if there are incoming bytes available
|
||||||
// from the server, read them and print them:
|
// from the server, read them and print them:
|
||||||
if (client.available())
|
if (client.available())
|
||||||
{
|
{
|
||||||
@ -103,7 +103,7 @@ void loop()
|
|||||||
client.stop();
|
client.stop();
|
||||||
|
|
||||||
// do nothing forevermore:
|
// do nothing forevermore:
|
||||||
for(;;)
|
for (;;)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
/*
|
/*
|
||||||
GSM Web Server
|
GSM Web Server
|
||||||
|
|
||||||
A simple web server that shows the value of the analog input pins.
|
A simple web server that shows the value of the analog input pins.
|
||||||
using a GSM shield.
|
using a GSM shield.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield attached
|
* GSM shield attached
|
||||||
* Analog inputs attached to pins A0 through A5 (optional)
|
* Analog inputs attached to pins A0 through A5 (optional)
|
||||||
|
|
||||||
created 8 Mar 2012
|
created 8 Mar 2012
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
*/
|
*/
|
||||||
@ -30,7 +30,7 @@ GSM gsmAccess; // include a 'true' parameter for debug enabled
|
|||||||
GSMServer server(80); // port 80 (http default)
|
GSMServer server(80); // port 80 (http default)
|
||||||
|
|
||||||
// timeout
|
// timeout
|
||||||
const unsigned long __TIMEOUT__ = 10*1000;
|
const unsigned long __TIMEOUT__ = 10 * 1000;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -39,16 +39,16 @@ void setup()
|
|||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection state
|
// connection state
|
||||||
boolean notConnected = true;
|
boolean notConnected = true;
|
||||||
|
|
||||||
// Start GSM shield
|
// Start GSM shield
|
||||||
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
|
if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
|
||||||
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
|
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -56,12 +56,12 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Connected to GPRS network");
|
Serial.println("Connected to GPRS network");
|
||||||
|
|
||||||
// start server
|
// start server
|
||||||
server.begin();
|
server.begin();
|
||||||
|
|
||||||
//Get IP.
|
//Get IP.
|
||||||
IPAddress LocalIP = gprs.getIPAddress();
|
IPAddress LocalIP = gprs.getIPAddress();
|
||||||
Serial.println("Server IP address=");
|
Serial.println("Server IP address=");
|
||||||
@ -77,21 +77,21 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
if (client)
|
if (client)
|
||||||
{
|
{
|
||||||
while (client.connected())
|
while (client.connected())
|
||||||
{
|
{
|
||||||
if (client.available())
|
if (client.available())
|
||||||
{
|
{
|
||||||
Serial.println("Receiving request!");
|
Serial.println("Receiving request!");
|
||||||
bool sendResponse = false;
|
bool sendResponse = false;
|
||||||
while(char c=client.read()) {
|
while (char c = client.read()) {
|
||||||
if (c == '\n') sendResponse = true;
|
if (c == '\n') sendResponse = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you've gotten to the end of the line (received a newline
|
// if you've gotten to the end of the line (received a newline
|
||||||
// character)
|
// character)
|
||||||
if (sendResponse)
|
if (sendResponse)
|
||||||
{
|
{
|
||||||
// send a standard http response header
|
// send a standard http response header
|
||||||
client.println("HTTP/1.1 200 OK");
|
client.println("HTTP/1.1 200 OK");
|
||||||
client.println("Content-Type: text/html");
|
client.println("Content-Type: text/html");
|
||||||
@ -103,7 +103,7 @@ void loop() {
|
|||||||
client.print(analogChannel);
|
client.print(analogChannel);
|
||||||
client.print(" is ");
|
client.print(" is ");
|
||||||
client.print(analogRead(analogChannel));
|
client.print(analogRead(analogChannel));
|
||||||
client.println("<br />");
|
client.println("<br />");
|
||||||
}
|
}
|
||||||
client.println("</html>");
|
client.println("</html>");
|
||||||
//necessary delay
|
//necessary delay
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
Make Voice Call
|
Make Voice Call
|
||||||
|
|
||||||
This sketch, for the Arduino GSM shield, puts a voice call to
|
This sketch, for the Arduino GSM shield, puts a voice call to
|
||||||
a remote phone number that you enter through the serial monitor.
|
a remote phone number that you enter through the serial monitor.
|
||||||
To make it work, open the serial monitor, and when you see the
|
To make it work, open the serial monitor, and when you see the
|
||||||
READY message, type a phone number. Make sure the serial monitor
|
READY message, type a phone number. Make sure the serial monitor
|
||||||
is set to send a just newline when you press return.
|
is set to send a just newline when you press return.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield
|
* GSM shield
|
||||||
* Voice circuit.
|
* Voice circuit.
|
||||||
With no voice circuit the call will send nor receive any sound
|
With no voice circuit the call will send nor receive any sound
|
||||||
|
|
||||||
|
|
||||||
created Mar 2012
|
created Mar 2012
|
||||||
by Javier Zorzano
|
by Javier Zorzano
|
||||||
|
|
||||||
This example is in the public domain.
|
This example is in the public domain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -42,15 +42,15 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Make Voice Call");
|
Serial.println("Make Voice Call");
|
||||||
|
|
||||||
// connection state
|
// connection state
|
||||||
boolean notConnected = true;
|
boolean notConnected = true;
|
||||||
|
|
||||||
// Start GSM shield
|
// Start GSM shield
|
||||||
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -58,7 +58,7 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("GSM initialized.");
|
Serial.println("GSM initialized.");
|
||||||
Serial.println("Enter phone number to call.");
|
Serial.println("Enter phone number to call.");
|
||||||
|
|
||||||
@ -84,33 +84,33 @@ void loop()
|
|||||||
|
|
||||||
// Call the remote number
|
// Call the remote number
|
||||||
remoteNumber.toCharArray(charbuffer, 20);
|
remoteNumber.toCharArray(charbuffer, 20);
|
||||||
|
|
||||||
|
|
||||||
// Check if the receiving end has picked up the call
|
// Check if the receiving end has picked up the call
|
||||||
if(vcs.voiceCall(charbuffer))
|
if (vcs.voiceCall(charbuffer))
|
||||||
{
|
{
|
||||||
Serial.println("Call Established. Enter line to end");
|
Serial.println("Call Established. Enter line to end");
|
||||||
// Wait for some input from the line
|
// Wait for some input from the line
|
||||||
while(Serial.read()!='\n' && (vcs.getvoiceCallStatus()==TALKING));
|
while (Serial.read() != '\n' && (vcs.getvoiceCallStatus() == TALKING));
|
||||||
// And hang up
|
// And hang up
|
||||||
vcs.hangCall();
|
vcs.hangCall();
|
||||||
}
|
}
|
||||||
Serial.println("Call Finished");
|
Serial.println("Call Finished");
|
||||||
remoteNumber="";
|
remoteNumber = "";
|
||||||
Serial.println("Enter phone number to call.");
|
Serial.println("Enter phone number to call.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("That's too long for a phone number. I'm forgetting it");
|
Serial.println("That's too long for a phone number. I'm forgetting it");
|
||||||
remoteNumber = "";
|
remoteNumber = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// add the latest character to the message to send:
|
// add the latest character to the message to send:
|
||||||
if(inChar!='\r')
|
if (inChar != '\r')
|
||||||
remoteNumber += inChar;
|
remoteNumber += inChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
SMS receiver
|
SMS receiver
|
||||||
|
|
||||||
This sketch, for the Arduino GSM shield, waits for a SMS message
|
This sketch, for the Arduino GSM shield, waits for a SMS message
|
||||||
and displays it through the Serial port.
|
and displays it through the Serial port.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield attached to and Arduino
|
* GSM shield attached to and Arduino
|
||||||
* SIM card that can receive SMS messages
|
* SIM card that can receive SMS messages
|
||||||
|
|
||||||
created 25 Feb 2012
|
created 25 Feb 2012
|
||||||
by Javier Zorzano / TD
|
by Javier Zorzano / TD
|
||||||
|
|
||||||
This example is in the public domain.
|
This example is in the public domain.
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS
|
http://arduino.cc/en/Tutorial/GSMExamplesReceiveSMS
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// include the GSM library
|
// include the GSM library
|
||||||
@ -28,25 +28,25 @@ GSM gsmAccess;
|
|||||||
GSM_SMS sms;
|
GSM_SMS sms;
|
||||||
|
|
||||||
// Array to hold the number a SMS is retreived from
|
// Array to hold the number a SMS is retreived from
|
||||||
char senderNumber[20];
|
char senderNumber[20];
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
// initialize serial communications and wait for port to open:
|
// initialize serial communications and wait for port to open:
|
||||||
Serial.begin(9600);
|
Serial.begin(9600);
|
||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("SMS Messages Receiver");
|
Serial.println("SMS Messages Receiver");
|
||||||
|
|
||||||
// connection state
|
// connection state
|
||||||
boolean notConnected = true;
|
boolean notConnected = true;
|
||||||
|
|
||||||
// Start GSM connection
|
// Start GSM connection
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -54,38 +54,38 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("GSM initialized");
|
Serial.println("GSM initialized");
|
||||||
Serial.println("Waiting for messages");
|
Serial.println("Waiting for messages");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
// If there are any SMSs available()
|
// If there are any SMSs available()
|
||||||
if (sms.available())
|
if (sms.available())
|
||||||
{
|
{
|
||||||
Serial.println("Message received from:");
|
Serial.println("Message received from:");
|
||||||
|
|
||||||
// Get remote number
|
// Get remote number
|
||||||
sms.remoteNumber(senderNumber, 20);
|
sms.remoteNumber(senderNumber, 20);
|
||||||
Serial.println(senderNumber);
|
Serial.println(senderNumber);
|
||||||
|
|
||||||
// An example of message disposal
|
// An example of message disposal
|
||||||
// Any messages starting with # should be discarded
|
// Any messages starting with # should be discarded
|
||||||
if(sms.peek()=='#')
|
if (sms.peek() == '#')
|
||||||
{
|
{
|
||||||
Serial.println("Discarded SMS");
|
Serial.println("Discarded SMS");
|
||||||
sms.flush();
|
sms.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read message bytes and print them
|
// Read message bytes and print them
|
||||||
while(c=sms.read())
|
while (c = sms.read())
|
||||||
Serial.print(c);
|
Serial.print(c);
|
||||||
|
|
||||||
Serial.println("\nEND OF MESSAGE");
|
Serial.println("\nEND OF MESSAGE");
|
||||||
|
|
||||||
// Delete message from modem memory
|
// Delete message from modem memory
|
||||||
sms.flush();
|
sms.flush();
|
||||||
Serial.println("MESSAGE DELETED");
|
Serial.println("MESSAGE DELETED");
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Receive Voice Call
|
Receive Voice Call
|
||||||
|
|
||||||
This sketch, for the Arduino GSM shield, receives voice calls,
|
This sketch, for the Arduino GSM shield, receives voice calls,
|
||||||
displays the calling number, waits a few seconds then hangs up.
|
displays the calling number, waits a few seconds then hangs up.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield
|
* GSM shield
|
||||||
* Voice circuit. Refer to to the GSM shield getting started guide
|
* Voice circuit. Refer to to the GSM shield getting started guide
|
||||||
at http://arduino.cc/en/Guide/ArduinoGSMShield#toc11
|
at http://arduino.cc/en/Guide/ArduinoGSMShield#toc11
|
||||||
* SIM card that can accept voice calls
|
* SIM card that can accept voice calls
|
||||||
|
|
||||||
With no voice circuit the call will connect, but will not send or receive sound
|
With no voice circuit the call will connect, but will not send or receive sound
|
||||||
|
|
||||||
created Mar 2012
|
created Mar 2012
|
||||||
by Javier Zorzano
|
by Javier Zorzano
|
||||||
|
|
||||||
This example is in the public domain.
|
This example is in the public domain.
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMExamplesReceiveVoiceCall
|
http://arduino.cc/en/Tutorial/GSMExamplesReceiveVoiceCall
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Include the GSM library
|
// Include the GSM library
|
||||||
@ -32,7 +32,7 @@ GSM gsmAccess;
|
|||||||
GSMVoiceCall vcs;
|
GSMVoiceCall vcs;
|
||||||
|
|
||||||
// Array to hold the number for the incoming call
|
// Array to hold the number for the incoming call
|
||||||
char numtel[20];
|
char numtel[20];
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -43,15 +43,15 @@ void setup()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Receive Voice Call");
|
Serial.println("Receive Voice Call");
|
||||||
|
|
||||||
// connection state
|
// connection state
|
||||||
boolean notConnected = true;
|
boolean notConnected = true;
|
||||||
|
|
||||||
// Start GSM shield
|
// Start GSM shield
|
||||||
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -59,44 +59,44 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This makes sure the modem correctly reports incoming events
|
// This makes sure the modem correctly reports incoming events
|
||||||
vcs.hangCall();
|
vcs.hangCall();
|
||||||
|
|
||||||
Serial.println("Waiting for a call");
|
Serial.println("Waiting for a call");
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// Check the status of the voice call
|
// Check the status of the voice call
|
||||||
switch (vcs.getvoiceCallStatus())
|
switch (vcs.getvoiceCallStatus())
|
||||||
{
|
{
|
||||||
case IDLE_CALL: // Nothing is happening
|
case IDLE_CALL: // Nothing is happening
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case RECEIVINGCALL: // Yes! Someone is calling us
|
case RECEIVINGCALL: // Yes! Someone is calling us
|
||||||
|
|
||||||
Serial.println("RECEIVING CALL");
|
Serial.println("RECEIVING CALL");
|
||||||
|
|
||||||
// Retrieve the calling number
|
// Retrieve the calling number
|
||||||
vcs.retrieveCallingNumber(numtel, 20);
|
vcs.retrieveCallingNumber(numtel, 20);
|
||||||
|
|
||||||
// Print the calling number
|
// Print the calling number
|
||||||
Serial.print("Number:");
|
Serial.print("Number:");
|
||||||
Serial.println(numtel);
|
Serial.println(numtel);
|
||||||
|
|
||||||
// Answer the call, establish the call
|
// Answer the call, establish the call
|
||||||
vcs.answerCall();
|
vcs.answerCall();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TALKING: // In this case the call would be established
|
case TALKING: // In this case the call would be established
|
||||||
|
|
||||||
Serial.println("TALKING. Press enter to hang up.");
|
Serial.println("TALKING. Press enter to hang up.");
|
||||||
while(Serial.read()!='\n')
|
while (Serial.read() != '\n')
|
||||||
delay(100);
|
delay(100);
|
||||||
vcs.hangCall();
|
vcs.hangCall();
|
||||||
Serial.println("Hanging up and waiting for the next call.");
|
Serial.println("Hanging up and waiting for the next call.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
delay(1000);
|
delay(1000);
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
SMS sender
|
SMS sender
|
||||||
|
|
||||||
This sketch, for the Arduino GSM shield,sends an SMS message
|
This sketch, for the Arduino GSM shield,sends an SMS message
|
||||||
you enter in the serial monitor. Connect your Arduino with the
|
you enter in the serial monitor. Connect your Arduino with the
|
||||||
GSM shield and SIM card, open the serial monitor, and wait for
|
GSM shield and SIM card, open the serial monitor, and wait for
|
||||||
the "READY" message to appear in the monitor. Next, type a
|
the "READY" message to appear in the monitor. Next, type a
|
||||||
message to send and press "return". Make sure the serial
|
message to send and press "return". Make sure the serial
|
||||||
monitor is set to send a newline when you press return.
|
monitor is set to send a newline when you press return.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield
|
* GSM shield
|
||||||
* SIM card that can send SMS
|
* SIM card that can send SMS
|
||||||
|
|
||||||
created 25 Feb 2012
|
created 25 Feb 2012
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
|
|
||||||
This example is in the public domain.
|
This example is in the public domain.
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMExamplesSendSMS
|
http://arduino.cc/en/Tutorial/GSMExamplesSendSMS
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Include the GSM library
|
// Include the GSM library
|
||||||
@ -37,7 +37,7 @@ void setup()
|
|||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("SMS Messages Sender");
|
Serial.println("SMS Messages Sender");
|
||||||
|
|
||||||
// connection state
|
// connection state
|
||||||
@ -45,9 +45,9 @@ void setup()
|
|||||||
|
|
||||||
// Start GSM shield
|
// Start GSM shield
|
||||||
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -55,7 +55,7 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("GSM initialized");
|
Serial.println("GSM initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ void loop()
|
|||||||
char remoteNum[20]; // telephone number to send sms
|
char remoteNum[20]; // telephone number to send sms
|
||||||
readSerial(remoteNum);
|
readSerial(remoteNum);
|
||||||
Serial.println(remoteNum);
|
Serial.println(remoteNum);
|
||||||
|
|
||||||
// sms text
|
// sms text
|
||||||
Serial.print("Now, enter SMS content: ");
|
Serial.print("Now, enter SMS content: ");
|
||||||
char txtMsg[200];
|
char txtMsg[200];
|
||||||
@ -75,11 +75,11 @@ void loop()
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
Serial.println("Message:");
|
Serial.println("Message:");
|
||||||
Serial.println(txtMsg);
|
Serial.println(txtMsg);
|
||||||
|
|
||||||
// send the message
|
// send the message
|
||||||
sms.beginSMS(remoteNum);
|
sms.beginSMS(remoteNum);
|
||||||
sms.print(txtMsg);
|
sms.print(txtMsg);
|
||||||
sms.endSMS();
|
sms.endSMS();
|
||||||
Serial.println("\nCOMPLETE!\n");
|
Serial.println("\nCOMPLETE!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ void loop()
|
|||||||
int readSerial(char result[])
|
int readSerial(char result[])
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
while (Serial.available() > 0)
|
while (Serial.available() > 0)
|
||||||
{
|
{
|
||||||
@ -100,7 +100,7 @@ int readSerial(char result[])
|
|||||||
Serial.flush();
|
Serial.flush();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(inChar!='\r')
|
if (inChar != '\r')
|
||||||
{
|
{
|
||||||
result[i] = inChar;
|
result[i] = inChar;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1,24 +1,24 @@
|
|||||||
/*
|
/*
|
||||||
Band Management
|
Band Management
|
||||||
|
|
||||||
This sketch, for the Arduino GSM shield, checks the band
|
This sketch, for the Arduino GSM shield, checks the band
|
||||||
currently configured in the modem and allows you to change
|
currently configured in the modem and allows you to change
|
||||||
it.
|
it.
|
||||||
|
|
||||||
Please check http://www.worldtimezone.com/gsm.html
|
Please check http://www.worldtimezone.com/gsm.html
|
||||||
Usual configurations:
|
Usual configurations:
|
||||||
Europe, Africa, Middle East: E-GSM(900)+DCS(1800)
|
Europe, Africa, Middle East: E-GSM(900)+DCS(1800)
|
||||||
USA, Canada, South America: GSM(850)+PCS(1900)
|
USA, Canada, South America: GSM(850)+PCS(1900)
|
||||||
Mexico: PCS(1900)
|
Mexico: PCS(1900)
|
||||||
Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)
|
Brazil: GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)
|
||||||
|
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield
|
* GSM shield
|
||||||
|
|
||||||
created 12 June 2012
|
created 12 June 2012
|
||||||
by Javier Zorzano, Scott Fitzgerald
|
by Javier Zorzano, Scott Fitzgerald
|
||||||
|
|
||||||
This example is in the public domain.
|
This example is in the public domain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -35,18 +35,18 @@ void setup()
|
|||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
|
|
||||||
// Beginning the band manager restarts the modem
|
// Beginning the band manager restarts the modem
|
||||||
Serial.println("Restarting modem...");
|
Serial.println("Restarting modem...");
|
||||||
band.begin();
|
band.begin();
|
||||||
Serial.println("Modem restarted.");
|
Serial.println("Modem restarted.");
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
// Get current band
|
// Get current band
|
||||||
String bandName = band.getBand(); // Get and print band name
|
String bandName = band.getBand(); // Get and print band name
|
||||||
Serial.print("Current band:");
|
Serial.print("Current band:");
|
||||||
Serial.println(bandName);
|
Serial.println(bandName);
|
||||||
@ -54,25 +54,25 @@ void loop()
|
|||||||
String newBandName;
|
String newBandName;
|
||||||
newBandName = askUser();
|
newBandName = askUser();
|
||||||
// Tell the user what we are about to do…
|
// Tell the user what we are about to do…
|
||||||
Serial.print("\nConfiguring band ");
|
Serial.print("\nConfiguring band ");
|
||||||
Serial.println(newBandName);
|
Serial.println(newBandName);
|
||||||
// Change the band
|
// Change the band
|
||||||
boolean operationSuccess;
|
boolean operationSuccess;
|
||||||
operationSuccess = band.setBand(newBandName);
|
operationSuccess = band.setBand(newBandName);
|
||||||
// Tell the user if the operation was OK
|
// Tell the user if the operation was OK
|
||||||
if(operationSuccess)
|
if (operationSuccess)
|
||||||
{
|
{
|
||||||
Serial.println("Success");
|
Serial.println("Success");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Serial.println("Error while changing band");
|
Serial.println("Error while changing band");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(operationSuccess)
|
if (operationSuccess)
|
||||||
{
|
{
|
||||||
while(true);
|
while (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function offers the user different options
|
// This function offers the user different options
|
||||||
@ -80,41 +80,41 @@ void loop()
|
|||||||
// The user selects one
|
// The user selects one
|
||||||
String askUser()
|
String askUser()
|
||||||
{
|
{
|
||||||
String newBand;
|
String newBand;
|
||||||
Serial.println("Select band:");
|
Serial.println("Select band:");
|
||||||
// Print the different options
|
// Print the different options
|
||||||
Serial.println("1 : E-GSM(900)");
|
Serial.println("1 : E-GSM(900)");
|
||||||
Serial.println("2 : DCS(1800)");
|
Serial.println("2 : DCS(1800)");
|
||||||
Serial.println("3 : PCS(1900)");
|
Serial.println("3 : PCS(1900)");
|
||||||
Serial.println("4 : E-GSM(900)+DCS(1800) ex: Europe");
|
Serial.println("4 : E-GSM(900)+DCS(1800) ex: Europe");
|
||||||
Serial.println("5 : GSM(850)+PCS(1900) Ex: USA, South Am.");
|
Serial.println("5 : GSM(850)+PCS(1900) Ex: USA, South Am.");
|
||||||
Serial.println("6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)");
|
Serial.println("6 : GSM(850)+E-GSM(900)+DCS(1800)+PCS(1900)");
|
||||||
|
|
||||||
// Empty the incoming buffer
|
// Empty the incoming buffer
|
||||||
while(Serial.available())
|
while (Serial.available())
|
||||||
Serial.read();
|
Serial.read();
|
||||||
|
|
||||||
// Wait for an answer, just look at the first character
|
// Wait for an answer, just look at the first character
|
||||||
while(!Serial.available());
|
while (!Serial.available());
|
||||||
char c= Serial.read();
|
char c = Serial.read();
|
||||||
if(c=='1')
|
if (c == '1')
|
||||||
newBand=GSM_MODE_EGSM;
|
newBand = GSM_MODE_EGSM;
|
||||||
else if(c=='2')
|
else if (c == '2')
|
||||||
newBand=GSM_MODE_DCS;
|
newBand = GSM_MODE_DCS;
|
||||||
else if(c=='3')
|
else if (c == '3')
|
||||||
newBand=GSM_MODE_PCS;
|
newBand = GSM_MODE_PCS;
|
||||||
else if(c=='4')
|
else if (c == '4')
|
||||||
newBand=GSM_MODE_EGSM_DCS;
|
newBand = GSM_MODE_EGSM_DCS;
|
||||||
else if(c=='5')
|
else if (c == '5')
|
||||||
newBand=GSM_MODE_GSM850_PCS;
|
newBand = GSM_MODE_GSM850_PCS;
|
||||||
else if(c=='6')
|
else if (c == '6')
|
||||||
newBand=GSM_MODE_GSM850_EGSM_DCS_PCS;
|
newBand = GSM_MODE_GSM850_EGSM_DCS_PCS;
|
||||||
else
|
else
|
||||||
newBand="GSM_MODE_UNDEFINED";
|
newBand = "GSM_MODE_UNDEFINED";
|
||||||
return newBand;
|
return newBand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,23 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
GSM Scan Networks
|
GSM Scan Networks
|
||||||
|
|
||||||
This example prints out the IMEI number of the modem,
|
This example prints out the IMEI number of the modem,
|
||||||
then checks to see if it's connected to a carrier. If so,
|
then checks to see if it's connected to a carrier. If so,
|
||||||
it prints the phone number associated with the card.
|
it prints the phone number associated with the card.
|
||||||
Then it scans for nearby networks and prints out their signal strengths.
|
Then it scans for nearby networks and prints out their signal strengths.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield
|
* GSM shield
|
||||||
* SIM card
|
* SIM card
|
||||||
|
|
||||||
Created 8 Mar 2012
|
Created 8 Mar 2012
|
||||||
by Tom Igoe, implemented by Javier Carazo
|
by Tom Igoe, implemented by Javier Carazo
|
||||||
Modified 4 Feb 2013
|
Modified 4 Feb 2013
|
||||||
by Scott Fitzgerald
|
by Scott Fitzgerald
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMToolsGsmScanNetworks
|
http://arduino.cc/en/Tutorial/GSMToolsGsmScanNetworks
|
||||||
|
|
||||||
This example code is part of the public domain
|
This example code is part of the public domain
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -48,15 +48,15 @@ void setup()
|
|||||||
|
|
||||||
Serial.println("GSM networks scanner");
|
Serial.println("GSM networks scanner");
|
||||||
scannerNetworks.begin();
|
scannerNetworks.begin();
|
||||||
|
|
||||||
// connection state
|
// connection state
|
||||||
boolean notConnected = true;
|
boolean notConnected = true;
|
||||||
|
|
||||||
// Start GSM shield
|
// Start GSM shield
|
||||||
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
while(notConnected)
|
while (notConnected)
|
||||||
{
|
{
|
||||||
if(gsmAccess.begin(PINNUMBER)==GSM_READY)
|
if (gsmAccess.begin(PINNUMBER) == GSM_READY)
|
||||||
notConnected = false;
|
notConnected = false;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -64,13 +64,13 @@ void setup()
|
|||||||
delay(1000);
|
delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get modem parameters
|
// get modem parameters
|
||||||
// IMEI, modem unique identifier
|
// IMEI, modem unique identifier
|
||||||
Serial.print("Modem IMEI: ");
|
Serial.print("Modem IMEI: ");
|
||||||
IMEI = modemTest.getIMEI();
|
IMEI = modemTest.getIMEI();
|
||||||
IMEI.replace("\n","");
|
IMEI.replace("\n", "");
|
||||||
if(IMEI != NULL)
|
if (IMEI != NULL)
|
||||||
Serial.println(IMEI);
|
Serial.println(IMEI);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,11 +79,11 @@ void loop()
|
|||||||
// scan for existing networks, displays a list of networks
|
// scan for existing networks, displays a list of networks
|
||||||
Serial.println("Scanning available networks. May take some seconds.");
|
Serial.println("Scanning available networks. May take some seconds.");
|
||||||
Serial.println(scannerNetworks.readNetworks());
|
Serial.println(scannerNetworks.readNetworks());
|
||||||
|
|
||||||
// currently connected carrier
|
// currently connected carrier
|
||||||
Serial.print("Current carrier: ");
|
Serial.print("Current carrier: ");
|
||||||
Serial.println(scannerNetworks.getCurrentCarrier());
|
Serial.println(scannerNetworks.getCurrentCarrier());
|
||||||
|
|
||||||
// returns strength and ber
|
// returns strength and ber
|
||||||
// signal strength in 0-31 scale. 31 means power > 51dBm
|
// signal strength in 0-31 scale. 31 means power > 51dBm
|
||||||
// BER is the Bit Error Rate. 0-7 scale. 99=not detectable
|
// BER is the Bit Error Rate. 0-7 scale. 99=not detectable
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
This example enables you to change or remove the PIN number of
|
This example enables you to change or remove the PIN number of
|
||||||
a SIM card inserted into a GSM shield.
|
a SIM card inserted into a GSM shield.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield
|
* GSM shield
|
||||||
* SIM card
|
* SIM card
|
||||||
|
|
||||||
Created 12 Jun 2012
|
Created 12 Jun 2012
|
||||||
by David del Peral
|
by David del Peral
|
||||||
|
|
||||||
This example code is part of the public domain
|
This example code is part of the public domain
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMToolsPinManagement
|
http://arduino.cc/en/Tutorial/GSMToolsPinManagement
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// libraries
|
// libraries
|
||||||
@ -39,32 +39,32 @@ void setup()
|
|||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("Change PIN example\n");
|
Serial.println("Change PIN example\n");
|
||||||
PINManager.begin();
|
PINManager.begin();
|
||||||
|
|
||||||
// check if the SIM have pin lock
|
// check if the SIM have pin lock
|
||||||
while(!auth){
|
while (!auth) {
|
||||||
int pin_query = PINManager.isPIN();
|
int pin_query = PINManager.isPIN();
|
||||||
if(pin_query == 1)
|
if (pin_query == 1)
|
||||||
{
|
{
|
||||||
// if SIM is locked, enter PIN code
|
// if SIM is locked, enter PIN code
|
||||||
Serial.print("Enter PIN code: ");
|
Serial.print("Enter PIN code: ");
|
||||||
user_input = readSerial();
|
user_input = readSerial();
|
||||||
// check PIN code
|
// check PIN code
|
||||||
if(PINManager.checkPIN(user_input) == 0)
|
if (PINManager.checkPIN(user_input) == 0)
|
||||||
{
|
{
|
||||||
auth = true;
|
auth = true;
|
||||||
PINManager.setPINUsed(true);
|
PINManager.setPINUsed(true);
|
||||||
Serial.println(oktext);
|
Serial.println(oktext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if PIN code was incorrected
|
// if PIN code was incorrected
|
||||||
Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
|
Serial.println("Incorrect PIN. Remember that you have 3 opportunities.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(pin_query == -1)
|
else if (pin_query == -1)
|
||||||
{
|
{
|
||||||
// PIN code is locked, user must enter PUK code
|
// PIN code is locked, user must enter PUK code
|
||||||
Serial.println("PIN locked. Enter PUK code: ");
|
Serial.println("PIN locked. Enter PUK code: ");
|
||||||
@ -72,7 +72,7 @@ void setup()
|
|||||||
Serial.print("Now, enter a new PIN code: ");
|
Serial.print("Now, enter a new PIN code: ");
|
||||||
user_input = readSerial();
|
user_input = readSerial();
|
||||||
// check PUK code
|
// check PUK code
|
||||||
if(PINManager.checkPUK(puk, user_input) == 0)
|
if (PINManager.checkPUK(puk, user_input) == 0)
|
||||||
{
|
{
|
||||||
auth = true;
|
auth = true;
|
||||||
PINManager.setPINUsed(true);
|
PINManager.setPINUsed(true);
|
||||||
@ -84,32 +84,32 @@ void setup()
|
|||||||
Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
|
Serial.println("Incorrect PUK or invalid new PIN. Try again!.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(pin_query == -2)
|
else if (pin_query == -2)
|
||||||
{
|
{
|
||||||
// the worst case, PIN and PUK are locked
|
// the worst case, PIN and PUK are locked
|
||||||
Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
|
Serial.println("PIN & PUK locked. Use PIN2/PUK2 in a mobile phone.");
|
||||||
while(true);
|
while (true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// SIM does not requires authetication
|
// SIM does not requires authetication
|
||||||
Serial.println("No pin necessary.");
|
Serial.println("No pin necessary.");
|
||||||
auth = true;
|
auth = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// start GSM shield
|
// start GSM shield
|
||||||
Serial.print("Checking register in GSM network...");
|
Serial.print("Checking register in GSM network...");
|
||||||
if(PINManager.checkReg() == 0)
|
if (PINManager.checkReg() == 0)
|
||||||
Serial.println(oktext);
|
Serial.println(oktext);
|
||||||
// if you are connect by roaming
|
// if you are connect by roaming
|
||||||
else if(PINManager.checkReg() == 1)
|
else if (PINManager.checkReg() == 1)
|
||||||
Serial.println("ROAMING " + oktext);
|
Serial.println("ROAMING " + oktext);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// error connection
|
// error connection
|
||||||
Serial.println(errortext);
|
Serial.println(errortext);
|
||||||
while(true);
|
while (true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,19 +118,19 @@ void loop()
|
|||||||
// Function loop implements pin management user menu
|
// Function loop implements pin management user menu
|
||||||
// Only if you SIM use pin lock, you can change PIN code
|
// Only if you SIM use pin lock, you can change PIN code
|
||||||
// user_op variables save user option
|
// user_op variables save user option
|
||||||
|
|
||||||
Serial.println("Choose an option:\n1 - On/Off PIN.");
|
Serial.println("Choose an option:\n1 - On/Off PIN.");
|
||||||
if(PINManager.getPINUsed())
|
if (PINManager.getPINUsed())
|
||||||
Serial.println("2 - Change PIN.");
|
Serial.println("2 - Change PIN.");
|
||||||
String user_op = readSerial();
|
String user_op = readSerial();
|
||||||
if(user_op == "1")
|
if (user_op == "1")
|
||||||
{
|
{
|
||||||
Serial.println("Enter your PIN code:");
|
Serial.println("Enter your PIN code:");
|
||||||
user_input = readSerial();
|
user_input = readSerial();
|
||||||
// activate/deactivate PIN lock
|
// activate/deactivate PIN lock
|
||||||
PINManager.switchPIN(user_input);
|
PINManager.switchPIN(user_input);
|
||||||
}
|
}
|
||||||
else if(user_op == "2" & PINManager.getPINUsed())
|
else if (user_op == "2" & PINManager.getPINUsed())
|
||||||
{
|
{
|
||||||
Serial.println("Enter your actual PIN code:");
|
Serial.println("Enter your actual PIN code:");
|
||||||
String oldPIN = readSerial();
|
String oldPIN = readSerial();
|
||||||
@ -152,7 +152,7 @@ void loop()
|
|||||||
String readSerial()
|
String readSerial()
|
||||||
{
|
{
|
||||||
String text = "";
|
String text = "";
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
while (Serial.available() > 0)
|
while (Serial.available() > 0)
|
||||||
{
|
{
|
||||||
@ -161,7 +161,7 @@ String readSerial()
|
|||||||
{
|
{
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
if(inChar!='\r')
|
if (inChar != '\r')
|
||||||
text += inChar;
|
text += inChar;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
This sketch test the GSM shield's ability to connect to a
|
This sketch test the GSM shield's ability to connect to a
|
||||||
GPERS network. It asks for APN information through the
|
GPERS network. It asks for APN information through the
|
||||||
serial monitor and tries to connect to arduino.cc.
|
serial monitor and tries to connect to arduino.cc.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield attached
|
* GSM shield attached
|
||||||
* SIM card with data plan
|
* SIM card with data plan
|
||||||
|
|
||||||
Created 18 Jun 2012
|
Created 18 Jun 2012
|
||||||
by David del Peral
|
by David del Peral
|
||||||
|
|
||||||
This example code is part of the public domain
|
This example code is part of the public domain
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMToolsTestGPRS
|
http://arduino.cc/en/Tutorial/GSMToolsTestGPRS
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// libraries
|
// libraries
|
||||||
@ -55,53 +55,53 @@ void setup()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
use_proxy = false;
|
use_proxy = false;
|
||||||
|
|
||||||
// start GSM shield
|
// start GSM shield
|
||||||
// if your SIM has PIN, pass it as a parameter of begin() in quotes
|
// if your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
Serial.print("Connecting GSM network...");
|
Serial.print("Connecting GSM network...");
|
||||||
if(gsmAccess.begin(PINNUMBER)!=GSM_READY)
|
if (gsmAccess.begin(PINNUMBER) != GSM_READY)
|
||||||
{
|
{
|
||||||
Serial.println(errortext);
|
Serial.println(errortext);
|
||||||
while(true);
|
while (true);
|
||||||
}
|
}
|
||||||
Serial.println(oktext);
|
Serial.println(oktext);
|
||||||
|
|
||||||
// read APN introduced by user
|
// read APN introduced by user
|
||||||
char apn[50];
|
char apn[50];
|
||||||
Serial.print("Enter your APN: ");
|
Serial.print("Enter your APN: ");
|
||||||
readSerial(apn);
|
readSerial(apn);
|
||||||
Serial.println(apn);
|
Serial.println(apn);
|
||||||
|
|
||||||
// Read APN login introduced by user
|
// Read APN login introduced by user
|
||||||
char login[50];
|
char login[50];
|
||||||
Serial.print("Now, enter your login: ");
|
Serial.print("Now, enter your login: ");
|
||||||
readSerial(login);
|
readSerial(login);
|
||||||
Serial.println(login);
|
Serial.println(login);
|
||||||
|
|
||||||
// read APN password introduced by user
|
// read APN password introduced by user
|
||||||
char password[20];
|
char password[20];
|
||||||
Serial.print("Finally, enter your password: ");
|
Serial.print("Finally, enter your password: ");
|
||||||
readSerial(password);
|
readSerial(password);
|
||||||
|
|
||||||
// attach GPRS
|
// attach GPRS
|
||||||
Serial.println("Attaching to GPRS with your APN...");
|
Serial.println("Attaching to GPRS with your APN...");
|
||||||
if(gprsAccess.attachGPRS(apn, login, password)!=GPRS_READY)
|
if (gprsAccess.attachGPRS(apn, login, password) != GPRS_READY)
|
||||||
{
|
{
|
||||||
Serial.println(errortext);
|
Serial.println(errortext);
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
|
|
||||||
Serial.println(oktext);
|
Serial.println(oktext);
|
||||||
|
|
||||||
// read proxy introduced by user
|
// read proxy introduced by user
|
||||||
char proxy[100];
|
char proxy[100];
|
||||||
Serial.print("If your carrier uses a proxy, enter it, if not press enter: ");
|
Serial.print("If your carrier uses a proxy, enter it, if not press enter: ");
|
||||||
readSerial(proxy);
|
readSerial(proxy);
|
||||||
Serial.println(proxy);
|
Serial.println(proxy);
|
||||||
|
|
||||||
// if user introduced a proxy, asks him for proxy port
|
// if user introduced a proxy, asks him for proxy port
|
||||||
int pport;
|
int pport;
|
||||||
if(proxy[0] != '\0'){
|
if (proxy[0] != '\0') {
|
||||||
// read proxy port introduced by user
|
// read proxy port introduced by user
|
||||||
char proxyport[10];
|
char proxyport[10];
|
||||||
Serial.print("Enter the proxy port: ");
|
Serial.print("Enter the proxy port: ");
|
||||||
@ -111,61 +111,61 @@ void loop()
|
|||||||
use_proxy = true;
|
use_proxy = true;
|
||||||
Serial.println(proxyport);
|
Serial.println(proxyport);
|
||||||
}
|
}
|
||||||
|
|
||||||
// connection with arduino.cc and realize HTTP request
|
// connection with arduino.cc and realize HTTP request
|
||||||
Serial.print("Connecting and sending GET request to arduino.cc...");
|
Serial.print("Connecting and sending GET request to arduino.cc...");
|
||||||
int res_connect;
|
int res_connect;
|
||||||
|
|
||||||
// if use a proxy, connect with it
|
// if use a proxy, connect with it
|
||||||
if(use_proxy)
|
if (use_proxy)
|
||||||
res_connect = client.connect(proxy, pport);
|
res_connect = client.connect(proxy, pport);
|
||||||
else
|
else
|
||||||
res_connect = client.connect(url, 80);
|
res_connect = client.connect(url, 80);
|
||||||
|
|
||||||
if (res_connect)
|
if (res_connect)
|
||||||
{
|
{
|
||||||
// make a HTTP 1.0 GET request (client sends the request)
|
// make a HTTP 1.0 GET request (client sends the request)
|
||||||
client.print("GET ");
|
client.print("GET ");
|
||||||
|
|
||||||
// if use a proxy, the path is arduino.cc URL
|
// if use a proxy, the path is arduino.cc URL
|
||||||
if(use_proxy)
|
if (use_proxy)
|
||||||
client.print(urlproxy);
|
client.print(urlproxy);
|
||||||
else
|
else
|
||||||
client.print(path);
|
client.print(path);
|
||||||
|
|
||||||
client.println(" HTTP/1.0");
|
client.println(" HTTP/1.0");
|
||||||
client.println();
|
client.println();
|
||||||
Serial.println(oktext);
|
Serial.println(oktext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// if you didn't get a connection to the server
|
// if you didn't get a connection to the server
|
||||||
Serial.println(errortext);
|
Serial.println(errortext);
|
||||||
}
|
}
|
||||||
Serial.print("Receiving response...");
|
Serial.print("Receiving response...");
|
||||||
|
|
||||||
boolean test = true;
|
boolean test = true;
|
||||||
while(test)
|
while (test)
|
||||||
{
|
{
|
||||||
// if there are incoming bytes available
|
// if there are incoming bytes available
|
||||||
// from the server, read and check them
|
// from the server, read and check them
|
||||||
if (client.available())
|
if (client.available())
|
||||||
{
|
{
|
||||||
char c = client.read();
|
char c = client.read();
|
||||||
response += c;
|
response += c;
|
||||||
|
|
||||||
// cast response obtained from string to char array
|
// cast response obtained from string to char array
|
||||||
char responsechar[response.length()+1];
|
char responsechar[response.length() + 1];
|
||||||
response.toCharArray(responsechar, response.length()+1);
|
response.toCharArray(responsechar, response.length() + 1);
|
||||||
|
|
||||||
// if response includes a "200 OK" substring
|
// if response includes a "200 OK" substring
|
||||||
if(strstr(responsechar, "200 OK") != NULL){
|
if (strstr(responsechar, "200 OK") != NULL) {
|
||||||
Serial.println(oktext);
|
Serial.println(oktext);
|
||||||
Serial.println("TEST COMPLETE!");
|
Serial.println("TEST COMPLETE!");
|
||||||
test = false;
|
test = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if the server's disconnected, stop the client:
|
// if the server's disconnected, stop the client:
|
||||||
if (!client.connected())
|
if (!client.connected())
|
||||||
{
|
{
|
||||||
@ -184,7 +184,7 @@ void loop()
|
|||||||
int readSerial(char result[])
|
int readSerial(char result[])
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
while (Serial.available() > 0)
|
while (Serial.available() > 0)
|
||||||
{
|
{
|
||||||
@ -194,7 +194,7 @@ int readSerial(char result[])
|
|||||||
result[i] = '\0';
|
result[i] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(inChar!='\r')
|
if (inChar != '\r')
|
||||||
{
|
{
|
||||||
result[i] = inChar;
|
result[i] = inChar;
|
||||||
i++;
|
i++;
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
|
|
||||||
This example tests to see if the modem of the
|
This example tests to see if the modem of the
|
||||||
GSM shield is working correctly. You do not need
|
GSM shield is working correctly. You do not need
|
||||||
a SIM card for this example.
|
a SIM card for this example.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield attached
|
* GSM shield attached
|
||||||
|
|
||||||
Created 12 Jun 2012
|
Created 12 Jun 2012
|
||||||
by David del Peral
|
by David del Peral
|
||||||
modified 21 Nov 2012
|
modified 21 Nov 2012
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMToolsTestModem
|
http://arduino.cc/en/Tutorial/GSMToolsTestModem
|
||||||
|
|
||||||
This sample code is part of the public domain
|
This sample code is part of the public domain
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// libraries
|
// libraries
|
||||||
@ -34,10 +34,10 @@ void setup()
|
|||||||
while (!Serial) {
|
while (!Serial) {
|
||||||
; // wait for serial port to connect. Needed for Leonardo only
|
; // wait for serial port to connect. Needed for Leonardo only
|
||||||
}
|
}
|
||||||
|
|
||||||
// start modem test (reset and check response)
|
// start modem test (reset and check response)
|
||||||
Serial.print("Starting modem test...");
|
Serial.print("Starting modem test...");
|
||||||
if(modem.begin())
|
if (modem.begin())
|
||||||
Serial.println("modem.begin() succeeded");
|
Serial.println("modem.begin() succeeded");
|
||||||
else
|
else
|
||||||
Serial.println("ERROR, no modem answer.");
|
Serial.println("ERROR, no modem answer.");
|
||||||
@ -48,9 +48,9 @@ void loop()
|
|||||||
// get modem IMEI
|
// get modem IMEI
|
||||||
Serial.print("Checking IMEI...");
|
Serial.print("Checking IMEI...");
|
||||||
IMEI = modem.getIMEI();
|
IMEI = modem.getIMEI();
|
||||||
|
|
||||||
// check IMEI response
|
// check IMEI response
|
||||||
if(IMEI != NULL)
|
if (IMEI != NULL)
|
||||||
{
|
{
|
||||||
// show IMEI in serial monitor
|
// show IMEI in serial monitor
|
||||||
Serial.println("Modem's IMEI: " + IMEI);
|
Serial.println("Modem's IMEI: " + IMEI);
|
||||||
@ -58,7 +58,7 @@ void loop()
|
|||||||
Serial.print("Resetting modem...");
|
Serial.print("Resetting modem...");
|
||||||
modem.begin();
|
modem.begin();
|
||||||
// get and check IMEI one more time
|
// get and check IMEI one more time
|
||||||
if(modem.getIMEI() != NULL)
|
if (modem.getIMEI() != NULL)
|
||||||
{
|
{
|
||||||
Serial.println("Modem is functoning properly");
|
Serial.println("Modem is functoning properly");
|
||||||
}
|
}
|
||||||
@ -72,6 +72,6 @@ void loop()
|
|||||||
Serial.println("Error: Could not get IMEI");
|
Serial.println("Error: Could not get IMEI");
|
||||||
}
|
}
|
||||||
// do nothing:
|
// do nothing:
|
||||||
while(true);
|
while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
Basic Web Server
|
Basic Web Server
|
||||||
|
|
||||||
A simple web server that replies with nothing, but prints the client's request
|
A simple web server that replies with nothing, but prints the client's request
|
||||||
and the server IP address.
|
and the server IP address.
|
||||||
|
|
||||||
Circuit:
|
Circuit:
|
||||||
* GSM shield attached
|
* GSM shield attached
|
||||||
|
|
||||||
created
|
created
|
||||||
by David Cuartielles
|
by David Cuartielles
|
||||||
modified 21 Nov 2012
|
modified 21 Nov 2012
|
||||||
by Tom Igoe
|
by Tom Igoe
|
||||||
|
|
||||||
http://arduino.cc/en/Tutorial/GSMToolsTestWebServer
|
http://arduino.cc/en/Tutorial/GSMToolsTestWebServer
|
||||||
|
|
||||||
This example code is part of the public domain
|
This example code is part of the public domain
|
||||||
*/
|
*/
|
||||||
#include <GSM.h>
|
#include <GSM.h>
|
||||||
|
|
||||||
// PIN Number
|
// PIN Number
|
||||||
#define PINNUMBER ""
|
#define PINNUMBER ""
|
||||||
@ -33,7 +33,7 @@ GSM gsmAccess; // include a 'true' parameter for debug enabled
|
|||||||
GSMServer server(80); // port 80 (http default)
|
GSMServer server(80); // port 80 (http default)
|
||||||
|
|
||||||
// timeout
|
// timeout
|
||||||
const unsigned long __TIMEOUT__ = 10*1000;
|
const unsigned long __TIMEOUT__ = 10 * 1000;
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -49,10 +49,10 @@ void setup()
|
|||||||
|
|
||||||
// Start GSM shield
|
// Start GSM shield
|
||||||
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
// If your SIM has PIN, pass it as a parameter of begin() in quotes
|
||||||
while(!connected)
|
while (!connected)
|
||||||
{
|
{
|
||||||
if((gsmAccess.begin(PINNUMBER)==GSM_READY) &
|
if ((gsmAccess.begin(PINNUMBER) == GSM_READY) &
|
||||||
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD)==GPRS_READY))
|
(gprs.attachGPRS(GPRS_APN, GPRS_LOGIN, GPRS_PASSWORD) == GPRS_READY))
|
||||||
connected = true;
|
connected = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -72,14 +72,14 @@ void setup()
|
|||||||
Serial.println(LocalIP);
|
Serial.println(LocalIP);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop() {
|
||||||
GSMClient client = server.available();
|
GSMClient client = server.available();
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
if (client.available()) {
|
if (client.available()) {
|
||||||
Serial.write(client.read());
|
Serial.write(client.read());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user