FIX: LinkRawWireless enables the library before calling any action

This commit is contained in:
Rodrigo Alfonso 2025-02-18 08:03:06 -03:00
parent 6868ca18cd
commit dcbdf37250
2 changed files with 22 additions and 4 deletions

View File

@ -229,11 +229,16 @@ class LinkRawWireless {
bool activate(bool _stopFirst = true) {
LINK_READ_TAG(LINK_RAW_WIRELESS_VERSION);
LINK_BARRIER;
isEnabled = false;
LINK_BARRIER;
bool success = reset(_stopFirst);
LINK_BARRIER;
isEnabled = true;
LINK_BARRIER;
return success;
}
@ -246,10 +251,16 @@ class LinkRawWireless {
* \warning This should be used as a replacement for `activate()`.
*/
bool restoreExistingConnection() {
LINK_BARRIER;
isEnabled = false;
LINK_BARRIER;
_resetState();
LINK_BARRIER;
isEnabled = true;
LINK_BARRIER;
_LRWLOG_("setting SPI to 2Mbps");
linkSPI.activate(LinkSPI::Mode::MASTER_2MBPS);
@ -286,7 +297,6 @@ class LinkRawWireless {
_LRWLOG_("restored ok!");
isEnabled = true;
return true;
}

View File

@ -296,14 +296,17 @@ class LinkWireless {
static_assert(LINK_WIRELESS_MAX_CLIENT_TRANSFER_LENGTH >= 2 &&
LINK_WIRELESS_MAX_CLIENT_TRANSFER_LENGTH <= 4);
lastError = Error::NONE;
LINK_BARRIER;
isEnabled = false;
LINK_BARRIER;
lastError = Error::NONE;
bool success = reset();
LINK_BARRIER;
isEnabled = true;
LINK_BARRIER;
isEnabled = true;
return success;
}
@ -316,7 +319,9 @@ class LinkWireless {
* \warning This should be used as a replacement for `activate()`.
*/
bool restoreExistingConnection() {
LINK_BARRIER;
isEnabled = false;
LINK_BARRIER;
resetState();
stopTimer();
@ -328,7 +333,10 @@ class LinkWireless {
return false;
}
LINK_BARRIER;
isEnabled = true;
LINK_BARRIER;
return true;
}