diff --git a/src/lib/spinel/spinel_driver.hpp b/src/lib/spinel/spinel_driver.hpp index 1f45bc719..5a3090c83 100644 --- a/src/lib/spinel/spinel_driver.hpp +++ b/src/lib/spinel/spinel_driver.hpp @@ -36,6 +36,14 @@ #include "lib/spinel/spinel.h" #include "lib/spinel/spinel_interface.hpp" +/** + * Represents an opaque (and empty) type corresponding to a SpinelDriver object. + * + */ +struct otSpinelDriver +{ +}; + namespace ot { namespace Spinel { @@ -49,7 +57,7 @@ static constexpr uint8_t kSpinelHeaderMaxNumIid = 4; static constexpr uint8_t kSpinelHeaderMaxNumIid = 1; #endif -class SpinelDriver : public Logger +class SpinelDriver : public otSpinelDriver, public Logger { public: typedef void ( diff --git a/src/posix/platform/include/openthread/openthread-system.h b/src/posix/platform/include/openthread/openthread-system.h index 460016e45..3c72ad0b5 100644 --- a/src/posix/platform/include/openthread/openthread-system.h +++ b/src/posix/platform/include/openthread/openthread-system.h @@ -97,6 +97,23 @@ typedef struct otPlatformConfig ///< the type to the app layer. } otPlatformConfig; +/** + * Represents the platform spinel driver structure. + * + */ +typedef struct otSpinelDriver otSpinelDriver; + +/** + * Gets the instance of the spinel driver; + * + * @note This API is used for external projects to get the instance of `SpinelDriver` to customize + * different spinel handlings. + * + * @returns A pointer to the spinel driver instance. + * + */ +otSpinelDriver *otSysGetSpinelDriver(void); + /** * Initializes the co-processor and the spinel driver. * diff --git a/src/posix/platform/system.cpp b/src/posix/platform/system.cpp index 8de729c4a..89da6af13 100644 --- a/src/posix/platform/system.cpp +++ b/src/posix/platform/system.cpp @@ -57,6 +57,7 @@ #include "posix/platform/mainloop.hpp" #include "posix/platform/mdns_socket.hpp" #include "posix/platform/radio_url.hpp" +#include "posix/platform/spinel_driver_getter.hpp" #include "posix/platform/udp.hpp" otInstance *gInstance = nullptr; @@ -258,6 +259,8 @@ CoprocessorType otSysInitCoprocessor(otPlatformCoprocessorUrls *aUrls) return sCoprocessorType; } +otSpinelDriver *otSysGetSpinelDriver(void) { return &ot::Posix::GetSpinelDriver(); } + otInstance *otSysInit(otPlatformConfig *aPlatformConfig) { OT_ASSERT(gInstance == nullptr);