IP fxns for ESP8266
- fixed int/uint warning - added functions to get local IP address with esp8266 - fixed local ip fxn for xbee - removed extra test builds - set travis to build all modems in tests
This commit is contained in:
18
.travis.yml
18
.travis.yml
@@ -18,18 +18,18 @@ env:
|
||||
- PLATFORMIO_CI_SRC=tools/FactoryReset
|
||||
|
||||
# Arduino test
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_SIM800' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_A6' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_M590' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_SIM800' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_A6' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_M590' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_ESP8266' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_XBEE' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_XBEE' --project-option='framework=arduino' --board=uno --board=leonardo --board=yun --board=megaatmega2560 --board=genuino101 --board=mkr1000USB --board=zero --board=teensy31 --board=bluepill_f103c8 --board=uno_pic32 --board=esp01 --board=nodemcuv2 --board=esp32dev --board=mayfly"
|
||||
|
||||
# Energia test
|
||||
- PLATFORMIO_CI_SRC=tools/test_buildA6 PLATFORMIO_CI_ARGS="--project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_buildESP8266 PLATFORMIO_CI_ARGS="--project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_buildM590 PLATFORMIO_CI_ARGS="--project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_buildSIM800 PLATFORMIO_CI_ARGS="--project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_buildXBee PLATFORMIO_CI_ARGS="--project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_SIM800' --project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_A6' --project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_M590' --project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_ESP8266' --project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
- PLATFORMIO_CI_SRC=tools/test_build PLATFORMIO_CI_ARGS="--project-option='build_flags=-D TINY_GSM_MODEM_XBEE' --project-option='framework=energia' --board=lplm4f120h5qr"
|
||||
|
||||
install:
|
||||
# ChipKIT issue: install 32-bit support for GCC PIC32
|
||||
|
||||
@@ -411,16 +411,16 @@ public:
|
||||
String strIP = getLocalIP();
|
||||
int Parts[4] = {0,0,0,0};
|
||||
int Part = 0;
|
||||
for ( int i=0; i<strIP.length(); i++ ) {
|
||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||
char c = strIP[i];
|
||||
if ( c == '.' ) {
|
||||
if (c == '.') {
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
}
|
||||
IPAddress res( Parts[0], Parts[1], Parts[2], Parts[3] );
|
||||
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -282,9 +282,34 @@ public:
|
||||
return waitResponse(10000L) == 1;
|
||||
}
|
||||
|
||||
String getLocalIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||
String getLocalIP() {
|
||||
sendAT(GF("+CIPSTA_CUR??"));
|
||||
int res1 = waitResponse(GF("ERROR"), GF("+CWJAP_CUR:"));
|
||||
if (res1 != 2) {
|
||||
return "";
|
||||
}
|
||||
String res2 = stream.readStringUntil('"');
|
||||
DBG(res2);
|
||||
waitResponse();
|
||||
return res2;
|
||||
}
|
||||
|
||||
IPAddress localIP() TINY_GSM_ATTR_NOT_IMPLEMENTED;
|
||||
IPAddress localIP() {
|
||||
String strIP = getLocalIP();
|
||||
int Parts[4] = {0,0,0,0};
|
||||
int Part = 0;
|
||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||
char c = strIP[i];
|
||||
if (c == '.') {
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
}
|
||||
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* GPRS functions
|
||||
@@ -425,7 +450,7 @@ public:
|
||||
if (data.length()) {
|
||||
DBG("### Unhandled:", data);
|
||||
}
|
||||
data = "";
|
||||
data = "";
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -427,16 +427,16 @@ public:
|
||||
String strIP = getLocalIP();
|
||||
int Parts[4] = {0,0,0,0};
|
||||
int Part = 0;
|
||||
for ( int i=0; i<strIP.length(); i++ ) {
|
||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||
char c = strIP[i];
|
||||
if ( c == '.' ) {
|
||||
if (c == '.') {
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
}
|
||||
IPAddress res( Parts[0], Parts[1], Parts[2], Parts[3] );
|
||||
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
@@ -531,16 +531,16 @@ public:
|
||||
String strIP = getLocalIP();
|
||||
int Parts[4] = {0,0,0,0};
|
||||
int Part = 0;
|
||||
for ( int i=0; i<strIP.length(); i++ ) {
|
||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||
char c = strIP[i];
|
||||
if ( c == '.' ) {
|
||||
if (c == '.') {
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
}
|
||||
IPAddress res( Parts[0], Parts[1], Parts[2], Parts[3] );
|
||||
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -907,7 +907,7 @@ public:
|
||||
if (data.length()) {
|
||||
DBG("### Unhandled:", data);
|
||||
}
|
||||
data = "";
|
||||
data = "";
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@@ -369,7 +369,7 @@ public:
|
||||
|
||||
String getLocalIP() {
|
||||
commandMode();
|
||||
sendAT(GF("LA"), host);
|
||||
sendAT(GF("MY"));
|
||||
String IPaddr; IPaddr.reserve(16);
|
||||
// wait for the response
|
||||
unsigned long startMillis = millis();
|
||||
@@ -382,18 +382,16 @@ public:
|
||||
String strIP = getLocalIP();
|
||||
int Parts[4] = {0,0,0,0};
|
||||
int Part = 0;
|
||||
for ( int i=0; i<strIP.length(); i++ )
|
||||
{
|
||||
char c = strIP[i];
|
||||
if ( c == '.' )
|
||||
{
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||
char c = strIP[i];
|
||||
if (c == '.') {
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
}
|
||||
IPAddress res( Parts[0], Parts[1], Parts[2], Parts[3] );
|
||||
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -449,16 +447,16 @@ private:
|
||||
strIP = streamReadUntil('\r'); // read result
|
||||
int Parts[4] = {0,0,0,0};
|
||||
int Part = 0;
|
||||
for ( int i=0; i<strIP.length(); i++ ) {
|
||||
for (uint8_t i=0; i<strIP.length(); i++) {
|
||||
char c = strIP[i];
|
||||
if ( c == '.' ) {
|
||||
if (c == '.') {
|
||||
Part++;
|
||||
continue;
|
||||
}
|
||||
Parts[Part] *= 10;
|
||||
Parts[Part] += c - '0';
|
||||
}
|
||||
IPAddress res( Parts[0], Parts[1], Parts[2], Parts[3] );
|
||||
IPAddress res(Parts[0], Parts[1], Parts[2], Parts[3]);
|
||||
return modemConnect(res, port);
|
||||
}
|
||||
|
||||
|
||||
BIN
doc/Digi XBee LTEC1 Users Guide - 90001525.pdf
Normal file
BIN
doc/Digi XBee LTEC1 Users Guide - 90001525.pdf
Normal file
Binary file not shown.
BIN
doc/Digi XBee S6B Users Guide - 90002180.pdf
Normal file
BIN
doc/Digi XBee S6B Users Guide - 90002180.pdf
Normal file
Binary file not shown.
BIN
doc/ESP8266 - AT Instruction Set.pdf
Normal file
BIN
doc/ESP8266 - AT Instruction Set.pdf
Normal file
Binary file not shown.
BIN
doc/ESP8266 - Datasheet v4.3.pdf
Normal file
BIN
doc/ESP8266 - Datasheet v4.3.pdf
Normal file
Binary file not shown.
BIN
doc/ESP8266 - Low Power Solutions.pdf
Normal file
BIN
doc/ESP8266 - Low Power Solutions.pdf
Normal file
Binary file not shown.
BIN
doc/SIM800 AT Commands v1.11.pdf
Normal file
BIN
doc/SIM800 AT Commands v1.11.pdf
Normal file
Binary file not shown.
@@ -4,12 +4,6 @@
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// #define TINY_GSM_MODEM_SIM800
|
||||
#define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
/**************************************************************
|
||||
*
|
||||
* DO NOT USE THIS - this is just a compilation test!
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// #define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_SIM808
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
TinyGsmClient client(modem);
|
||||
|
||||
char server[] = "somewhere";
|
||||
char resource[] = "something";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
modem.restart();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Test the start/restart functions
|
||||
modem.restart();
|
||||
modem.begin();
|
||||
modem.autoBaud();
|
||||
modem.factoryDefault();
|
||||
|
||||
// Test the SIM card functions
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
|
||||
modem.getSimCCID();
|
||||
modem.getIMEI();
|
||||
modem.getSimStatus();
|
||||
modem.getRegistrationStatus();
|
||||
modem.getOperator();
|
||||
#endif
|
||||
|
||||
|
||||
// Test the Networking functions
|
||||
modem.getSignalQuality();
|
||||
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.waitForNetwork();
|
||||
modem.gprsConnect("YourAPN", "", "");
|
||||
#else
|
||||
modem.networkConnect("YourSSID", "YourPWD");
|
||||
modem.waitForNetwork();
|
||||
#endif
|
||||
|
||||
client.connect(server, 80);
|
||||
|
||||
// Make a HTTP GET request:
|
||||
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
|
||||
client.print(String("Host: ") + server + "\r\n");
|
||||
client.print("Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timeout = millis();
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
client.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.gprsDisconnect();
|
||||
#else
|
||||
modem.networkDisconnect();
|
||||
#endif
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**************************************************************
|
||||
*
|
||||
* DO NOT USE THIS - this is just a compilation test!
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// #define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
#define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
TinyGsmClient client(modem);
|
||||
|
||||
char server[] = "somewhere";
|
||||
char resource[] = "something";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
modem.restart();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Test the start/restart functions
|
||||
modem.restart();
|
||||
modem.begin();
|
||||
modem.autoBaud();
|
||||
modem.factoryDefault();
|
||||
|
||||
// Test the SIM card functions
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
|
||||
modem.getSimCCID();
|
||||
modem.getIMEI();
|
||||
modem.getSimStatus();
|
||||
modem.getRegistrationStatus();
|
||||
modem.getOperator();
|
||||
#endif
|
||||
|
||||
|
||||
// Test the Networking functions
|
||||
modem.getSignalQuality();
|
||||
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.waitForNetwork();
|
||||
modem.gprsConnect("YourAPN", "", "");
|
||||
#else
|
||||
modem.networkConnect("YourSSID", "YourPWD");
|
||||
modem.waitForNetwork();
|
||||
#endif
|
||||
|
||||
client.connect(server, 80);
|
||||
|
||||
// Make a HTTP GET request:
|
||||
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
|
||||
client.print(String("Host: ") + server + "\r\n");
|
||||
client.print("Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timeout = millis();
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
client.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.gprsDisconnect();
|
||||
#else
|
||||
modem.networkDisconnect();
|
||||
#endif
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**************************************************************
|
||||
*
|
||||
* DO NOT USE THIS - this is just a compilation test!
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// #define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
#define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
TinyGsmClient client(modem);
|
||||
|
||||
char server[] = "somewhere";
|
||||
char resource[] = "something";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
modem.restart();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Test the start/restart functions
|
||||
modem.restart();
|
||||
modem.begin();
|
||||
modem.autoBaud();
|
||||
modem.factoryDefault();
|
||||
|
||||
// Test the SIM card functions
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
|
||||
modem.getSimCCID();
|
||||
modem.getIMEI();
|
||||
modem.getSimStatus();
|
||||
modem.getRegistrationStatus();
|
||||
modem.getOperator();
|
||||
#endif
|
||||
|
||||
|
||||
// Test the Networking functions
|
||||
modem.getSignalQuality();
|
||||
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.waitForNetwork();
|
||||
modem.gprsConnect("YourAPN", "", "");
|
||||
#else
|
||||
modem.networkConnect("YourSSID", "YourPWD");
|
||||
modem.waitForNetwork();
|
||||
#endif
|
||||
|
||||
client.connect(server, 80);
|
||||
|
||||
// Make a HTTP GET request:
|
||||
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
|
||||
client.print(String("Host: ") + server + "\r\n");
|
||||
client.print("Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timeout = millis();
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
client.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.gprsDisconnect();
|
||||
#else
|
||||
modem.networkDisconnect();
|
||||
#endif
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**************************************************************
|
||||
*
|
||||
* DO NOT USE THIS - this is just a compilation test!
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
#define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
TinyGsmClient client(modem);
|
||||
|
||||
char server[] = "somewhere";
|
||||
char resource[] = "something";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
modem.restart();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Test the start/restart functions
|
||||
modem.restart();
|
||||
modem.begin();
|
||||
modem.autoBaud();
|
||||
modem.factoryDefault();
|
||||
|
||||
// Test the SIM card functions
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
|
||||
modem.getSimCCID();
|
||||
modem.getIMEI();
|
||||
modem.getSimStatus();
|
||||
modem.getRegistrationStatus();
|
||||
modem.getOperator();
|
||||
#endif
|
||||
|
||||
|
||||
// Test the Networking functions
|
||||
modem.getSignalQuality();
|
||||
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.waitForNetwork();
|
||||
modem.gprsConnect("YourAPN", "", "");
|
||||
#else
|
||||
modem.networkConnect("YourSSID", "YourPWD");
|
||||
modem.waitForNetwork();
|
||||
#endif
|
||||
|
||||
client.connect(server, 80);
|
||||
|
||||
// Make a HTTP GET request:
|
||||
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
|
||||
client.print(String("Host: ") + server + "\r\n");
|
||||
client.print("Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timeout = millis();
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
client.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.gprsDisconnect();
|
||||
#else
|
||||
modem.networkDisconnect();
|
||||
#endif
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/**************************************************************
|
||||
*
|
||||
* DO NOT USE THIS - this is just a compilation test!
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// #define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
#define TINY_GSM_MODEM_XBEE
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
TinyGsmClient client(modem);
|
||||
|
||||
char server[] = "somewhere";
|
||||
char resource[] = "something";
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(3000);
|
||||
modem.restart();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// Test the start/restart functions
|
||||
modem.restart();
|
||||
modem.begin();
|
||||
modem.autoBaud();
|
||||
modem.factoryDefault();
|
||||
|
||||
// Test the SIM card functions
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590) || defined(TINY_GSM_MODEM_XBEE)
|
||||
modem.getSimCCID();
|
||||
modem.getIMEI();
|
||||
modem.getSimStatus();
|
||||
modem.getRegistrationStatus();
|
||||
modem.getOperator();
|
||||
#endif
|
||||
|
||||
|
||||
// Test the Networking functions
|
||||
modem.getSignalQuality();
|
||||
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.waitForNetwork();
|
||||
modem.gprsConnect("YourAPN", "", "");
|
||||
#else
|
||||
modem.networkConnect("YourSSID", "YourPWD");
|
||||
modem.waitForNetwork();
|
||||
#endif
|
||||
|
||||
client.connect(server, 80);
|
||||
|
||||
// Make a HTTP GET request:
|
||||
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
|
||||
client.print(String("Host: ") + server + "\r\n");
|
||||
client.print("Connection: close\r\n\r\n");
|
||||
|
||||
unsigned long timeout = millis();
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
client.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
|
||||
#if defined(TINY_GSM_MODEM_SIM800) || defined(TINY_GSM_MODEM_A6) || defined(TINY_GSM_MODEM_M590)
|
||||
modem.gprsDisconnect();
|
||||
#else
|
||||
modem.networkDisconnect();
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user