From f7e5e681cf8648db9ea3978ca75464fdc1df2f16 Mon Sep 17 00:00:00 2001 From: Rodrigo Alfonso Date: Sun, 14 Jan 2024 01:26:24 -0300 Subject: [PATCH] Adding ACK debug logging --- .../src/scenes/DebugScene.cpp | 8 ++++++++ .../src/scenes/DebugScene.h | 1 + lib/LinkRawWireless.hpp | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp b/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp index 59a8d34..b2f6b64 100644 --- a/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp +++ b/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp @@ -128,6 +128,9 @@ void DebugScene::processButtons(u16 keys) { selectHandler->setIsPressed(keys & KEY_SELECT); startHandler->setIsPressed(keys & KEY_START); + if (aHandler->hasBeenPressedNow()) + showCommandSendMenu(); + if (bHandler->hasBeenPressedNow()) toggleLogLevel(); @@ -160,9 +163,14 @@ void DebugScene::toggleLogLevel() { } log(""); } + void DebugScene::resetAdapter() { log("> resetting adapter..."); bool success = linkRawWireless->activate(); log(success ? "< it worked :)" : "< it failed :("); log(""); +} + +void DebugScene::showCommandSendMenu() { + // TODO: IMPLEMENT } \ No newline at end of file diff --git a/examples/LinkRawWireless_demo/src/scenes/DebugScene.h b/examples/LinkRawWireless_demo/src/scenes/DebugScene.h index 8e7ea3d..d72b76e 100644 --- a/examples/LinkRawWireless_demo/src/scenes/DebugScene.h +++ b/examples/LinkRawWireless_demo/src/scenes/DebugScene.h @@ -22,6 +22,7 @@ class DebugScene : public Scene { void processButtons(u16 keys); void toggleLogLevel(); void resetAdapter(); + void showCommandSendMenu(); }; #endif // DEBUG_SCENE_H diff --git a/lib/LinkRawWireless.hpp b/lib/LinkRawWireless.hpp index a03ac24..ed8797c 100644 --- a/lib/LinkRawWireless.hpp +++ b/lib/LinkRawWireless.hpp @@ -39,6 +39,7 @@ (1 + LINK_RAW_WIRELESS_BROADCAST_LENGTH) #define LINK_RAW_WIRELESS_MAX_COMMAND_TRANSFER_LENGTH 22 #define LINK_RAW_WIRELESS_COMMAND_HELLO 0x10 +#define LINK_RAW_WIRELESS_COMMAND_VERSION 0x11 #define LINK_RAW_WIRELESS_COMMAND_SETUP 0x17 #define LINK_RAW_WIRELESS_COMMAND_BROADCAST 0x16 #define LINK_RAW_WIRELESS_COMMAND_START_HOST 0x19 @@ -608,13 +609,21 @@ class LinkRawWireless { u32 vCount = REG_VCOUNT; linkSPI->_setSOLow(); - while (!linkSPI->_isSIHigh()) - if (cmdTimeout(lines, vCount)) + while (!linkSPI->_isSIHigh()) { + if (cmdTimeout(lines, vCount)) { + debug("! ACK 1 failed. I put SO=LOW,"); + debug("! but SI didn't become HIGH."); return false; + } + } linkSPI->_setSOHigh(); - while (linkSPI->_isSIHigh()) - if (cmdTimeout(lines, vCount)) + while (linkSPI->_isSIHigh()) { + if (cmdTimeout(lines, vCount)) { + debug("! ACK 2 failed. I put SO=HIGH,"); + debug("! but SI didn't become LOW."); return false; + } + } linkSPI->_setSOLow(); return true;