[SX126x] Wakeup device on standby() call (#740)

pull/746/head
jgromes 2023-05-02 18:59:33 +02:00
rodzic 84ebdddcaf
commit bdc5bb0bba
2 zmienionych plików z 11 dodań i 3 usunięć

Wyświetl plik

@ -453,8 +453,16 @@ int16_t SX126x::standby(uint8_t mode) {
// set RF switch (if present)
this->mod->setRfSwitchState(Module::MODE_IDLE);
uint8_t data[] = {mode};
return(this->mod->SPIwriteStream(RADIOLIB_SX126X_CMD_SET_STANDBY, data, 1));
uint8_t data[] = { mode };
int16_t state = this->mod->SPIwriteStream(RADIOLIB_SX126X_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_SX126X_CMD_SET_STANDBY, data, 1));
}
return(state);
}
void SX126x::setDio1Action(void (*func)(void)) {

Wyświetl plik

@ -538,7 +538,7 @@ class SX126x: public PhysicalLayer {
int16_t scanChannel(uint8_t symbolNum = RADIOLIB_SX126X_CAD_PARAM_DEFAULT, uint8_t detPeak = RADIOLIB_SX126X_CAD_PARAM_DEFAULT, uint8_t detMin = RADIOLIB_SX126X_CAD_PARAM_DEFAULT);
/*!
\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 of the currently active modem ("warm start")
or to false to discard current configuration ("cold start"). Defaults to true.
\returns \ref status_codes