From 7afa41bf2a23bd486831cea99ce5425603b2de86 Mon Sep 17 00:00:00 2001 From: Kyle Schwarz Date: Thu, 3 Jul 2025 09:30:29 -0400 Subject: [PATCH] API: C: Add TC10 --- api/icsneoc/icsneoc.cpp | 30 ++++++++++++ .../communication/message/tc10statusmessage.h | 13 +---- include/icsneo/communication/tc10.h | 47 +++++++++++++++++++ include/icsneo/icsneoc.h | 41 ++++++++++++++++ 4 files changed, 119 insertions(+), 12 deletions(-) create mode 100644 include/icsneo/communication/tc10.h diff --git a/api/icsneoc/icsneoc.cpp b/api/icsneoc/icsneoc.cpp index 91b4bdb..aeff7d5 100644 --- a/api/icsneoc/icsneoc.cpp +++ b/api/icsneoc/icsneoc.cpp @@ -757,3 +757,33 @@ bool icsneo_isOnlineSupported(const neodevice_t* device) { return device->device->isOnlineSupported(); } + +bool icsneo_requestTC10Wake(const neodevice_t* device, neonetid_t netid) { + if(!icsneo_isValidNeoDevice(device)) + return false; + + return device->device->requestTC10Wake((Network::NetID)netid); +} + +bool icsneo_requestTC10Sleep(const neodevice_t* device, neonetid_t netid) { + if(!icsneo_isValidNeoDevice(device)) + return false; + + return device->device->requestTC10Sleep((Network::NetID)netid); +} + +bool icsneo_getTC10Status(const neodevice_t* device, neonetid_t netid, neotc10status_t* status) { + if(!icsneo_isValidNeoDevice(device)) + return false; + + const auto statusMsg = device->device->getTC10Status((Network::NetID)netid); + + if(!statusMsg) + return false; + + status->wakeStatus = (neotc10wakestatus_t)statusMsg->wakeStatus; + status->sleepStatus = (neotc10sleepstatus_t)statusMsg->sleepStatus; + + return true; +} + diff --git a/include/icsneo/communication/message/tc10statusmessage.h b/include/icsneo/communication/message/tc10statusmessage.h index baba024..0c5f498 100644 --- a/include/icsneo/communication/message/tc10statusmessage.h +++ b/include/icsneo/communication/message/tc10statusmessage.h @@ -4,24 +4,13 @@ #ifdef __cplusplus #include "icsneo/communication/message/message.h" +#include "icsneo/communication/tc10.h" #include namespace icsneo { -enum class TC10WakeStatus : uint8_t { - NoWakeReceived, - WakeReceived, -}; - -enum class TC10SleepStatus : uint8_t { - NoSleepReceived, - SleepReceived, - SleepFailed, - SleepAborted, -}; - class TC10StatusMessage : public Message { public: static std::shared_ptr DecodeToMessage(const std::vector& bytestream); diff --git a/include/icsneo/communication/tc10.h b/include/icsneo/communication/tc10.h new file mode 100644 index 0000000..e7fc214 --- /dev/null +++ b/include/icsneo/communication/tc10.h @@ -0,0 +1,47 @@ +#ifndef __ICSNEO_TC10_H_ +#define __ICSNEO_TC10_H_ + +#ifdef __cplusplus + +#include + +namespace icsneo { + +enum class TC10WakeStatus : uint8_t { + NoWakeReceived, + WakeReceived, +}; + +enum class TC10SleepStatus : uint8_t { + NoSleepReceived, + SleepReceived, + SleepFailed, + SleepAborted, +}; + +} + +#endif // __cplusplus + +#ifdef __ICSNEOC_H_ + +typedef enum _neotc10wakestatus_t { + ICSNEO_TC10_NO_WAKE_RECEIVED = 0, + ICSNEO_TC10_WAKE_RECEIVED = 1, +} neotc10wakestatus_t; + +typedef enum _neotc10sleepstatus_t { + ICSNEO_TC10_NO_SLEEP_RECEIVED = 0, + ICSNEO_TC10_SLEEP_RECEIVED = 1, + ICSNEO_TC10_SLEEP_FAILED = 1, + ICSNEO_TC10_SLEEP_ABORTED = 1, +} neotc10sleepstatus_t; + +typedef struct _neotc10status_t { + neotc10wakestatus_t wakeStatus; + neotc10sleepstatus_t sleepStatus; +} neotc10status_t; + +#endif + +#endif // __ICSNEO_TC10_H_ diff --git a/include/icsneo/icsneoc.h b/include/icsneo/icsneoc.h index 9549d20..1ed07f9 100644 --- a/include/icsneo/icsneoc.h +++ b/include/icsneo/icsneoc.h @@ -9,6 +9,7 @@ #include "icsneo/platform/dynamiclib.h" // Dynamic library loading and exporting #include "icsneo/communication/network.h" // Network type and netID defines #include "icsneo/communication/io.h" // IO enum defines +#include "icsneo/communication/tc10.h" #include "icsneo/api/version.h" // For version info #include "icsneo/api/event.h" // For event and error info @@ -845,6 +846,34 @@ extern bool DLLExport icsneo_setRTC(const neodevice_t* device, uint64_t input); */ extern bool DLLExport icsneo_isOnlineSupported(const neodevice_t* device); +/** + * \brief Request TC10 wake + * \param[in] device A pointer to the neodevice_t structure specifying the device to operate on. + * \param[in] netid The interface to request the TC10 wake on. + + * \returns True if the device successfully sent the TC10 wake request. +*/ +extern bool DLLExport icsneo_requestTC10Wake(const neodevice_t* device, neonetid_t netid); + +/** + * \brief Request TC10 sleep + * \param[in] device A pointer to the neodevice_t structure specifying the device to operate on. + * \param[in] netid The interface to request the TC10 sleep on. + + * \returns True if the device successfully sent the TC10 sleep request. +*/ +extern bool DLLExport icsneo_requestTC10Sleep(const neodevice_t* device, neonetid_t netid); + +/** + * \brief Query TC10 status + * \param[in] device A pointer to the neodevice_t structure specifying the device to operate on. + * \param[in] netid The interface to request the TC10 status for. + * \param[out] status The TC10 status for the given interface + + * \returns True if the device successfully retreieved the TC10 status. +*/ +extern bool DLLExport icsneo_getTC10Status(const neodevice_t* device, neonetid_t netid, neotc10status_t* status); + #ifdef __cplusplus } // extern "C" #endif @@ -1028,6 +1057,15 @@ fn_icsneo_setRTC icsneo_setRTC; typedef bool(*fn_icsneo_isOnlineSupported)(const neodevice_t* device); fn_icsneo_isOnlineSupported icsneo_isOnlineSupported; +typedef bool(*fn_icsneo_requestTC10Wake)(const neodevice_t* device, neonetid_t netid); +fn_icsneo_requestTC10Wake icsneo_requestTC10Wake; + +typedef bool(*fn_icsneo_requestTC10Sleep)(const neodevice_t* device, neonetid_t netid); +fn_icsneo_requestTC10Sleep icsneo_requestTC10Sleep; + +typedef bool(*fn_icsneo_getTC10Status)(const neodevice_t* device, neonetid_t netid, neotc10status_t* status); +fn_icsneo_getTC10Status icsneo_getTC10Status; + #define ICSNEO_IMPORT(func) func = (fn_##func)icsneo_dynamicLibraryGetFunction(icsneo_libraryHandle, #func) #define ICSNEO_IMPORTASSERT(func) if((ICSNEO_IMPORT(func)) == NULL) return 3 void* icsneo_libraryHandle = NULL; @@ -1101,6 +1139,9 @@ int icsneo_init() { ICSNEO_IMPORTASSERT(icsneo_getRTC); ICSNEO_IMPORTASSERT(icsneo_setRTC); ICSNEO_IMPORTASSERT(icsneo_isOnlineSupported); + ICSNEO_IMPORTASSERT(icsneo_requestTC10Wake); + ICSNEO_IMPORTASSERT(icsneo_requestTC10Sleep); + ICSNEO_IMPORTASSERT(icsneo_getTC10Status); icsneo_initialized = true; return 0;