Skip to content

Commit eda6523

Browse files
committed
Add configureSleepPin and setSleepPin as weak functions
1 parent a8c6b3c commit eda6523

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ getIMEI KEYWORD2
4545
isConnected KEYWORD2
4646
passThruI2Cread KEYWORD2
4747
passThruI2Cwrite KEYWORD2
48+
configureSleepPin KEYWORD2
49+
setSleepPin KEYWORD2
4850

4951
#######################################
5052
# Constants (LITERAL1)

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=IridiumSBDi2c
2-
version=3.0.2
2+
version=3.0.3
33
author=Mikal Hart and Paul Clark (PaulZC)
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=This library supports satellite data transmissions from anywhere on earth using the RockBLOCK family of Iridium 9602 and 9603 modems.

src/IridiumSBD.cpp

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,11 @@ void IridiumSBD::power(bool on)
11011101
}
11021102
else
11031103
{
1104-
pinMode(this->sleepPin, OUTPUT); // Make the sleep pin an output
1104+
if (this->sleepPinConfigured == false)
1105+
{
1106+
configureSleepPin();
1107+
this->sleepPinConfigured = true;
1108+
}
11051109
}
11061110
}
11071111

@@ -1110,15 +1114,14 @@ void IridiumSBD::power(bool on)
11101114
diagprint(F("Powering on modem...\r\n"));
11111115
if (this->useSerial)
11121116
{
1113-
digitalWrite(this->sleepPin, HIGH); // HIGH = awake
1117+
setSleepPin(HIGH); // HIGH = awake
11141118
}
11151119
else
11161120
{
11171121
enable9603(true);
11181122
}
11191123
lastPowerOnTime = millis();
11201124
}
1121-
11221125
else
11231126
{
11241127
// Best Practices Guide suggests waiting at least 2 seconds
@@ -1130,7 +1133,7 @@ void IridiumSBD::power(bool on)
11301133
diagprint(F("Powering off modem...\r\n"));
11311134
if (this->useSerial)
11321135
{
1133-
digitalWrite(this->sleepPin, LOW); // LOW = asleep
1136+
setSleepPin(LOW); // LOW = asleep
11341137
}
11351138
else
11361139
{
@@ -1139,6 +1142,22 @@ void IridiumSBD::power(bool on)
11391142
}
11401143
}
11411144

1145+
void IridiumSBD::configureSleepPin()
1146+
{
1147+
pinMode(this->sleepPin, OUTPUT); // Make the sleep pin an output
1148+
diagprint(F("configureSleepPin: sleepPin configured\r\n"));
1149+
}
1150+
1151+
void IridiumSBD::setSleepPin(uint8_t enable)
1152+
{
1153+
digitalWrite(this->sleepPin, enable); // HIGH = awake, LOW = asleep
1154+
diagprint(F("setSleepPin: sleepPin set "));
1155+
if (enable == HIGH)
1156+
diagprint(F("HIGH\r\n"));
1157+
else
1158+
diagprint(F("LOW\r\n"));
1159+
}
1160+
11421161
void IridiumSBD::send(FlashString str, bool beginLine, bool endLine)
11431162
{
11441163
if (beginLine)

src/IridiumSBD.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ class IridiumSBD
134134
int passThruI2Cread(uint8_t *rxBuffer, size_t &rxBufferSize, size_t &numBytes);
135135
int passThruI2Cwrite(uint8_t *txBuffer, size_t &txBufferSize);
136136

137+
// Weak functions to configure and set the sleep pin - user can overwrite with a custom functions if required
138+
void configureSleepPin() __attribute__((weak));
139+
void setSleepPin(uint8_t enable) __attribute__((weak));
140+
137141
IridiumSBD(Stream &str, int sleepPinNo = -1, int ringPinNo = -1)
138142
{
139143
useSerial = true;
@@ -146,6 +150,7 @@ class IridiumSBD
146150
asleep = true;
147151
reentrant = false;
148152
sleepPin = sleepPinNo;
153+
sleepPinConfigured = false;
149154
ringPin = ringPinNo;
150155
msstmWorkaroundRequested = true;
151156
ringAlertsEnabled = {ringPinNo != -1};
@@ -175,6 +180,7 @@ class IridiumSBD
175180
asleep = true;
176181
reentrant = false;
177182
sleepPin = -1;
183+
sleepPinConfigured = false;
178184
ringPin = -1;
179185
msstmWorkaroundRequested = false;
180186
ringAlertsEnabled = true;
@@ -218,6 +224,7 @@ class IridiumSBD
218224
bool asleep;
219225
bool reentrant;
220226
int sleepPin;
227+
bool sleepPinConfigured;
221228
int ringPin;
222229
bool msstmWorkaroundRequested;
223230
bool ringAlertsEnabled;

0 commit comments

Comments
 (0)