Skip to content

Commit b496c43

Browse files
committed
feat: Function to adjust SBD Session Timeout
Signed-off-by: Andrew Yong <[email protected]>
1 parent 8ab63df commit b496c43

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

src/IridiumSBD.cpp

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,24 @@ void IridiumSBD::adjustATTimeout(int seconds)
171171
this->atTimeout = seconds;
172172
}
173173

174+
// Tweak SBD Session Timeout
175+
int IridiumSBD::adjustSBDSessionTimeout(int seconds)
176+
{
177+
if ((seconds >= this->atTimeout) || seconds == 0)
178+
diagprint(F("SBD commands that do not complete before AT timeout will return ISBD_PROTOCOL_ERROR\r\n"));
179+
this->sbdSessionTimeout = seconds;
180+
181+
if (!this->asleep) {
182+
send(F("AT+SBDST="), true, false);
183+
send(seconds);
184+
send(F("\r"), false);
185+
if (!waitForATResponse()) {
186+
return cancelled() ? ISBD_CANCELLED : ISBD_PROTOCOL_ERROR;
187+
}
188+
}
189+
return ISBD_SUCCESS;
190+
}
191+
174192
// Tweak Send/Receive SBDIX process timeout
175193
void IridiumSBD::adjustSendReceiveTimeout(int seconds)
176194
{
@@ -614,6 +632,21 @@ int IridiumSBD::internalBegin()
614632
}
615633
diagprint(F("MSSTM workaround is")); diagprint(msstmWorkaroundRequested ? F("") : F(" NOT")); diagprint(F(" enforced.\r\n"));
616634

635+
// Set SBD session timeout only if it has been changed from the default (to avoid regressions)
636+
// ISU AT Command Reference: "The <timeout> setting is stored only while the SBD Modem is powered up, and defaults to zero (meaning infinite timeout) after a power-cycle."
637+
if (this->sbdSessionTimeout != ISBD_DEFAULT_SBDSESSION_TIMEOUT)
638+
{
639+
ret = adjustSBDSessionTimeout(this->sbdSessionTimeout);
640+
if (ret != ISBD_SUCCESS)
641+
{
642+
diagprint(F("adjustSBDSessionTimeout: failed\r\n"));
643+
}
644+
else
645+
{
646+
diagprint(F("adjustSBDSessionTimeout: success!\r\n"));
647+
}
648+
}
649+
617650
// Done!
618651
diagprint(F("InternalBegin: success!\r\n"));
619652
return ISBD_SUCCESS;

src/IridiumSBD.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
6767
#define ISBD_DEFAULT_AT_TIMEOUT 30
6868
#define ISBD_MSSTM_RETRY_INTERVAL 10
6969
#define ISBD_DEFAULT_SBDIX_INTERVAL 10
70+
#define ISBD_DEFAULT_SBDSESSION_TIMEOUT 0
7071
#define ISBD_USB_SBDIX_INTERVAL 30
7172
#define ISBD_DEFAULT_SENDRECEIVE_TIME 300
7273
#define ISBD_STARTUP_MAX_TIME 240
@@ -113,6 +114,7 @@ class IridiumSBD
113114
typedef enum { DEFAULT_POWER_PROFILE = 0, USB_POWER_PROFILE = 1 } POWERPROFILE;
114115
void setPowerProfile(POWERPROFILE profile); // 0 = direct connect (default), 1 = USB
115116
void adjustATTimeout(int seconds); // default value = 30 seconds
117+
int adjustSBDSessionTimeout(int seconds); // 0 = infinite (default)
116118
void adjustSendReceiveTimeout(int seconds); // default value = 300 seconds
117119
void adjustStartupTimeout(int seconds); // default value = 240 seconds
118120
void useMSSTMWorkaround(bool useMSSTMWorkAround); // true to use workaround from Iridium Alert 5/7/13
@@ -147,6 +149,7 @@ class IridiumSBD
147149
useSerial = true;
148150
stream = &str;
149151
sbdixInterval = ISBD_USB_SBDIX_INTERVAL;
152+
sbdSessionTimeout = 0;
150153
atTimeout = ISBD_DEFAULT_AT_TIMEOUT;
151154
sendReceiveTimeout = ISBD_DEFAULT_SENDRECEIVE_TIME;
152155
startupTimeout = ISBD_STARTUP_MAX_TIME;
@@ -177,6 +180,7 @@ class IridiumSBD
177180
wireport = &wirePort;
178181
deviceaddress = deviceAddress;
179182
sbdixInterval = ISBD_USB_SBDIX_INTERVAL;
183+
sbdSessionTimeout = 0;
180184
atTimeout = ISBD_DEFAULT_AT_TIMEOUT;
181185
sendReceiveTimeout = ISBD_DEFAULT_SENDRECEIVE_TIME;
182186
startupTimeout = ISBD_STARTUP_MAX_TIME;
@@ -217,6 +221,7 @@ class IridiumSBD
217221

218222
// Timings
219223
int sbdixInterval;
224+
int sbdSessionTimeout;
220225
int atTimeout;
221226
int sendReceiveTimeout;
222227
int startupTimeout;

0 commit comments

Comments
 (0)