otInstance Declarations (#473)

* Add otInstance type declaration and update ot APIs to take it as input.
This commit is contained in:
Nick Banks
2016-09-12 14:29:43 -07:00
committed by Jonathan Hui
parent 9b1de7bbb2
commit ffbe65c6dd
67 changed files with 1560 additions and 1099 deletions
+1
View File
@@ -34,6 +34,7 @@ bin_PROGRAMS = \
ot_cli_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/examples/platforms \
$(NULL)
+36 -6
View File
@@ -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;
}
+1
View File
@@ -34,6 +34,7 @@ bin_PROGRAMS = \
ot_ncp_CPPFLAGS = \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/examples/platforms \
$(NULL)
+36 -6
View File
@@ -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;
}