Update test build

Signed-off-by: Sara Damiano <sdamiano@stroudcenter.org>
This commit is contained in:
Sara Damiano
2024-05-24 12:05:53 -04:00
parent c1a0c4e3e1
commit 27e14e6292
2 changed files with 168 additions and 112 deletions

View File

@@ -139,7 +139,7 @@ void setup() {
// !!!!!!!!!!!
DBG("Wait...");
delay(6000);
delay(6000L);
// Set GSM module baud rate
TinyGsmAutoBaud(SerialAT, GSM_AUTOBAUD_MIN, GSM_AUTOBAUD_MAX);
@@ -183,7 +183,7 @@ void loop() {
if (GSM_PIN && modem.getSimStatus() != 3) { modem.simUnlock(GSM_PIN); }
#endif
#if TINY_GSM_TEST_WIFI
#if TINY_GSM_TEST_WIFI && defined(TINY_GSM_MODEM_HAS_WIFI)
DBG("Setting SSID/password...");
if (!modem.networkConnect(wifiSSID, wifiPass)) {
DBG(" fail");
@@ -193,7 +193,7 @@ void loop() {
SerialMon.println(" success");
#endif
#if TINY_GSM_TEST_GPRS && defined TINY_GSM_MODEM_XBEE
#if TINY_GSM_TEST_GPRS && defined(TINY_GSM_MODEM_XBEE)
// The XBee must run the gprsConnect function BEFORE waiting for network!
modem.gprsConnect(apn, gprsUser, gprsPass);
#endif
@@ -349,6 +349,7 @@ void loop() {
}
#endif
// Test the SMS functions
#if TINY_GSM_TEST_SMS && defined TINY_GSM_MODEM_HAS_SMS && defined SMS_TARGET
res = modem.sendSMS(SMS_TARGET, String("Hello from ") + imei);
DBG("SMS:", res ? "OK" : "fail");
@@ -365,24 +366,27 @@ void loop() {
#endif
// Test the GSM location functions
#if TINY_GSM_TEST_GSM_LOCATION && defined TINY_GSM_MODEM_HAS_GSM_LOCATION
float lat = 0;
float lon = 0;
float accuracy = 0;
int year = 0;
int month = 0;
int day = 0;
int hour = 0;
int min = 0;
int sec = 0;
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;
for (int8_t i = 15; i; i--) {
DBG("Requesting current GSM location");
if (modem.getGsmLocation(&lat, &lon, &accuracy, &year, &month, &day, &hour,
&min, &sec)) {
DBG("Latitude:", String(lat, 8), "\tLongitude:", String(lon, 8));
DBG("Accuracy:", accuracy);
DBG("Year:", year, "\tMonth:", month, "\tDay:", day);
DBG("Hour:", hour, "\tMinute:", min, "\tSecond:", sec);
if (modem.getGsmLocation(&gsm_latitude, &gsm_longitude, &gsm_accuracy,
&gsm_year, &gsm_month, &gsm_day, &gsm_hour,
&gsm_minute, &gsm_second)) {
DBG("Latitude:", String(gsm_latitude, 8),
"\tLongitude:", String(gsm_longitude, 8));
DBG("Accuracy:", gsm_accuracy);
DBG("Year:", gsm_year, "\tMonth:", gsm_month, "\tDay:", gsm_day);
DBG("Hour:", gsm_hour, "\tMinute:", gsm_minute, "\tSecond:", gsm_second);
break;
} else {
DBG("Couldn't get GSM location, retrying in 15s.");
@@ -394,35 +398,38 @@ void loop() {
DBG("GSM Based Location String:", location);
#endif
// Test the GPS functions
#if TINY_GSM_TEST_GPS && defined TINY_GSM_MODEM_HAS_GPS
DBG("Enabling GPS/GNSS/GLONASS and waiting 15s for warm-up");
#if !defined(TINY_GSM_MODEM_SARAR5)
#if !defined(TINY_GSM_MODEM_SARAR5) // not needed for this module
modem.enableGPS();
#endif
delay(15000L);
float lat2 = 0;
float lon2 = 0;
float speed2 = 0;
float alt2 = 0;
int vsat2 = 0;
int usat2 = 0;
float accuracy2 = 0;
int year2 = 0;
int month2 = 0;
int day2 = 0;
int hour2 = 0;
int min2 = 0;
int sec2 = 0;
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;
for (int8_t i = 15; i; i--) {
DBG("Requesting current GPS/GNSS/GLONASS location");
if (modem.getGPS(&lat2, &lon2, &speed2, &alt2, &vsat2, &usat2, &accuracy2,
&year2, &month2, &day2, &hour2, &min2, &sec2)) {
DBG("Latitude:", String(lat2, 8), "\tLongitude:", String(lon2, 8));
DBG("Speed:", speed2, "\tAltitude:", alt2);
DBG("Visible Satellites:", vsat2, "\tUsed Satellites:", usat2);
DBG("Accuracy:", accuracy2);
DBG("Year:", year2, "\tMonth:", month2, "\tDay:", day2);
DBG("Hour:", hour2, "\tMinute:", min2, "\tSecond:", sec2);
if (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)) {
DBG("Latitude:", String(gps_latitude, 8),
"\tLongitude:", String(gps_longitude, 8));
DBG("Speed:", gps_speed, "\tAltitude:", gps_altitude);
DBG("Visible Satellites:", gps_vsat, "\tUsed Satellites:", gps_usat);
DBG("Accuracy:", gps_accuracy);
DBG("Year:", gps_year, "\tMonth:", gps_month, "\tDay:", gps_day);
DBG("Hour:", gps_hour, "\tMinute:", gps_minute, "\tSecond:", gps_second);
break;
} else {
DBG("Couldn't get GPS/GNSS/GLONASS location, retrying in 15s.");
@@ -431,31 +438,34 @@ void loop() {
}
DBG("Retrieving GPS/GNSS/GLONASS location again as a string");
String gps_raw = modem.getGPSraw();
#if !defined(TINY_GSM_MODEM_SARAR5) // not available for this module
DBG("GPS/GNSS Based Location String:", gps_raw);
DBG("Disabling GPS");
modem.disableGPS();
#endif
#endif
// Test the Network time functions
#if TINY_GSM_TEST_NTP && defined TINY_GSM_MODEM_HAS_NTP
DBG("Asking modem to sync with NTP");
modem.NTPServerSync("132.163.96.5", 20);
modem.NTPServerSync("pool.ntp.org", 20);
#endif
#if TINY_GSM_TEST_TIME && defined TINY_GSM_MODEM_HAS_TIME
int year3 = 0;
int month3 = 0;
int day3 = 0;
int hour3 = 0;
int min3 = 0;
int sec3 = 0;
float timezone = 0;
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;
for (int8_t i = 5; i; i--) {
DBG("Requesting current network time");
if (modem.getNetworkTime(&year3, &month3, &day3, &hour3, &min3, &sec3,
&timezone)) {
DBG("Year:", year3, "\tMonth:", month3, "\tDay:", day3);
DBG("Hour:", hour3, "\tMinute:", min3, "\tSecond:", sec3);
DBG("Timezone:", timezone);
if (modem.getNetworkTime(&ntp_year, &ntp_month, &ntp_day, &ntp_hour,
&ntp_min, &ntp_sec, &ntp_timezone)) {
DBG("Year:", ntp_year, "\tMonth:", ntp_month, "\tDay:", ntp_day);
DBG("Hour:", ntp_hour, "\tMinute:", ntp_min, "\tSecond:", ntp_sec);
DBG("Timezone:", ntp_timezone);
break;
} else {
DBG("Couldn't get network time, retrying in 15s.");
@@ -467,16 +477,18 @@ void loop() {
DBG("Current Network Time:", time);
#endif
// Test Battery functions
#if TINY_GSM_TEST_BATTERY && defined TINY_GSM_MODEM_HAS_BATTERY
uint8_t chargeState = -99;
int8_t percent = -99;
uint16_t milliVolts = -9999;
modem.getBattStats(chargeState, percent, milliVolts);
uint8_t chargeState = -99;
int8_t chargePercent = -99;
uint16_t milliVolts = -9999;
modem.getBattStats(chargeState, chargePercent, milliVolts);
DBG("Battery charge state:", chargeState);
DBG("Battery charge 'percent':", percent);
DBG("Battery charge 'percent':", chargePercent);
DBG("Battery voltage:", milliVolts / 1000.0F);
#endif
// Test temperature functions
#if TINY_GSM_TEST_TEMPERATURE && defined TINY_GSM_MODEM_HAS_TEMPERATURE
float temp = modem.getTemperature();
DBG("Chip temperature:", temp);

View File

@@ -24,13 +24,21 @@ void loop() {
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.radioOff(); // Not available for all modems
modem.poweroff();
// modem.setPhoneFunctionality(1, 1); // Not available for all modems
// Test generic network functions
modem.getRegistrationStatus();
@@ -42,25 +50,27 @@ void loop() {
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.getSimCCID();
modem.getIMEI();
modem.getIMSI();
modem.getSimStatus();
modem.gprsConnect("myAPN");
modem.gprsConnect("myAPN", "myUser");
modem.gprsConnect("myAPN", "myAPNUser", "myAPNPass");
modem.gprsDisconnect();
modem.getOperator();
#endif
// Test WiFi Functions
#if defined(TINY_GSM_MODEM_HAS_WIFI)
modem.networkConnect("mySSID", "mySSIDPassword");
modem.networkDisconnect();
modem.getSimCCID();
modem.getIMEI();
modem.getIMSI();
modem.getOperator();
// modem.getProvider(); // Not available for all modems
#endif
char server[] = "somewhere";
@@ -92,8 +102,19 @@ void loop() {
client.stop();
#if defined(TINY_GSM_MODEM_HAS_SSL)
// modem.addCertificate(); // not yet impemented
// modem.deleteCertificate(); // not yet impemented
// 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);
@@ -149,75 +170,98 @@ void loop() {
#if defined(TINY_GSM_MODEM_HAS_GSM_LOCATION) && not defined(__AVR_ATmega32U4__)
modem.getGsmLocationRaw();
modem.getGsmLocation();
float glatitude = -9999;
float glongitude = -9999;
float gacc = 0;
int gyear = 0;
int gmonth = 0;
int gday = 0;
int ghour = 0;
int gmin = 0;
int gsec = 0;
modem.getGsmLocation(&glatitude, &glongitude);
modem.getGsmLocation(&glatitude, &glongitude, &gacc, &gyear, &gmonth, &gday,
&ghour, &gmin, &gsec);
modem.getGsmLocationTime(&gyear, &gmonth, &gday, &ghour, &gmin, &gsec);
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();
float latitude = -9999;
float longitude = -9999;
float speed = 0;
float alt = 0;
int vsat = 0;
int usat = 0;
float acc = 0;
int year = 0;
int month = 0;
int day = 0;
int hour = 0;
int minute = 0;
int second = 0;
modem.getGPS(&latitude, &longitude);
modem.getGPS(&latitude, &longitude, &speed, &alt, &vsat, &usat, &acc, &year,
&month, &day, &hour, &minute, &second);
#if !defined(TINY_GSM_MODEM_SARAR5) // not available for this module
modem.disableGPS();
#endif
#endif
// Test the Network time function
// 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 year3 = 0;
int month3 = 0;
int day3 = 0;
int hour3 = 0;
int min3 = 0;
int sec3 = 0;
float timezone = 0;
modem.getNetworkTime(&year3, &month3, &day3, &hour3, &min3, &sec3, &timezone);
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)
uint8_t chargeState = 0;
int8_t chargePercent = 0;
uint16_t milliVolts = 0;
// modem.getBattVoltage(); // Not available for all modems
// modem.getBattPercent(); // Not available for all modems
// modem.getBattChargeState(); // Not available for all modems
uint8_t chargeState = -99;
int8_t chargePercent = -99;
uint16_t milliVolts = -9999;
modem.getBattStats(chargeState, chargePercent, milliVolts);
#endif
// Test the temperature function
// Test temperature functions
#if defined(TINY_GSM_MODEM_HAS_TEMPERATURE)
modem.getTemperature();
#endif