mirror of
				https://github.com/KevinMidboe/TinyGSM.git
				synced 2025-10-29 18:00:18 +00:00 
			
		
		
		
	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:
		
							
								
								
									
										10
									
								
								.travis.yml
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								.travis.yml
									
									
									
									
									
								
							@@ -25,11 +25,11 @@ env:
 | 
			
		||||
    - 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,7 +411,7 @@ 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 == '.') {
 | 
			
		||||
        Part++;
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
 
 | 
			
		||||
@@ -427,7 +427,7 @@ 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 == '.') {
 | 
			
		||||
        Part++;
 | 
			
		||||
 
 | 
			
		||||
@@ -531,7 +531,7 @@ 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 == '.') {
 | 
			
		||||
        Part++;
 | 
			
		||||
 
 | 
			
		||||
@@ -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,11 +382,9 @@ 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;
 | 
			
		||||
      }
 | 
			
		||||
@@ -449,7 +447,7 @@ 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 == '.') {
 | 
			
		||||
        Part++;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										
											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