[SX128x] Wakeup device on standby() call

This commit is contained in:
jgromes 2023-05-02 18:58:59 +02:00
parent d1d07af00b
commit 84ebdddcaf
2 changed files with 10 additions and 2 deletions

View file

@ -460,7 +460,15 @@ int16_t SX128x::standby(uint8_t mode) {
this->mod->setRfSwitchState(Module::MODE_IDLE);
uint8_t data[] = { mode };
return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1));
int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1);
if(state == RADIOLIB_ERR_NONE) {
return(state);
} else if(state == RADIOLIB_ERR_SPI_CMD_TIMEOUT) {
// the device might be in sleep mode, pull NSS low to wake up and try again
this->mod->hal->digitalWrite(this->mod->getCs(), this->mod->hal->GpioLevelLow);
return(this->mod->SPIwriteStream(RADIOLIB_SX128X_CMD_SET_STANDBY, data, 1));
}
return(state);
}
void SX128x::setDio1Action(void (*func)(void)) {

View file

@ -460,7 +460,7 @@ class SX128x: public PhysicalLayer {
int16_t scanChannel();
/*!
\brief Sets the module to sleep mode.
\brief Sets the module to sleep mode. To wake the device up, call standby().
\param retainConfig Set to true to retain configuration and data buffer or to false
to discard current configuration and data buffer. Defaults to true.
\returns \ref status_codes