Skip to content
This repository has been archived by the owner on Aug 30, 2022. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulZC committed Mar 15, 2020
2 parents 2d9861a + 018c057 commit d4f97b5
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 30 deletions.
51 changes: 24 additions & 27 deletions src/IridiumSBD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <time.h>
#include "IridiumSBD.h"


bool ISBDCallback() __attribute__((weak));
void ISBDConsoleCallback(IridiumSBD *device, char c) __attribute__((weak));
void ISBDDiagsCallback(IridiumSBD *device, char c) __attribute__((weak));
Expand Down Expand Up @@ -155,7 +156,7 @@ void IridiumSBD::setPowerProfile(POWERPROFILE profile) // 0 = direct connect (de
}
}

// Tweak AT timeout
// Tweak AT timeout
void IridiumSBD::adjustATTimeout(int seconds)
{
this->atTimeout = seconds;
Expand All @@ -167,7 +168,7 @@ void IridiumSBD::adjustSendReceiveTimeout(int seconds)
this->sendReceiveTimeout = seconds;
}

void IridiumSBD::useMSSTMWorkaround(bool useWorkAround) // true to use workaround from Iridium Alert 5/7
void IridiumSBD::useMSSTMWorkaround(bool useWorkAround) // true to use workaround from Iridium Alert 5/7
{
this->msstmWorkaroundRequested = useWorkAround;
}
Expand Down Expand Up @@ -215,9 +216,9 @@ bool IridiumSBD::hasRingAsserted()
{
ret = true; // Return true
//diagprint(F("ringPin seen!\r\n"));
}
}
}

return ret;
}

Expand All @@ -244,7 +245,7 @@ int IridiumSBD::getSystemTime(struct tm &tm)
unsigned long ticks_since_epoch = strtoul(msstmResponseBuf, NULL, 16);

