diff --git a/IridiumSBD.cpp b/IridiumSBD.cpp index 1a434cf..9ecccea 100644 --- a/IridiumSBD.cpp +++ b/IridiumSBD.cpp @@ -376,22 +376,22 @@ int IridiumSBD::internalGetSignalQuality(int &quality) int IridiumSBD::internalMSSTMWorkaround(bool &okToProceed) { /* - According to Iridium 9602 Product Bulletin of 7 May 2013, to overcome a system erratum: + According to Iridium 9602 Product Bulletin of 7 May 2013, to overcome a system erratum: - "Before attempting any of the following commands: +SBDDET, +SBDREG, +SBDI, +SBDIX, +SBDIXA the field application - should issue the AT command –MSSTM to the transceiver and evaluate the response to determine if it is valid or not: + "Before attempting any of the following commands: +SBDDET, +SBDREG, +SBDI, +SBDIX, +SBDIXA the field application + should issue the AT command –MSSTM to the transceiver and evaluate the response to determine if it is valid or not: - Valid Response: "---MSSTM: XXXXXXXX" where XXXXXXXX is an eight---digit hexadecimal number. + Valid Response: "---MSSTM: XXXXXXXX" where XXXXXXXX is an eight---digit hexadecimal number. - Invalid Response: "---MSSTM: no network service" + Invalid Response: "---MSSTM: no network service" - If the response is invalid, the field application should wait and recheck system time until a valid response is - obtained before proceeding. + If the response is invalid, the field application should wait and recheck system time until a valid response is + obtained before proceeding. - This will ensure that the Iridium SBD transceiver has received a valid system time before attempting SBD communication. - The Iridium SBD transceiver will receive the valid system time from the Iridium network when it has a good link to the - satellite. Ensuring that the received signal strength reported in response to AT command +CSQ and +CIER is above 2---3 bars - before attempting SBD communication will protect against lockout. + This will ensure that the Iridium SBD transceiver has received a valid system time before attempting SBD communication. + The Iridium SBD transceiver will receive the valid system time from the Iridium network when it has a good link to the + satellite. Ensuring that the received signal strength reported in response to AT command +CSQ and +CIER is above 2---3 bars + before attempting SBD communication will protect against lockout. */ char msstmResponseBuf[24]; @@ -660,7 +660,7 @@ int IridiumSBD::doSBDRB(uint8_t *rxBuffer, size_t *prxBufferSize) void IridiumSBD::power(bool on) { static unsigned long lastPowerOnTime = 0UL; - + if (this->sleepPin == -1) return; diff --git a/IridiumSBD.h b/IridiumSBD.h index 69dd1ed..3021bc1 100644 --- a/IridiumSBD.h +++ b/IridiumSBD.h @@ -58,96 +58,96 @@ typedef const __FlashStringHelper *FlashString; class IridiumSBD { public: - int begin(); - int sendSBDText(const char *message); - int sendSBDBinary(const uint8_t *txData, size_t txDataSize); - int sendReceiveSBDText(const char *message, uint8_t *rxBuffer, size_t &rxBufferSize); - int sendReceiveSBDBinary(const uint8_t *txData, size_t txDataSize, uint8_t *rxBuffer, size_t &rxBufferSize); - int getSignalQuality(int &quality); - - int getWaitingMessageCount(); - int sleep(); - bool isAsleep(); - - void setPowerProfile(int profile); // 0 = direct connect (default), 1 = USB - void adjustATTimeout(int seconds); // default value = 20 seconds - void adjustSendReceiveTimeout(int seconds); // default value = 300 seconds + int begin(); + int sendSBDText(const char *message); + int sendSBDBinary(const uint8_t *txData, size_t txDataSize); + int sendReceiveSBDText(const char *message, uint8_t *rxBuffer, size_t &rxBufferSize); + int sendReceiveSBDBinary(const uint8_t *txData, size_t txDataSize, uint8_t *rxBuffer, size_t &rxBufferSize); + int getSignalQuality(int &quality); + + int getWaitingMessageCount(); + int sleep(); + bool isAsleep(); + + void setPowerProfile(int profile); // 0 = direct connect (default), 1 = USB + void adjustATTimeout(int seconds); // default value = 20 seconds + void adjustSendReceiveTimeout(int seconds); // default value = 300 seconds void setMinimumSignalQuality(int quality); // a number between 1 and 5, default ISBD_DEFAULT_CSQ_MINIMUM void useMSSTMWorkaround(bool useWorkAround); // true to use workaround from Iridium Alert 5/7 - void attachConsole(Stream &stream); + void attachConsole(Stream &stream); #if ISBD_DIAGS - void attachDiags(Stream &stream); + void attachDiags(Stream &stream); #endif - IridiumSBD(Stream &str, int sleepPinNo = -1) : - stream(str), - pConsoleStream(NULL), + IridiumSBD(Stream &str, int sleepPinNo = -1) : + stream(str), + pConsoleStream(NULL), #if ISBD_DIAGS - pDiagsStream(NULL), + pDiagsStream(NULL), #endif - csqInterval(ISBD_DEFAULT_CSQ_INTERVAL), - sbdixInterval(ISBD_DEFAULT_SBDIX_INTERVAL), - atTimeout(ISBD_DEFAULT_AT_TIMEOUT), - sendReceiveTimeout(ISBD_DEFAULT_SENDRECEIVE_TIME), - remainingMessages(-1), - asleep(true), - reentrant(false), - sleepPin(sleepPinNo), + csqInterval(ISBD_DEFAULT_CSQ_INTERVAL), + sbdixInterval(ISBD_DEFAULT_SBDIX_INTERVAL), + atTimeout(ISBD_DEFAULT_AT_TIMEOUT), + sendReceiveTimeout(ISBD_DEFAULT_SENDRECEIVE_TIME), + remainingMessages(-1), + asleep(true), + reentrant(false), + sleepPin(sleepPinNo), minimumCSQ(ISBD_DEFAULT_CSQ_MINIMUM), useWorkaround(true) - { - pinMode(sleepPin, OUTPUT); - } + { + pinMode(sleepPin, OUTPUT); + } private: - Stream &stream; - Stream *pConsoleStream; + Stream &stream; + Stream *pConsoleStream; #if ISBD_DIAGS - Stream *pDiagsStream; + Stream *pDiagsStream; #endif - // Timings - int csqInterval; - int sbdixInterval; - int atTimeout; - int sendReceiveTimeout; - - // State variables - int remainingMessages; - bool asleep; - bool reentrant; - int sleepPin; + // Timings + int csqInterval; + int sbdixInterval; + int atTimeout; + int sendReceiveTimeout; + + // State variables + int remainingMessages; + bool asleep; + bool reentrant; + int sleepPin; int minimumCSQ; bool useWorkaround; - // Internal utilities - bool smartWait(int seconds); - bool waitForATResponse(char *response=NULL, int responseSize=0, const char *prompt=NULL, const char *terminator="OK\r\n"); + // Internal utilities + bool smartWait(int seconds); + bool waitForATResponse(char *response=NULL, int responseSize=0, const char *prompt=NULL, const char *terminator="OK\r\n"); - int internalBegin(); - int internalSendReceiveSBD(const char *txTxtMessage, const uint8_t *txData, size_t txDataSize, uint8_t *rxBuffer, size_t *prxBufferSize); - int internalGetSignalQuality(int &quality); + int internalBegin(); + int internalSendReceiveSBD(const char *txTxtMessage, const uint8_t *txData, size_t txDataSize, uint8_t *rxBuffer, size_t *prxBufferSize); + int internalGetSignalQuality(int &quality); int internalMSSTMWorkaround(bool &okToProceed); - int internalSleep(); + int internalSleep(); int doSBDIX(uint16_t &moCode, uint16_t &moMSN, uint16_t &mtCode, uint16_t &mtMSN, uint16_t &mtLen, uint16_t &mtRemaining); - int doSBDRB(uint8_t *rxBuffer, size_t *prxBufferSize); // in/out - void power(bool on); + int doSBDRB(uint8_t *rxBuffer, size_t *prxBufferSize); // in/out + void power(bool on); - void send(FlashString str, bool beginLine = true, bool endLine = true); - void send(const char *str); - void send(uint16_t n); + void send(FlashString str, bool beginLine = true, bool endLine = true); + void send(const char *str); + void send(uint16_t n); - bool cancelled(); + bool cancelled(); - void dbg(FlashString str); - void dbg(const char *str); - void dbg(uint16_t n); - void dbg(char c); + void dbg(FlashString str); + void dbg(const char *str); + void dbg(uint16_t n); + void dbg(char c); void console(FlashString str); - void console(const char *str); + void console(const char *str); void console(uint16_t n); - void console(char c); + void console(char c); }; diff --git a/examples/Beacon/Beacon.ino b/examples/Beacon/Beacon.ino index a7bff59..b7b943a 100644 --- a/examples/Beacon/Beacon.ino +++ b/examples/Beacon/Beacon.ino @@ -90,17 +90,17 @@ void loop() if (fixFound) { sprintf(outBuffer, "%d%02d%02d%02d%02d%02d,", year, month, day, hour, minute, second); - int len = strlen(outBuffer); + int len = strlen(outBuffer); PString str(outBuffer + len, sizeof(outBuffer) - len); str.print(latitude, 6); str.print(","); str.print(longitude, 6); - str.print(","); - str.print(altitude / 100); - str.print(","); - str.print(tinygps.f_speed_knots(), 1); - str.print(","); - str.print(tinygps.course() / 100); + str.print(","); + str.print(altitude / 100); + str.print(","); + str.print(tinygps.f_speed_knots(), 1); + str.print(","); + str.print(tinygps.course() / 100); } else diff --git a/examples/SendReceive/SendReceive.ino b/examples/SendReceive/SendReceive.ino index c69a7a4..70824db 100644 --- a/examples/SendReceive/SendReceive.ino +++ b/examples/SendReceive/SendReceive.ino @@ -11,8 +11,8 @@ void setup() Serial.begin(115200); nss.begin(19200); -// isbd.attachConsole(Serial); -// isbd.attachDiags(Serial); + isbd.attachConsole(Serial); + isbd.attachDiags(Serial); isbd.begin();