ncsi: encapsulate NC-SI commands with NCSICommand / NCSIResponse structs
... and rename Interface::sendOemCommand to Interface::sendCommand.
This provides a more clear facility to pass command and response objects
around, for future command and transport implementations.
Change-Id: I46e594ab6467ed87cfc27189c3ec4bd321726ee5
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
diff --git a/src/ncsi_netlink_main.cpp b/src/ncsi_netlink_main.cpp
index 3089b7c..ce9b3f2 100644
--- a/src/ncsi_netlink_main.cpp
+++ b/src/ncsi_netlink_main.cpp
@@ -209,16 +209,19 @@
lg2::debug("Payload: {PAYLOAD}", "PAYLOAD", toHexStr(payload));
}
- auto cmd =
- std::span<const unsigned char>(payload.begin(), payload.end());
- auto resp =
- interface.sendOemCommand(packageInt, channelInt, operationInt, cmd);
+ std::optional<uint8_t> chan = channelInt != DEFAULT_VALUE
+ ? std::make_optional(channelInt)
+ : std::nullopt;
+ NCSICommand cmd(operationInt, packageInt, chan, payload);
+
+ auto resp = interface.sendCommand(cmd);
if (!resp)
{
return EXIT_FAILURE;
}
lg2::debug("Response {DATA_LEN} bytes: {DATA}", "DATA_LEN",
- resp->size(), "DATA", toHexStr(*resp));
+ resp->full_payload.size(), "DATA",
+ toHexStr(resp->full_payload));
}
else if ((options)["set"] == "true")
{