From 1203ea6426a906d62a3921b6d4c6a4a6c8e0abde Mon Sep 17 00:00:00 2001 From: Nick Bertoldi <109968900+bertoldi-silabs@users.noreply.github.com> Date: Tue, 9 May 2023 21:37:54 -0400 Subject: [PATCH] Define posix radio RadioSpinel accessor (#9018) When adding cli commands to be used by a posix platform is is useful to have access to the spinel interface when trying to communicate with a RCP using vendor specific spinel properties. It is inadvisable to create a separate spinel interface for custom properties as the two interfaces would need to avoid contention on the hardware interface. This accessor method allows access to the static spinel interface defined in radio.cpp for external code segments. Dependent source files can do so with: `(RadioSpinel*)Posix::Radio::getSpinelInstance()` or similar. --- src/posix/platform/radio.cpp | 2 ++ src/posix/platform/radio.hpp | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/posix/platform/radio.cpp b/src/posix/platform/radio.cpp index 98f580a6f..00e2c1c9f 100644 --- a/src/posix/platform/radio.cpp +++ b/src/posix/platform/radio.cpp @@ -201,6 +201,8 @@ void Radio::Init(void) #endif // OPENTHREAD_CONFIG_PLATFORM_RADIO_COEX_ENABLE } +void *Radio::GetSpinelInstance(void) { return &sRadioSpinel; } + } // namespace Posix } // namespace ot diff --git a/src/posix/platform/radio.hpp b/src/posix/platform/radio.hpp index 1312cb450..6a3d54956 100644 --- a/src/posix/platform/radio.hpp +++ b/src/posix/platform/radio.hpp @@ -55,6 +55,14 @@ public: */ void Init(void); + /** + * This method acts as an accessor to the spinel instance used by the radio. + * + * @returns A pointer to the radio's spinel interface instance. + * + */ + static void *GetSpinelInstance(void); + private: RadioUrl mRadioUrl; };