first commit
This commit is contained in:
commit
e6a42e28e9
4355 changed files with 4626605 additions and 0 deletions
99
libraries/TinyGSM/tools/AT_Debug/AT_Debug.ino
Normal file
99
libraries/TinyGSM/tools/AT_Debug/AT_Debug.ino
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/**************************************************************
|
||||
*
|
||||
* This script tries to auto-detect the baud rate
|
||||
* and allows direct AT commands access
|
||||
*
|
||||
* TinyGSM Getting Started guide:
|
||||
* https://tiny.cc/tinygsm-readme
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// Select your modem:
|
||||
#define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_SIM808
|
||||
// #define TINY_GSM_MODEM_SIM868
|
||||
// #define TINY_GSM_MODEM_SIM900
|
||||
// #define TINY_GSM_MODEM_SIM7000
|
||||
// #define TINY_GSM_MODEM_SIM7000SSL
|
||||
// #define TINY_GSM_MODEM_SIM7080
|
||||
// #define TINY_GSM_MODEM_SIM5360
|
||||
// #define TINY_GSM_MODEM_SIM7600
|
||||
// #define TINY_GSM_MODEM_A7672X
|
||||
// #define TINY_GSM_MODEM_UBLOX
|
||||
// #define TINY_GSM_MODEM_SARAR4
|
||||
// #define TINY_GSM_MODEM_SARAR5
|
||||
// #define TINY_GSM_MODEM_M95
|
||||
// #define TINY_GSM_MODEM_BG95
|
||||
// #define TINY_GSM_MODEM_BG96
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_A7
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_MC60
|
||||
// #define TINY_GSM_MODEM_MC60E
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_ESP32
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
// #define TINY_GSM_MODEM_SEQUANS_MONARCH
|
||||
|
||||
// Set serial for debug console (to the Serial Monitor, speed 115200)
|
||||
#define SerialMon Serial
|
||||
|
||||
// Set serial for AT commands (to the module)
|
||||
// Use Hardware Serial on Mega, Leonardo, Micro
|
||||
#ifndef __AVR_ATmega328P__
|
||||
#define SerialAT Serial1
|
||||
|
||||
// or Software Serial on Uno, Nano
|
||||
#else
|
||||
#include <SoftwareSerial.h>
|
||||
SoftwareSerial SerialAT(2, 3); // RX, TX
|
||||
#endif
|
||||
|
||||
#define TINY_GSM_DEBUG SerialMon
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
// Module baud rate
|
||||
uint32_t rate = 0; // Set to 0 for Auto-Detect
|
||||
|
||||
void setup() {
|
||||
// Set console baud rate
|
||||
SerialMon.begin(115200);
|
||||
delay(6000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
if (!rate) { rate = TinyGsmAutoBaud(SerialAT); }
|
||||
|
||||
if (!rate) {
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
SerialMon.println(F(" Module does not respond!"));
|
||||
SerialMon.println(F(" Check your Serial wiring"));
|
||||
SerialMon.println(
|
||||
F(" Check the module is correctly powered and turned on"));
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
delay(30000L);
|
||||
return;
|
||||
}
|
||||
|
||||
SerialAT.begin(rate);
|
||||
|
||||
// Access AT commands from Serial Monitor
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
SerialMon.println(F(" You can now send AT commands"));
|
||||
SerialMon.println(
|
||||
F(" Enter \"AT\" (without quotes), and you should see \"OK\""));
|
||||
SerialMon.println(
|
||||
F(" If it doesn't work, select \"Both NL & CR\" in Serial Monitor"));
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
|
||||
while (true) {
|
||||
if (SerialAT.available()) { SerialMon.write(SerialAT.read()); }
|
||||
if (SerialMon.available()) { SerialAT.write(SerialMon.read()); }
|
||||
delay(0);
|
||||
}
|
||||
}
|
||||
46
libraries/TinyGSM/tools/AT_Spy/AT_Spy.ino
Normal file
46
libraries/TinyGSM/tools/AT_Spy/AT_Spy.ino
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**************************************************************
|
||||
*
|
||||
* This script just listens in on the communication
|
||||
* between an Arduino and the modem.
|
||||
*
|
||||
* TinyGSM Getting Started guide:
|
||||
* https://tiny.cc/tinygsm-readme
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// Set the baud rate between the modem and the board
|
||||
#define BAUD_RATE 9600
|
||||
|
||||
// Set serial printing out the communication
|
||||
#define SPY Serial
|
||||
|
||||
// Set serial for input from modem
|
||||
#define MODEM_TX Serial1
|
||||
|
||||
// Set serial for AT commands (to the module)
|
||||
// Use Hardware Serial on Mega, Leonardo, Micro
|
||||
// #define BOARD_TX Serial1
|
||||
|
||||
// or AltSoftware
|
||||
#include <AltSoftSerial.h>
|
||||
AltSoftSerial BOARD_TX;
|
||||
|
||||
|
||||
void setup() {
|
||||
// Set console baud rate
|
||||
SPY.begin(115200);
|
||||
|
||||
MODEM_TX.begin(BAUD_RATE);
|
||||
BOARD_TX.begin(BAUD_RATE);
|
||||
delay(6000);
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
while (MODEM_TX.available()) {
|
||||
SPY.write(MODEM_TX.read());
|
||||
}
|
||||
while (BOARD_TX.available()) {
|
||||
SPY.write(BOARD_TX.read());
|
||||
}
|
||||
}
|
||||
289
libraries/TinyGSM/tools/Diagnostics/Diagnostics.ino
Normal file
289
libraries/TinyGSM/tools/Diagnostics/Diagnostics.ino
Normal file
|
|
@ -0,0 +1,289 @@
|
|||
/**************************************************************
|
||||
*
|
||||
* To run this tool you need StreamDebugger library:
|
||||
* https://github.com/vshymanskyy/StreamDebugger
|
||||
* or from http://librarymanager/all#StreamDebugger
|
||||
*
|
||||
* TinyGSM Getting Started guide:
|
||||
* https://tiny.cc/tinygsm-readme
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// Select your modem:
|
||||
#define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_SIM808
|
||||
// #define TINY_GSM_MODEM_SIM868
|
||||
// #define TINY_GSM_MODEM_SIM900
|
||||
// #define TINY_GSM_MODEM_SIM7000
|
||||
// #define TINY_GSM_MODEM_SIM7000SSL
|
||||
// #define TINY_GSM_MODEM_SIM7080
|
||||
// #define TINY_GSM_MODEM_SIM5360
|
||||
// #define TINY_GSM_MODEM_SIM7600
|
||||
// #define TINY_GSM_MODEM_A7672X
|
||||
// #define TINY_GSM_MODEM_UBLOX
|
||||
// #define TINY_GSM_MODEM_SARAR4
|
||||
// #define TINY_GSM_MODEM_M95
|
||||
// #define TINY_GSM_MODEM_BG95
|
||||
// #define TINY_GSM_MODEM_BG96
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_A7
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_MC60
|
||||
// #define TINY_GSM_MODEM_MC60E
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_ESP32
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
// #define TINY_GSM_MODEM_SEQUANS_MONARCH
|
||||
|
||||
// Set serial for debug console (to the Serial Monitor, default speed 115200)
|
||||
#define SerialMon Serial
|
||||
|
||||
// Set serial for AT commands (to the module)
|
||||
// Use Hardware Serial on Mega, Leonardo, Micro
|
||||
#ifndef __AVR_ATmega328P__
|
||||
#define SerialAT Serial1
|
||||
|
||||
// or Software Serial on Uno, Nano
|
||||
#else
|
||||
#include <SoftwareSerial.h>
|
||||
SoftwareSerial SerialAT(2, 3); // RX, TX
|
||||
#endif
|
||||
|
||||
// Increase RX buffer to capture the entire response
|
||||
// Chips without internal buffering (A6/A7, ESP8266, M590)
|
||||
// need enough space in the buffer for the entire response
|
||||
// else data will be lost (and the http library will fail).
|
||||
#ifndef TINY_GSM_RX_BUFFER
|
||||
#define TINY_GSM_RX_BUFFER 1024
|
||||
#endif
|
||||
|
||||
// See all AT commands, if wanted
|
||||
// #define DUMP_AT_COMMANDS
|
||||
|
||||
// Define the serial console for debug prints, if needed
|
||||
#define TINY_GSM_DEBUG SerialMon
|
||||
|
||||
// Range to attempt to autobaud
|
||||
// NOTE: DO NOT AUTOBAUD in production code. Once you've established
|
||||
// communication, set a fixed baud rate using modem.setBaud(#).
|
||||
#define GSM_AUTOBAUD_MIN 9600
|
||||
#define GSM_AUTOBAUD_MAX 115200
|
||||
|
||||
// Add a reception delay - may be needed for a fast processor at a slow baud
|
||||
// rate #define TINY_GSM_YIELD() { delay(2); }
|
||||
|
||||
// Uncomment this if you want to use SSL
|
||||
// #define USE_SSL
|
||||
|
||||
#define TINY_GSM_USE_GPRS true
|
||||
#define TINY_GSM_USE_WIFI false
|
||||
|
||||
// set GSM PIN, if any
|
||||
#define GSM_PIN ""
|
||||
|
||||
// Your GPRS credentials, if any
|
||||
const char apn[] = "YourAPN";
|
||||
const char gprsUser[] = "";
|
||||
const char gprsPass[] = "";
|
||||
|
||||
// Your WiFi connection credentials, if applicable
|
||||
const char wifiSSID[] = "YourSSID";
|
||||
const char wifiPass[] = "YourWiFiPass";
|
||||
|
||||
// Server details
|
||||
const char server[] = "vsh.pp.ua";
|
||||
const char resource[] = "/TinyGSM/logo.txt";
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
// Just in case someone defined the wrong thing..
|
||||
#if TINY_GSM_USE_GPRS && not defined TINY_GSM_MODEM_HAS_GPRS
|
||||
#undef TINY_GSM_USE_GPRS
|
||||
#undef TINY_GSM_USE_WIFI
|
||||
#define TINY_GSM_USE_GPRS false
|
||||
#define TINY_GSM_USE_WIFI true
|
||||
#endif
|
||||
#if TINY_GSM_USE_WIFI && not defined TINY_GSM_MODEM_HAS_WIFI
|
||||
#undef TINY_GSM_USE_GPRS
|
||||
#undef TINY_GSM_USE_WIFI
|
||||
#define TINY_GSM_USE_GPRS true
|
||||
#define TINY_GSM_USE_WIFI false
|
||||
#endif
|
||||
|
||||
#ifdef DUMP_AT_COMMANDS
|
||||
#include <StreamDebugger.h>
|
||||
StreamDebugger debugger(SerialAT, SerialMon);
|
||||
TinyGsm modem(debugger);
|
||||
#else
|
||||
TinyGsm modem(SerialAT);
|
||||
#endif
|
||||
|
||||
#if defined(TINY_GSM_MODEM_HAS_SSL)
|
||||
#define USE_SSL
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSL
|
||||
TinyGsmClientSecure client(modem);
|
||||
const int port = 443;
|
||||
#else
|
||||
TinyGsmClient client(modem);
|
||||
const int port = 80;
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
// Set console baud rate
|
||||
SerialMon.begin(115200);
|
||||
delay(10);
|
||||
|
||||
// !!!!!!!!!!!
|
||||
// Set your reset, enable, power pins here
|
||||
// !!!!!!!!!!!
|
||||
|
||||
SerialMon.println("Wait...");
|
||||
|
||||
// Set GSM module baud rate
|
||||
TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX);
|
||||
// SerialAT.begin(9600);
|
||||
delay(6000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Restart takes quite some time
|
||||
// To skip it, call init() instead of restart()
|
||||
SerialMon.print("Initializing modem...");
|
||||
if (!modem.restart()) {
|
||||
// if (!modem.init()) {
|
||||
SerialMon.println(F(" [fail]"));
|
||||
SerialMon.println(F("************************"));
|
||||
SerialMon.println(F(" Is your modem connected properly?"));
|
||||
SerialMon.println(F(" Is your serial speed (baud rate) correct?"));
|
||||
SerialMon.println(F(" Is your modem powered on?"));
|
||||
SerialMon.println(F(" Do you use a good, stable power source?"));
|
||||
SerialMon.println(F(" Try using File -> Examples -> TinyGSM -> tools -> "
|
||||
"AT_Debug to find correct configuration"));
|
||||
SerialMon.println(F("************************"));
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(F(" [OK]"));
|
||||
|
||||
String modemInfo = modem.getModemInfo();
|
||||
SerialMon.print("Modem Info: ");
|
||||
SerialMon.println(modemInfo);
|
||||
|
||||
#if TINY_GSM_USE_GPRS
|
||||
// Unlock your SIM card with a PIN if needed
|
||||
if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); }
|
||||
#endif
|
||||
|
||||
#if TINY_GSM_USE_WIFI
|
||||
// Wifi connection parameters must be set before waiting for the network
|
||||
SerialMon.print(F("Setting SSID/password..."));
|
||||
if (!modem.networkConnect(wifiSSID, wifiPass)) {
|
||||
SerialMon.println(" fail");
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(" success");
|
||||
#endif
|
||||
|
||||
#if TINY_GSM_USE_GPRS && defined TINY_GSM_MODEM_XBEE
|
||||
// The XBee must run the gprsConnect function BEFORE waiting for network!
|
||||
modem.gprsConnect(apn, gprsUser, gprsPass);
|
||||
#endif
|
||||
|
||||
SerialMon.print("Waiting for network...");
|
||||
if (!modem.waitForNetwork(
|
||||
600000L)) { // You may need lengthen this in poor service areas
|
||||
SerialMon.println(F(" [fail]"));
|
||||
SerialMon.println(F("************************"));
|
||||
SerialMon.println(F(" Is your sim card locked?"));
|
||||
SerialMon.println(F(" Do you have a good signal?"));
|
||||
SerialMon.println(F(" Is antenna attached?"));
|
||||
SerialMon.println(F(" Does the SIM card work with your phone?"));
|
||||
SerialMon.println(F("************************"));
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(F(" [OK]"));
|
||||
|
||||
#if TINY_GSM_USE_GPRS
|
||||
// GPRS connection parameters are usually set after network registration
|
||||
SerialMon.print("Connecting to ");
|
||||
SerialMon.print(apn);
|
||||
if (!modem.gprsConnect(apn, gprsUser, gprsPass)) {
|
||||
SerialMon.println(F(" [fail]"));
|
||||
SerialMon.println(F("************************"));
|
||||
SerialMon.println(F(" Is GPRS enabled by network provider?"));
|
||||
SerialMon.println(F(" Try checking your card balance."));
|
||||
SerialMon.println(F("************************"));
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(F(" [OK]"));
|
||||
#endif
|
||||
|
||||
IPAddress local = modem.localIP();
|
||||
SerialMon.print("Local IP: ");
|
||||
SerialMon.println(local);
|
||||
|
||||
SerialMon.print(F("Connecting to "));
|
||||
SerialMon.print(server);
|
||||
if (!client.connect(server, port)) {
|
||||
SerialMon.println(F(" [fail]"));
|
||||
delay(10000);
|
||||
return;
|
||||
}
|
||||
SerialMon.println(F(" [OK]"));
|
||||
|
||||
// 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");
|
||||
|
||||
// Wait for data to arrive
|
||||
while (client.connected() && !client.available()) {
|
||||
delay(100);
|
||||
SerialMon.print('.');
|
||||
};
|
||||
SerialMon.println();
|
||||
|
||||
// Skip all headers
|
||||
client.find("\r\n\r\n");
|
||||
|
||||
// Read data
|
||||
uint32_t timeout = millis();
|
||||
uint32_t bytesReceived = 0;
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
char c = client.read();
|
||||
// SerialMon.print(c);
|
||||
bytesReceived += 1;
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
SerialMon.println(F("Server disconnected"));
|
||||
|
||||
#if TINY_GSM_USE_WIFI
|
||||
modem.networkDisconnect();
|
||||
SerialMon.println(F("WiFi disconnected"));
|
||||
#endif
|
||||
#if TINY_GSM_USE_GPRS
|
||||
modem.gprsDisconnect();
|
||||
SerialMon.println(F("GPRS disconnected"));
|
||||
#endif
|
||||
|
||||
SerialMon.println();
|
||||
SerialMon.println(F("************************"));
|
||||
SerialMon.print(F(" Received: "));
|
||||
SerialMon.print(bytesReceived);
|
||||
SerialMon.println(F(" bytes"));
|
||||
SerialMon.print(F(" Test: "));
|
||||
SerialMon.println((bytesReceived == 121) ? "PASSED" : "FAILED");
|
||||
SerialMon.println(F("************************"));
|
||||
|
||||
// Do nothing forevermore
|
||||
while (true) { delay(1000); }
|
||||
}
|
||||
84
libraries/TinyGSM/tools/FactoryReset/FactoryReset.ino
Normal file
84
libraries/TinyGSM/tools/FactoryReset/FactoryReset.ino
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/**************************************************************
|
||||
*
|
||||
* To run this tool you need StreamDebugger library:
|
||||
* https://github.com/vshymanskyy/StreamDebugger
|
||||
* or from http://librarymanager/all#StreamDebugger
|
||||
*
|
||||
* TinyGSM Getting Started guide:
|
||||
* https://tiny.cc/tinygsm-readme
|
||||
*
|
||||
**************************************************************/
|
||||
|
||||
// Select your modem:
|
||||
#define TINY_GSM_MODEM_SIM800
|
||||
// #define TINY_GSM_MODEM_SIM808
|
||||
// #define TINY_GSM_MODEM_SIM868
|
||||
// #define TINY_GSM_MODEM_SIM900
|
||||
// #define TINY_GSM_MODEM_SIM5360
|
||||
// #define TINY_GSM_MODEM_UBLOX
|
||||
// #define TINY_GSM_MODEM_SARAR4
|
||||
// #define TINY_GSM_MODEM_M95
|
||||
// #define TINY_GSM_MODEM_BG95
|
||||
// #define TINY_GSM_MODEM_BG96
|
||||
// #define TINY_GSM_MODEM_A6
|
||||
// #define TINY_GSM_MODEM_A7
|
||||
// #define TINY_GSM_MODEM_M590
|
||||
// #define TINY_GSM_MODEM_MC60
|
||||
// #define TINY_GSM_MODEM_MC60E
|
||||
// #define TINY_GSM_MODEM_ESP8266
|
||||
// #define TINY_GSM_MODEM_ESP32
|
||||
// #define TINY_GSM_MODEM_XBEE
|
||||
// #define TINY_GSM_MODEM_SEQUANS_MONARCH
|
||||
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
// Set serial for debug console (to the Serial Monitor, speed 115200)
|
||||
#define SerialMon Serial
|
||||
|
||||
// Set serial for AT commands (to the module)
|
||||
// Use Hardware Serial on Mega, Leonardo, Micro
|
||||
#ifndef __AVR_ATmega328P__
|
||||
#define SerialAT Serial1
|
||||
|
||||
// or Software Serial on Uno, Nano
|
||||
#else
|
||||
#include <SoftwareSerial.h>
|
||||
SoftwareSerial SerialAT(2, 3); // RX, TX
|
||||
#endif
|
||||
|
||||
#include <StreamDebugger.h>
|
||||
StreamDebugger debugger(SerialAT, SerialMon);
|
||||
TinyGsm modem(debugger);
|
||||
|
||||
void setup() {
|
||||
// Set console baud rate
|
||||
SerialMon.begin(115200);
|
||||
delay(10);
|
||||
|
||||
// Set GSM module baud rate
|
||||
SerialAT.begin(9600);
|
||||
delay(6000);
|
||||
|
||||
if (!modem.init()) {
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
SerialMon.println(F(" Cannot initialize modem!"));
|
||||
SerialMon.println(
|
||||
F(" Use File -> Examples -> TinyGSM -> tools -> AT_Debug"));
|
||||
SerialMon.println(F(" to find correct configuration"));
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
return;
|
||||
}
|
||||
|
||||
bool ret = modem.factoryDefault();
|
||||
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
SerialMon.print(F(" Return settings to Factory Defaults: "));
|
||||
SerialMon.println((ret) ? "OK" : "FAIL");
|
||||
SerialMon.println(
|
||||
F("***********************************************************"));
|
||||
}
|
||||
|
||||
void loop() {}
|
||||
268
libraries/TinyGSM/tools/test_build/test_build.ino
Normal file
268
libraries/TinyGSM/tools/test_build/test_build.ino
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
/**************************************************************
|
||||
*
|
||||
* DO NOT USE THIS - this is just a compilation test!
|
||||
* This is NOT an example for use of this library!
|
||||
*
|
||||
**************************************************************/
|
||||
#include <TinyGsmClient.h>
|
||||
|
||||
TinyGsm modem(Serial);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
delay(6000);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Test the basic functions
|
||||
modem.begin();
|
||||
modem.begin("1234");
|
||||
modem.init();
|
||||
modem.init("1234");
|
||||
modem.setBaud(115200);
|
||||
modem.testAT();
|
||||
|
||||
modem.getModemInfo();
|
||||
modem.getModemName();
|
||||
modem.getModemManufacturer();
|
||||
modem.getModemModel();
|
||||
modem.getModemRevision();
|
||||
modem.factoryDefault();
|
||||
|
||||
#if not defined(TINY_GSM_MODEM_ESP8266) && not defined(TINY_GSM_MODEM_ESP32)
|
||||
modem.getModemSerialNumber();
|
||||
#endif
|
||||
|
||||
// Test Power functions
|
||||
modem.restart();
|
||||
// modem.sleepEnable(); // Not available for all modems
|
||||
// modem.radioOff(); // Not available for all modems
|
||||
modem.poweroff();
|
||||
// modem.setPhoneFunctionality(1, 1); // Not available for all modems
|
||||
|
||||
// Test generic network functions
|
||||
modem.getRegistrationStatus();
|
||||
modem.isNetworkConnected();
|
||||
modem.waitForNetwork();
|
||||
modem.waitForNetwork(15000L);
|
||||
modem.waitForNetwork(15000L, true);
|
||||
modem.getSignalQuality();
|
||||
modem.getLocalIP();
|
||||
modem.localIP();
|
||||
|
||||
// Test WiFi Functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_WIFI)
|
||||
modem.networkConnect("mySSID", "mySSIDPassword");
|
||||
modem.networkDisconnect();
|
||||
#endif
|
||||
|
||||
// Test the GPRS and SIM card functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_GPRS)
|
||||
modem.simUnlock("1234");
|
||||
modem.getSimStatus();
|
||||
|
||||
modem.gprsConnect("myAPN");
|
||||
modem.gprsConnect("myAPN", "myUser");
|
||||
modem.gprsConnect("myAPN", "myAPNUser", "myAPNPass");
|
||||
modem.gprsDisconnect();
|
||||
|
||||
modem.getSimCCID();
|
||||
modem.getIMEI();
|
||||
modem.getIMSI();
|
||||
modem.getOperator();
|
||||
// modem.getProvider(); // Not available for all modems
|
||||
#endif
|
||||
|
||||
char server[] = "somewhere";
|
||||
char resource[] = "something";
|
||||
|
||||
// Test TCP functions
|
||||
modem.maintain();
|
||||
TinyGsmClient client;
|
||||
TinyGsmClient client2(modem);
|
||||
TinyGsmClient client3(modem, 1);
|
||||
client.init(&modem);
|
||||
client.init(&modem, 1);
|
||||
|
||||
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");
|
||||
|
||||
uint32_t timeout = millis();
|
||||
while (client.connected() && millis() - timeout < 10000L) {
|
||||
while (client.available()) {
|
||||
client.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client.stop();
|
||||
|
||||
#if defined(TINY_GSM_MODEM_HAS_SSL)
|
||||
// modem.addCertificate("certificateName"); // Not available for all modems
|
||||
// modem.addCertificate(
|
||||
// String("certificateName")); // Not available for all modems
|
||||
// modem.addCertificate("certificateName", "certificate_content",
|
||||
// 20); // Not available for all modems
|
||||
// modem.addCertificate(String("certificateName"),
|
||||
// String("certificate_content"),
|
||||
// 20); // Not available for all
|
||||
// modems
|
||||
// modem.deleteCertificate("certificateName"); // Not available for all
|
||||
// modems
|
||||
modem.setCertificate("certificateName", 0);
|
||||
modem.setCertificate(String("certificateName"), 0);
|
||||
TinyGsmClientSecure client_secure(modem);
|
||||
TinyGsmClientSecure client_secure2(modem);
|
||||
TinyGsmClientSecure client_secure3(modem, 1);
|
||||
client_secure.init(&modem);
|
||||
client_secure.init(&modem, 1);
|
||||
|
||||
client_secure.connect(server, 443);
|
||||
|
||||
// Make a HTTP GET request:
|
||||
client_secure.print(String("GET ") + resource + " HTTP/1.0\r\n");
|
||||
client_secure.print(String("Host: ") + server + "\r\n");
|
||||
client_secure.print("Connection: close\r\n\r\n");
|
||||
|
||||
timeout = millis();
|
||||
while (client_secure.connected() && millis() - timeout < 10000L) {
|
||||
while (client_secure.available()) {
|
||||
client_secure.read();
|
||||
timeout = millis();
|
||||
}
|
||||
}
|
||||
|
||||
client_secure.stop();
|
||||
#endif
|
||||
|
||||
// Test the calling functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_CALLING) && not defined(__AVR_ATmega32U4__)
|
||||
modem.callNumber(String("+380000000000"));
|
||||
modem.callHangup();
|
||||
|
||||
#if not defined(TINY_GSM_MODEM_SEQUANS_MONARCH)
|
||||
modem.callAnswer();
|
||||
modem.dtmfSend('A', 1000);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Test the SMS functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_SMS) && not defined(__AVR_ATmega32U4__)
|
||||
modem.sendSMS(String("+380000000000"), String("Hello from "));
|
||||
|
||||
#if not defined(TINY_GSM_MODEM_XBEE) && not defined(TINY_GSM_MODEM_SARAR4)
|
||||
modem.sendUSSD("*111#");
|
||||
#endif
|
||||
|
||||
#if not defined(TINY_GSM_MODEM_XBEE) && not defined(TINY_GSM_MODEM_M590) && \
|
||||
not defined(TINY_GSM_MODEM_SARAR4)
|
||||
modem.sendSMS_UTF16("+380000000000", "Hello", 5);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Test the GSM location functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_GSM_LOCATION) && not defined(__AVR_ATmega32U4__)
|
||||
modem.getGsmLocationRaw();
|
||||
modem.getGsmLocation();
|
||||
float gsm_latitude = 0;
|
||||
float gsm_longitude = 0;
|
||||
float gsm_accuracy = 0;
|
||||
int gsm_year = 0;
|
||||
int gsm_month = 0;
|
||||
int gsm_day = 0;
|
||||
int gsm_hour = 0;
|
||||
int gsm_minute = 0;
|
||||
int gsm_second = 0;
|
||||
modem.getGsmLocation(&gsm_latitude, &gsm_longitude);
|
||||
modem.getGsmLocation(&gsm_latitude, &gsm_longitude, &gsm_accuracy, &gsm_year,
|
||||
&gsm_month, &gsm_day, &gsm_hour, &gsm_minute,
|
||||
&gsm_second);
|
||||
modem.getGsmLocationTime(&gsm_year, &gsm_month, &gsm_day, &gsm_hour,
|
||||
&gsm_minute, &gsm_second);
|
||||
modem.getGsmLocation();
|
||||
#endif
|
||||
|
||||
// Test the GPS functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_GPS) && not defined(__AVR_ATmega32U4__)
|
||||
// modem.setGNSSMode(1, true); // Not available for all modems
|
||||
// modem.getGNSSMode(); // Not available for all modems
|
||||
#if !defined(TINY_GSM_MODEM_SARAR5) // not available for this module
|
||||
modem.enableGPS();
|
||||
#endif
|
||||
float gps_latitude = 0;
|
||||
float gps_longitude = 0;
|
||||
float gps_speed = 0;
|
||||
float gps_altitude = 0;
|
||||
int gps_vsat = 0;
|
||||
int gps_usat = 0;
|
||||
float gps_accuracy = 0;
|
||||
int gps_year = 0;
|
||||
int gps_month = 0;
|
||||
int gps_day = 0;
|
||||
int gps_hour = 0;
|
||||
int gps_minute = 0;
|
||||
int gps_second = 0;
|
||||
modem.getGPS(&gps_latitude, &gps_longitude);
|
||||
modem.getGPS(&gps_latitude, &gps_longitude, &gps_speed, &gps_altitude,
|
||||
&gps_vsat, &gps_usat, &gps_accuracy, &gps_year, &gps_month,
|
||||
&gps_day, &gps_hour, &gps_minute, &gps_second);
|
||||
modem.getGPSraw();
|
||||
#if !defined(TINY_GSM_MODEM_SARAR5) // not available for this module
|
||||
modem.disableGPS();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Test the Network time functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_NTP) && not defined(__AVR_ATmega32U4__)
|
||||
modem.NTPServerSync("pool.ntp.org", 3);
|
||||
// modem.ShowNTPError(1); // Not available for all modems
|
||||
#endif
|
||||
|
||||
// Test the Network time function
|
||||
#if defined(TINY_GSM_MODEM_HAS_TIME) && not defined(__AVR_ATmega32U4__)
|
||||
modem.getGSMDateTime(DATE_FULL);
|
||||
int ntp_year = 0;
|
||||
int ntp_month = 0;
|
||||
int ntp_day = 0;
|
||||
int ntp_hour = 0;
|
||||
int ntp_min = 0;
|
||||
int ntp_sec = 0;
|
||||
float ntp_timezone = 0;
|
||||
modem.getNetworkTime(&ntp_year, &ntp_month, &ntp_day, &ntp_hour, &ntp_min,
|
||||
&ntp_sec, &ntp_timezone);
|
||||
// modem.getNetworkUTCTime(&ntp_year, &ntp_month, &ntp_day, &ntp_hour,
|
||||
// &ntp_min,
|
||||
// &ntp_sec,
|
||||
// &ntp_timezone); // Not available for all modems
|
||||
#endif
|
||||
|
||||
// Test bluetooth functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_BLUETOOTH)
|
||||
modem.enableBluetooth();
|
||||
modem.disableBluetooth();
|
||||
modem.setBluetoothVisibility(true);
|
||||
modem.setBluetoothHostName("bluetooth");
|
||||
#endif
|
||||
|
||||
// Test Battery functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_BATTERY)
|
||||
// modem.getBattVoltage(); // Not available for all modems
|
||||
// modem.getBattPercent(); // Not available for all modems
|
||||
// modem.getBattChargeState(); // Not available for all modems
|
||||
int8_t chargeState = -99;
|
||||
int8_t chargePercent = -99;
|
||||
int16_t milliVolts = -9999;
|
||||
modem.getBattStats(chargeState, chargePercent, milliVolts);
|
||||
#endif
|
||||
|
||||
// Test temperature functions
|
||||
#if defined(TINY_GSM_MODEM_HAS_TEMPERATURE)
|
||||
modem.getTemperature();
|
||||
#endif
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue