From dcbdf372503c318b60ae3bb257b4b8a66034f397 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Tue, 18 Feb 2025 08:03:06 -0300 Subject: [PATCH] FIX: LinkRawWireless enables the library before calling any action --- lib/LinkRawWireless.hpp | 12 +++++++++++- lib/LinkWireless.hpp | 14 +++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/LinkRawWireless.hpp b/lib/LinkRawWireless.hpp index c3a7a9a..8eef0af 100644 --- a/lib/LinkRawWireless.hpp +++ b/lib/LinkRawWireless.hpp @@ -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; } diff --git a/lib/LinkWireless.hpp b/lib/LinkWireless.hpp index 28c0bcb..6035d26 100644 --- a/lib/LinkWireless.hpp +++ b/lib/LinkWireless.hpp @@ -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; }