Skip to content

Commit 52f44b2

Browse files
authored
Merge pull request #13 from sandeepmistry/low-power-fixes
Low power fixes
2 parents 6169ad3 + 85f6918 commit 52f44b2

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/GSMPIN.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int GSMPIN::isPIN()
3535
{
3636
String response;
3737

38-
for (unsigned long start = millis(); millis() < (start + 1000);) {
38+
for (unsigned long start = millis(); (millis() - start) < 1000;) {
3939
MODEM.send("AT+CPIN?");
4040

4141
if (MODEM.waitForResponse(10000, &response) == 1) {
@@ -124,7 +124,7 @@ void GSMPIN::switchPIN(String pin)
124124

125125
int GSMPIN::checkReg()
126126
{
127-
for (unsigned long start = millis(); millis() < (start + 10000L);) {
127+
for (unsigned long start = millis(); (millis() - start) < 10000L;) {
128128
MODEM.send("AT+CREG?");
129129

130130
String response = "";

src/GSMVoiceCall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ int GSMVoiceCall::voiceCall(const char* to, unsigned long timeout)
6363
}
6464

6565
_callStatus = CALLING;
66-
for (unsigned long start = millis(); (timeout == 0) || (millis() < (start + timeout));) {
66+
for (unsigned long start = millis(); (timeout == 0) || ((millis() - start) < timeout);) {
6767
if (getvoiceCallStatus() != CALLING) {
6868
break;
6969
}

src/Modem.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ void ModemClass::debug()
103103

104104
int ModemClass::autosense(int timeout)
105105
{
106-
for (unsigned long start = millis(); millis() < (start + timeout);) {
106+
for (unsigned long start = millis(); (millis() - start) < timeout;) {
107107
if (noop() == 1) {
108108
return 1;
109109
}
@@ -163,6 +163,7 @@ void ModemClass::send(const char* command)
163163
{
164164
if (_lowPowerMode) {
165165
digitalWrite(_dtrPin, LOW);
166+
delay(5);
166167
}
167168

168169
_uart->println(command);
@@ -186,7 +187,7 @@ void ModemClass::sendf(const char *fmt, ...)
186187
int ModemClass::waitForResponse(unsigned long timeout, String* responseDataStorage)
187188
{
188189
_responseDataStorage = responseDataStorage;
189-
for (unsigned long start = millis(); millis() < (start + timeout);) {
190+
for (unsigned long start = millis(); (millis() - start) < timeout;) {
190191
int r = ready();
191192

192193
if (r != 0) {

0 commit comments

Comments
 (0)