Skip to content

Commit

Permalink
[SX126x] Added option to change sleep mode (cold/warm start)
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Dec 29, 2019
1 parent 460a050 commit 02ac97b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/modules/SX126x/SX126x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,12 @@ int16_t SX126x::scanChannel() {
return(ERR_UNKNOWN);
}

int16_t SX126x::sleep() {
uint8_t data[] = {SX126X_SLEEP_START_COLD | SX126X_SLEEP_RTC_OFF};
int16_t SX126x::sleep(bool retainConfig) {
uint8_t sleepMode = SX126X_SLEEP_START_WARM;
if(!retainConfig) {
sleepMode = SX126X_SLEEP_START_COLD;
}
uint8_t data[] = {sleepMode | SX126X_SLEEP_RTC_OFF};
int16_t state = SPIwriteCommand(SX126X_CMD_SET_SLEEP, data, 1, false);

// wait for SX126x to safely enter sleep mode
Expand Down
4 changes: 3 additions & 1 deletion src/modules/SX126x/SX126x.h
Original file line number Diff line number Diff line change
Expand Up @@ -452,9 +452,11 @@ class SX126x: public PhysicalLayer {
/*!
\brief Sets the module to sleep mode.
\param retainConfig Set to true to retain configuration of the currently active modem ("warm start") or to false to discard current configuration ("cold start"). Defaults to true.
\returns \ref status_codes
*/
int16_t sleep();
int16_t sleep(bool retainConfig = true);

/*!
\brief Sets the module to standby mode (overload for PhysicalLayer compatibility, uses 13 MHz RC oscillator).
Expand Down

0 comments on commit 02ac97b

Please sign in to comment.