mirror of
https://github.com/espressif/openthread.git
synced 2026-08-26 20:19:53 +00:00
[posix] add OT sys API to get the spinel driver (#10393)
This commit is contained in:
@@ -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.
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user