From c279769bc1a35ee23075a177ba45e1c7b24eb9bc Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Mon, 28 Oct 2019 11:30:35 -0600 Subject: [PATCH 1/4] Add note to example --- examples/01_SMS_Send/01_SMS_Send.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/01_SMS_Send/01_SMS_Send.ino b/examples/01_SMS_Send/01_SMS_Send.ino index 46b0df2..4cfb382 100644 --- a/examples/01_SMS_Send/01_SMS_Send.ino +++ b/examples/01_SMS_Send/01_SMS_Send.ino @@ -35,7 +35,7 @@ SoftwareSerial lteSerial(8, 9); LTE_Shield lte; // Set the cell phone number to be texted -String DESTINATION_NUMBER = "11234567890"; +String DESTINATION_NUMBER = "11234567890"; //This is the full cell # including country code void setup() { Serial.begin(9600); @@ -64,4 +64,4 @@ void loop() { message += c; // Add last character to message } } -} \ No newline at end of file +} From d100cc9fc8f079f6564717fa9ba2df7028ec49e3 Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Mon, 28 Oct 2019 12:06:04 -0600 Subject: [PATCH 2/4] Add debug method and messages. --- keywords.txt | 4 +++ src/SparkFun_LTE_Shield_Arduino_Library.cpp | 36 ++++++++++++++++++++- src/SparkFun_LTE_Shield_Arduino_Library.h | 8 +++++ 3 files changed, 47 insertions(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 1f423de..6e9fd0e 100644 --- a/keywords.txt +++ b/keywords.txt @@ -107,6 +107,10 @@ gpsGetRmc KEYWORD2 gpsEnableSpeed KEYWORD2 gpsGetSpeed KEYWORD2 gpsRequest KEYWORD2 +enableDebugging KEYWORD2 +disableDebugging KEYWORD2 +debug KEYWORD2 +debugln KEYWORD2 ####################################### # Constants LITERAL1 diff --git a/src/SparkFun_LTE_Shield_Arduino_Library.cpp b/src/SparkFun_LTE_Shield_Arduino_Library.cpp index c570076..21f21f2 100644 --- a/src/SparkFun_LTE_Shield_Arduino_Library.cpp +++ b/src/SparkFun_LTE_Shield_Arduino_Library.cpp @@ -1564,10 +1564,13 @@ LTE_Shield_error_t LTE_Shield::init(unsigned long baud, { LTE_Shield_error_t err; + debugln(F("Begin module init.")); + beginSerial(baud); // Begin serial if (initType == LTE_SHIELD_INIT_AUTOBAUD) { + debugln(F("Attempting autobaud connection to module.")); if (autobaud(baud) != LTE_SHIELD_ERROR_SUCCESS) { return init(baud, LTE_SHIELD_INIT_RESET); @@ -1575,7 +1578,9 @@ LTE_Shield_error_t LTE_Shield::init(unsigned long baud, } else if (initType == LTE_SHIELD_INIT_RESET) { + debugln(F("Power cycling module.")); powerOn(); + delay(1000); if (at() != LTE_SHIELD_ERROR_SUCCESS) { return init(baud, LTE_SHIELD_INIT_AUTOBAUD); @@ -1586,7 +1591,12 @@ LTE_Shield_error_t LTE_Shield::init(unsigned long baud, err = enableEcho(false); if (err != LTE_SHIELD_ERROR_SUCCESS) + { + debugln(F("Module failed echo test.")); return init(baud, LTE_SHIELD_INIT_AUTOBAUD); + } + + debugln(F("Module responded successfully.")); _baud = baud; setGpioMode(GPIO1, NETWORK_STATUS); @@ -1607,6 +1617,8 @@ void LTE_Shield::powerOn(void) digitalWrite(_powerPin, LOW); delay(LTE_SHIELD_POWER_PULSE_PERIOD); pinMode(_powerPin, INPUT); // Return to high-impedance, rely on SARA module internal pull-up + delay(2000); //Wait before sending AT commands to module. 100 is too short. + debugln("Power cycle complete"); } void LTE_Shield::hwReset(void) @@ -2056,6 +2068,28 @@ char *LTE_Shield::lte_calloc_char(size_t num) return (char *)calloc(num, sizeof(char)); } +//Enable or disable the printing of extra debug statements +void LTE_Shield::enableDebugging(Stream &debugPort) +{ + _debugSerial = &debugPort; //Grab which port the user wants us to use for debugging + + _printDebug = true; //Should we print the commands we send? Good for debugging +} +void LTE_Shield::disableDebugging(void) +{ + _printDebug = false; //Turn off extra print statements +} +void LTE_Shield::debug(String toPrint) +{ + if (_printDebug) + _debugSerial->print(toPrint); +} +void LTE_Shield::debugln(String toPrint) +{ + if (_printDebug) + _debugSerial->println(toPrint); +} + // GPS Helper Functions: // Read a source string until a delimiter is hit, store the result in destination @@ -2255,4 +2289,4 @@ static boolean parseGPRMCString(char *rmcString, PositionData *pos, return true; } return false; -} \ No newline at end of file +} diff --git a/src/SparkFun_LTE_Shield_Arduino_Library.h b/src/SparkFun_LTE_Shield_Arduino_Library.h index 8d6b6d4..6dc48fe 100644 --- a/src/SparkFun_LTE_Shield_Arduino_Library.h +++ b/src/SparkFun_LTE_Shield_Arduino_Library.h @@ -319,6 +319,11 @@ class LTE_Shield : public Print LTE_Shield_error_t gpsRequest(unsigned int timeout, uint32_t accuracy, boolean detailed = true); + void enableDebugging(Stream &debugPort = Serial); //Turn on command sending and response printing. If user doesn't specify then Serial will be used + void disableDebugging(void); + void debug(String toPrint); + void debugln(String toPrint); + private: HardwareSerial *_hardSerial; #ifdef LTE_SHIELD_SOFTWARE_SERIAL_ENABLED @@ -331,6 +336,9 @@ class LTE_Shield : public Print IPAddress _lastRemoteIP; IPAddress _lastLocalIP; + bool _printDebug = false; + Stream *_debugSerial; + void (*_socketReadCallback)(int, String); void (*_socketCloseCallback)(int); void (*_gpsRequestCallback)(ClockData, PositionData, SpeedData, unsigned long); From 4365c7984c96be08a740c33aaf18bf4aca7c60ea Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Tue, 29 Oct 2019 09:50:20 -0600 Subject: [PATCH 3/4] Add max initialize value to prevent infinite failed init attempts. --- src/SparkFun_LTE_Shield_Arduino_Library.cpp | 12 ++++++++++-- src/SparkFun_LTE_Shield_Arduino_Library.h | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/SparkFun_LTE_Shield_Arduino_Library.cpp b/src/SparkFun_LTE_Shield_Arduino_Library.cpp index 21f21f2..5e71835 100644 --- a/src/SparkFun_LTE_Shield_Arduino_Library.cpp +++ b/src/SparkFun_LTE_Shield_Arduino_Library.cpp @@ -100,7 +100,7 @@ char lteShieldRXBuffer[128]; static boolean parseGPRMCString(char *rmcString, PositionData *pos, ClockData *clk, SpeedData *spd); -LTE_Shield::LTE_Shield(uint8_t powerPin, uint8_t resetPin) +LTE_Shield::LTE_Shield(uint8_t powerPin, uint8_t resetPin, uint8_t maxInitDepth) { #ifdef LTE_SHIELD_SOFTWARE_SERIAL_ENABLED _softSerial = NULL; @@ -109,6 +109,7 @@ LTE_Shield::LTE_Shield(uint8_t powerPin, uint8_t resetPin) _baud = 0; _resetPin = resetPin; _powerPin = powerPin; + _maxInitDepth = maxInitDepth; _socketReadCallback = NULL; _socketCloseCallback = NULL; _lastRemoteIP = {0, 0, 0, 0}; @@ -1564,6 +1565,14 @@ LTE_Shield_error_t LTE_Shield::init(unsigned long baud, { LTE_Shield_error_t err; + //If we have recursively called init too many times, bail + _currentInitDepth++; + if (_currentInitDepth == _maxInitDepth) + { + debugln(F("Module failed to init. Exiting.")); + return (LTE_SHIELD_ERROR_NO_RESPONSE); + } + debugln(F("Begin module init.")); beginSerial(baud); // Begin serial @@ -1580,7 +1589,6 @@ LTE_Shield_error_t LTE_Shield::init(unsigned long baud, { debugln(F("Power cycling module.")); powerOn(); - delay(1000); if (at() != LTE_SHIELD_ERROR_SUCCESS) { return init(baud, LTE_SHIELD_INIT_AUTOBAUD); diff --git a/src/SparkFun_LTE_Shield_Arduino_Library.h b/src/SparkFun_LTE_Shield_Arduino_Library.h index 6dc48fe..3bf5a4a 100644 --- a/src/SparkFun_LTE_Shield_Arduino_Library.h +++ b/src/SparkFun_LTE_Shield_Arduino_Library.h @@ -165,7 +165,7 @@ class LTE_Shield : public Print { public: // Constructor - LTE_Shield(uint8_t powerPin = LTE_SHIELD_POWER_PIN, uint8_t resetPin = LTE_SHIELD_RESET_PIN); + LTE_Shield(uint8_t powerPin = LTE_SHIELD_POWER_PIN, uint8_t resetPin = LTE_SHIELD_RESET_PIN, uint8_t maxInitDepth = 9); // Begin -- initialize BT module and ensure it's connected #ifdef LTE_SHIELD_SOFTWARE_SERIAL_ENABLED @@ -338,6 +338,8 @@ class LTE_Shield : public Print bool _printDebug = false; Stream *_debugSerial; + uint8_t _maxInitDepth; + uint8_t _currentInitDepth = 0; void (*_socketReadCallback)(int, String); void (*_socketCloseCallback)(int); From ae6068baa3f6395158b3c68c21bc4f4ef1c9a9ce Mon Sep 17 00:00:00 2001 From: Nathan Seidle Date: Thu, 31 Oct 2019 13:15:11 -0600 Subject: [PATCH 4/4] Add response printing to debug output --- src/SparkFun_LTE_Shield_Arduino_Library.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/SparkFun_LTE_Shield_Arduino_Library.cpp b/src/SparkFun_LTE_Shield_Arduino_Library.cpp index 5e71835..af1aeec 100644 --- a/src/SparkFun_LTE_Shield_Arduino_Library.cpp +++ b/src/SparkFun_LTE_Shield_Arduino_Library.cpp @@ -1794,7 +1794,8 @@ LTE_Shield_error_t LTE_Shield::sendCommandWithResponse( if (hwAvailable()) { char c = readChar(); - //Serial.write(c); + debug((String)c); + if (responseDest != NULL) { responseDest[destIndex++] = c; pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy