diff --git a/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp b/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp index 2f050fb..1c7883c 100644 --- a/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp +++ b/examples/LinkRawWireless_demo/src/scenes/DebugScene.cpp @@ -727,12 +727,9 @@ void DebugScene::processCommand(u32 selectedCommandIndex) { case 0x33: case 0x34: goto generic; - case 0x35: { - // TODO: IMPLEMENT - } - case 0x37: { - // TODO: IMPLEMENT - } + case 0x35: + case 0x37: + goto genericWait; case 0x38: case 0x39: goto generic; @@ -745,8 +742,9 @@ void DebugScene::processCommand(u32 selectedCommandIndex) { simple: return logSimpleCommand(name, command); generic: - auto data = selectData(); - return logSimpleCommand(name, command, data); + return logGenericCommand(name, command); +genericWait: + return logGenericWaitCommand(name, command); } int DebugScene::selectServerId() { @@ -871,6 +869,40 @@ std::string DebugScene::selectUserName() { } } +void DebugScene::logGenericWaitCommand(std::string name, u32 id) { + auto data = selectData(); + return logOperation("sending " + name, [id, &data]() { + auto result = linkRawWireless->sendCommand(id, data); + for (u32 i = 0; i < result.responses.size(); i++) { + log("< [response" + std::to_string(i) + "] " + + linkRawWireless->toHex(result.responses[i])); + } + + if (!result.success) + return false; + + log("Now WAITING..."); + + LinkRawWireless::RemoteCommand remoteCommand = + linkRawWireless->receiveCommandFromAdapter(); + + if (remoteCommand.success) { + log("< [notif] " + linkRawWireless->toHex(remoteCommand.commandId)); + for (u32 i = 0; i < remoteCommand.params.size(); i++) { + log("< [param" + std::to_string(i) + "] " + + linkRawWireless->toHex(remoteCommand.params[i])); + } + } + + return remoteCommand.success; + }); +} + +void DebugScene::logGenericCommand(std::string name, u32 id) { + auto data = selectData(); + return logSimpleCommand(name, id, data); +} + void DebugScene::logSimpleCommand(std::string name, u32 id, std::vector params) { diff --git a/examples/LinkRawWireless_demo/src/scenes/DebugScene.h b/examples/LinkRawWireless_demo/src/scenes/DebugScene.h index 16309ce..df7fccb 100644 --- a/examples/LinkRawWireless_demo/src/scenes/DebugScene.h +++ b/examples/LinkRawWireless_demo/src/scenes/DebugScene.h @@ -46,6 +46,8 @@ class DebugScene : public Scene { std::string selectUserName(); std::vector selectDataToSend(); std::vector selectData(); + void logGenericWaitCommand(std::string name, u32 id); + void logGenericCommand(std::string name, u32 id); void logSimpleCommand(std::string name, u32 id, std::vector params = {}); void logOperation(std::string name, std::function operation); void resetAdapter();