Skip to content

Commit bc2ecb4

Browse files
committed
Added sleep command
1 parent 952a6ed commit bc2ecb4

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/TheThingsNetwork.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -874,3 +874,20 @@ void TheThingsNetwork::stateMessage(uint8_t type, uint8_t indexMsg, const char *
874874
debugPrintLn();
875875
}
876876
}
877+
878+
void TheThingsNetwork::sleep(unsigned long msec) {
879+
if (100 < msec && msec < 4294967296) {
880+
while (modemStream->available()) {
881+
modemStream->read();
882+
}
883+
debugPrint(F(SENDING));
884+
sendCommand(SYS_TABLE, SYS_PREFIX, true);
885+
sendCommand(SYS_TABLE, SYS_SLEEP, true);
886+
char buffer[10];
887+
sprintf(buffer, "%ld", msec);
888+
modemStream->write(buffer);
889+
debugPrint(buffer);
890+
modemStream->write(SEND_MSG);
891+
debugPrintLn();
892+
}
893+
}

src/TheThingsNetwork.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class TheThingsNetwork
9090
bool personalize(const char *devAddr, const char *nwkSKey, const char *appSKey);
9191
bool personalize();
9292
ttn_response_t sendBytes(const byte* payload, size_t length, port_t port = 1, bool confirm = false);
93+
void sleep(unsigned long mseconds);
9394
int8_t poll(port_t port = 1, bool confirm = false);
9495
};
9596

0 commit comments

Comments
 (0)