Many sub templates to inherit from!

This commit is contained in:
Sara Damiano
2020-02-11 16:03:44 -05:00
parent 9ec9111f32
commit be81985c83
33 changed files with 1976 additions and 2291 deletions

View File

@@ -3,15 +3,13 @@
* DO NOT USE THIS - this is just a compilation test!
*
**************************************************************/
#define TINY_GSM_MODEM_SIM800
#include <TinyGsmClient.h>
TinyGsm modem(Serial);
TinyGsmClient client(modem);
#if defined(TINY_GSM_MODEM_HAS_SSL)
TinyGsmClientSecure client_secure(modem);
TinyGsmClientSecure client_secure(modem);
#endif
char server[] = "somewhere";
@@ -23,7 +21,6 @@ void setup() {
}
void loop() {
// Test the basic functions
// modem.init();
modem.begin();
@@ -33,9 +30,6 @@ void loop() {
modem.getModemInfo();
modem.getModemName();
modem.maintain();
modem.hasSSL();
modem.hasWifi();
modem.hasGPRS();
// Test Power functions
modem.restart();
@@ -43,27 +37,78 @@ void loop() {
modem.radioOff();
modem.poweroff();
// Test the SIM card functions
#if defined(TINY_GSM_MODEM_HAS_GPRS)
// Test the SIM card functions
#if defined(TINY_GSM_MODEM_HAS_GPRS)
modem.getSimCCID();
modem.getIMEI();
modem.getSimStatus();
modem.getOperator();
#endif
#endif
// Test the calling functions
#if defined(TINY_GSM_MODEM_HAS_CALLING)
modem.callNumber(String("+380000000000"));
modem.callAnswer();
modem.callHangup();
#endif
// Test the SMS functions
#if defined(TINY_GSM_MODEM_HAS_SMS)
modem.sendUSSD("*111#");
modem.sendSMS(String("+380000000000"), String("Hello from "));
modem.sendSMS_UTF16("+380000000000", "Hello", 5);
#endif
// Test the GSM location functions
#if defined(TINY_GSM_MODEM_HAS_GSM_LOCATION)
modem.getGsmLocation();
#endif
// Test the Network time function
#if defined(TINY_GSM_MODEM_HAS_TIME)
modem.getGSMDateTime(DATE_FULL);
#endif
// Test the Network time function
#if defined(TINY_GSM_MODEM_HAS_TIME)
modem.getGSMDateTime(DATE_FULL);
#endif
// Test the GPS functions
#if defined(TINY_GSM_MODEM_HAS_GPS)
modem.enableGPS();
modem.getGPSraw();
float latitude = -9999;
float longitude = -9999;
modem.getGPS(&latitude, &longitude);
#endif
// Test Battery functions
#if defined(TINY_GSM_MODEM_HAS_BATTERY)
uint8_t chargeState = 0;
int8_t chargePercent = 0;
uint16_t milliVolts = 0;
modem.getBattStats(chargeState, chargePercent, milliVolts);
#endif
// Test the temperature function
#if defined(TINY_GSM_MODEM_HAS_TEMPERATURE)
modem.getTemperature();
#endif
// Test the Networking functions
modem.getRegistrationStatus();
modem.getSignalQuality();
modem.localIP();
#if defined(TINY_GSM_MODEM_HAS_GPRS)
modem.waitForNetwork();
modem.gprsConnect("YourAPN", "", "");
#endif
#if defined(TINY_GSM_MODEM_HAS_WIFI)
modem.networkConnect("YourSSID", "YourWiFiPass");
modem.waitForNetwork();
#endif
#if defined(TINY_GSM_MODEM_HAS_GPRS)
modem.waitForNetwork();
modem.gprsConnect("YourAPN", "", "");
#endif
#if defined(TINY_GSM_MODEM_HAS_WIFI)
modem.networkConnect("YourSSID", "YourWiFiPass");
modem.waitForNetwork();
#endif
client.connect(server, 80);
@@ -82,12 +127,31 @@ void loop() {
client.stop();
#if defined(TINY_GSM_MODEM_HAS_GPRS)
modem.gprsDisconnect();
#endif
#if defined(TINY_GSM_MODEM_HAS_WIFI)
modem.networkDisconnect();
#endif
#if defined(TINY_GSM_MODEM_HAS_SSL)
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
#if defined(TINY_GSM_MODEM_HAS_GPRS)
modem.gprsDisconnect();
#endif
#if defined(TINY_GSM_MODEM_HAS_WIFI)
modem.networkDisconnect();
#endif
// Test battery and temperature functions
// modem.getBattVoltage();