[posix] add OT sys API to get the spinel driver (#10393)

This commit is contained in:
Li Cao
2024-06-18 08:30:35 -07:00
committed by GitHub
parent 54afce92ab
commit fad66e272a
3 changed files with 29 additions and 1 deletions
+9 -1
View File
@@ -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 (
@@ -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.
*
+3
View File
@@ -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);