mirror of
https://github.com/espressif/openthread.git
synced 2026-07-29 15:17:47 +00:00
otInstance Declarations (#473)
* Add otInstance type declaration and update ot APIs to take it as input.
This commit is contained in:
@@ -34,6 +34,7 @@ bin_PROGRAMS = \
|
||||
|
||||
ot_cli_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/examples/platforms \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@@ -26,31 +26,61 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread.h>
|
||||
#include <openthread-config.h>
|
||||
#include <openthread-diag.h>
|
||||
#include <cli/cli-uart.h>
|
||||
#include <platform/platform.h>
|
||||
#include <assert.h>
|
||||
|
||||
void otSignalTaskletPending(void)
|
||||
void otSignalTaskletPending(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
otInstance *sInstance;
|
||||
|
||||
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
uint64_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
#endif
|
||||
|
||||
PlatformInit(argc, argv);
|
||||
otEnable();
|
||||
otCliUartInit();
|
||||
|
||||
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
// Call to query the buffer size
|
||||
(void)otInstanceInit(NULL, &otInstanceBufferLength);
|
||||
|
||||
// Call to allocate the buffer
|
||||
otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength);
|
||||
assert(otInstanceBuffer);
|
||||
|
||||
// Initialize Openthread with the buffer
|
||||
sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength);
|
||||
#else
|
||||
sInstance = otInstanceInit();
|
||||
#endif
|
||||
assert(sInstance);
|
||||
|
||||
otCliUartInit(sInstance);
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
diagInit();
|
||||
diagInit(sInstance);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
otProcessNextTasklet();
|
||||
PlatformProcessDrivers();
|
||||
otProcessNextTasklet(sInstance);
|
||||
PlatformProcessDrivers(sInstance);
|
||||
}
|
||||
|
||||
// otInstanceFinalize(sInstance);
|
||||
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
// free(otInstanceBuffer);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ bin_PROGRAMS = \
|
||||
|
||||
ot_ncp_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/examples/platforms \
|
||||
$(NULL)
|
||||
|
||||
|
||||
@@ -26,31 +26,61 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <openthread-core-config.h>
|
||||
#include <openthread.h>
|
||||
#include <openthread-config.h>
|
||||
#include <openthread-diag.h>
|
||||
#include <common/debug.hpp>
|
||||
#include <ncp/ncp.h>
|
||||
#include <platform/platform.h>
|
||||
|
||||
void otSignalTaskletPending(void)
|
||||
void otSignalTaskletPending(otInstance *aInstance)
|
||||
{
|
||||
(void)aInstance;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
otInstance *sInstance;
|
||||
|
||||
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
uint64_t otInstanceBufferLength = 0;
|
||||
uint8_t *otInstanceBuffer = NULL;
|
||||
#endif
|
||||
|
||||
PlatformInit(argc, argv);
|
||||
otEnable();
|
||||
otNcpInit();
|
||||
|
||||
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
// Call to query the buffer size
|
||||
(void)otInstanceInit(NULL, &otInstanceBufferLength);
|
||||
|
||||
// Call to allocate the buffer
|
||||
otInstanceBuffer = (uint8_t *)malloc(otInstanceBufferLength);
|
||||
assert(otInstanceBuffer);
|
||||
|
||||
// Initialize Openthread with the buffer
|
||||
sInstance = otInstanceInit(otInstanceBuffer, &otInstanceBufferLength);
|
||||
#else
|
||||
sInstance = otInstanceInit();
|
||||
#endif
|
||||
assert(sInstance);
|
||||
|
||||
otNcpInit(sInstance);
|
||||
|
||||
#if OPENTHREAD_ENABLE_DIAG
|
||||
diagInit();
|
||||
diagInit(sInstance);
|
||||
#endif
|
||||
|
||||
while (1)
|
||||
{
|
||||
otProcessNextTasklet();
|
||||
PlatformProcessDrivers();
|
||||
otProcessNextTasklet(sInstance);
|
||||
PlatformProcessDrivers(sInstance);
|
||||
}
|
||||
|
||||
// otInstanceFinalize(sInstance);
|
||||
#ifdef OPENTHREAD_MULTIPLE_INSTANCE
|
||||
// free(otInstanceBuffer);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user