/* Strategy: we'll convert to seconds by finding the largest number of integral
seconds less than the equivalent ticks_since_epoch. Subtract that away and
seconds less than the equivalent ticks_since_epoch. Subtract that away and
we'll be left with a small number that won't overflow when we scale by 90/1000.
Many thanks to Scott Weldon for this suggestion.
Expand Down Expand Up @@ -463,7 +464,7 @@ boolean IridiumSBD::isConnected()
return true;
}
else
{
{
wireport->beginTransmission((uint8_t)deviceaddress);
return (wireport->endTransmission() == 0); // Check that the device ack's
}
Expand Down Expand Up @@ -553,23 +554,23 @@ int IridiumSBD::internalBegin()
}

// The usual initialization sequence
FlashString strings[3] = { F("ATE1\r"), F("AT&D0\r"), F("AT&K0\r") };
const char *strings[3] = { "ATE1\r", "AT&D0\r", "AT&K0\r" };
for (int i=0; i<3; ++i)
{
send(strings[i]);
send(strings[i]);
if (!waitForATResponse())
return cancelled() ? ISBD_CANCELLED : ISBD_PROTOCOL_ERROR;
}

// Enable or disable RING alerts as requested by user
// By default they are on if a RING pin was supplied on constructor
diagprint(F("Ring alerts are")); diagprint(ringAlertsEnabled ? F("") : F(" NOT")); diagprint(F(" enabled.\r\n"));

if (ringAlertsEnabled) enableRingAlerts(true); // This will clear ringAsserted and the Ring Indicator flag
else {
if (!this->useSerial) clearRingIndicator(); // If ring alerts are not enabled and using I2C, make sure the Ring Indicator flag is clear
}

send(ringAlertsEnabled ? F("AT+SBDMTA=1\r") : F("AT+SBDMTA=0\r"));
if (!waitForATResponse())
return cancelled() ? ISBD_CANCELLED : ISBD_PROTOCOL_ERROR;
Expand Down Expand Up @@ -601,7 +602,7 @@ int IridiumSBD::internalBegin()

int IridiumSBD::internalSendReceiveSBD(const char *txTxtMessage, const uint8_t *txData, size_t txDataSize, uint8_t *rxBuffer, size_t *prxBufferSize)
{
diagprint(F("internalSendReceive\r\n"));
diagprint(F("internalSendReceive\r\n"));

if (this->asleep)
return ISBD_IS_ASLEEP;
Expand Down Expand Up @@ -748,7 +749,7 @@ int IridiumSBD::internalSendReceiveSBD(const char *txTxtMessage, const uint8_t *
else
{
// No data returned
if (prxBufferSize)
if (prxBufferSize)
*prxBufferSize = 0;
}
return ISBD_SUCCESS;
Expand Down Expand Up @@ -805,19 +806,19 @@ int IridiumSBD::internalMSSTMWorkaround(bool &okToProceed)
/*
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
"Before attempting any of the following commands: +SBDDET, +SBDREG, +SBDI, +SBDIX, +SBDIXA the field application
should issue the AT command AT-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.
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
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];
Expand Down Expand Up @@ -942,10 +943,7 @@ bool IridiumSBD::cancelled()
}
}

if (ISBDCallback != NULL)
return !ISBDCallback();

return false;
return !ISBDCallback();
}

int IridiumSBD::doSBDIX(uint16_t &moCode, uint16_t &moMSN, uint16_t &mtCode, uint16_t &mtMSN, uint16_t &mtLen, uint16_t &mtRemaining)
Expand Down Expand Up @@ -1075,7 +1073,7 @@ int IridiumSBD::doSBDRB(uint8_t *rxBuffer, size_t *prxBufferSize)
consoleprint(F("]"));

// Return actual size of returned buffer
if (prxBufferSize)
if (prxBufferSize)
*prxBufferSize = (size_t)size;

// Wait for final OK
Expand Down Expand Up @@ -1265,7 +1263,7 @@ void IridiumSBD::diagprint(uint16_t n)
void IridiumSBD::consoleprint(FlashString str)
{
PGM_P p = reinterpret_cast<PGM_P>(str);
while (1)
while (1)
{
char c = pgm_read_byte(p++);
if (c == 0) break;
Expand Down Expand Up @@ -1425,7 +1423,7 @@ void IridiumSBD::check9603data()
i2cSerPoke(wireport->read()); // Read and store each byte
}
}

lastCheck = millis(); //Put off checking to avoid excessive I2C bus traffic
}
}
Expand Down Expand Up @@ -1485,7 +1483,7 @@ int IridiumSBD::internalPassThruI2Cread(uint8_t *rxBuffer, size_t &rxBufferSize,
}

numBytes = (size_t)bytesAvailable; //Store bytesAvailable in numBytes

size_t bufferPtr = 0; // Initialise buffer pointer

//Now read the serial bytes (if any)
Expand Down Expand Up @@ -1649,4 +1647,3 @@ int IridiumSBD::internalGetIMEI(char *IMEI, size_t bufferSize)

return ISBD_SUCCESS;
}

6 changes: 3 additions & 3 deletions src/IridiumSBD.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class IridiumSBD
unsigned long lastCheck = 0; // The time in millis when the I2C bus was last checked (limits I2C traffic)
const uint8_t I2C_POLLING_WAIT_MS = 5; //Limit checking of new characters to every 5 ms (roughly 10 chars at 19200 baud)

// State variables
// State variables
int remainingMessages;
bool asleep;
bool reentrant;
Expand Down Expand Up @@ -281,7 +281,7 @@ class IridiumSBD
//Create the IO 'register'
//A '1' in any of the bits indicates that the pin is ON (not necessarily that it is HIGH!)
byte IO_REGISTER;

//These are the bit definitions for the IO 'register'
const uint8_t IO_SHDN = (1 << 0); // LTC3225 !SHDN : Read / Write
const uint8_t IO_PWR_EN = (1 << 1); // 9603N power enable via the P-FET : Read / Write
Expand All @@ -303,4 +303,4 @@ class IridiumSBD
int internalPassThruI2Cwrite(uint8_t *txBuffer, size_t &txBufferSize);
};

#endif
#endif

0 comments on commit d4f97b5

Please sign in to comment.