mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
Unify example apps across all example platforms. (#215)
This commit is contained in:
+3
-3
@@ -43,16 +43,16 @@ set -x
|
||||
}
|
||||
|
||||
[ $BUILD_TARGET != posix ] || {
|
||||
make -f Makefile-Standalone distcheck || die
|
||||
make -f examples/Makefile-posix distcheck || die
|
||||
}
|
||||
|
||||
[ $BUILD_TARGET != posix-32-bit ] || {
|
||||
CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 make -f Makefile-Standalone distcheck || die
|
||||
CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 make -f examples/Makefile-posix distcheck || die
|
||||
}
|
||||
|
||||
[ $BUILD_TARGET != cc2538 ] || {
|
||||
export PATH=/tmp/gcc-arm-none-eabi-4_9-2015q3/bin:$PATH || die
|
||||
make -f examples/cc2538/Makefile-cc2538 || die
|
||||
make -f examples/Makefile-cc2538 || die
|
||||
}
|
||||
|
||||
[ $BUILD_TARGET != scan-build ] || {
|
||||
|
||||
@@ -45,8 +45,8 @@ contributing to the ongoing development of OpenThread.
|
||||
# Getting started #
|
||||
|
||||
The easiest way to get started is to run the CLI example in
|
||||
`/examples/posix/app/cli`. See the
|
||||
[CLI example README](examples/posix/app/cli/README.md)
|
||||
`/examples/apps/cli`. See the
|
||||
[CLI example README](examples/apps/cli/README.md)
|
||||
for more details.
|
||||
|
||||
|
||||
|
||||
+7
-10
@@ -412,6 +412,7 @@ esac
|
||||
AC_MSG_RESULT(${OPENTHREAD_EXAMPLES})
|
||||
|
||||
AC_SUBST(OPENTHREAD_EXAMPLES)
|
||||
AM_CONDITIONAL([OPENTHREAD_EXAMPLES], [test ${with_examples} != "none"])
|
||||
AC_DEFINE_UNQUOTED([OPENTHREAD_EXAMPLES],[${OPENTHREAD_EXAMPLES}],[OpenThread examples])
|
||||
|
||||
AC_SUBST(OPENTHREAD_EXAMPLES_POSIX)
|
||||
@@ -527,16 +528,12 @@ src/core/Makefile
|
||||
third_party/Makefile
|
||||
third_party/mbedtls/Makefile
|
||||
examples/Makefile
|
||||
examples/posix/Makefile
|
||||
examples/posix/app/Makefile
|
||||
examples/posix/app/cli/Makefile
|
||||
examples/posix/app/ncp/Makefile
|
||||
examples/posix/platform/Makefile
|
||||
examples/cc2538/Makefile
|
||||
examples/cc2538/app/Makefile
|
||||
examples/cc2538/app/cli/Makefile
|
||||
examples/cc2538/app/ncp/Makefile
|
||||
examples/cc2538/platform/Makefile
|
||||
examples/apps/Makefile
|
||||
examples/apps/cli/Makefile
|
||||
examples/apps/ncp/Makefile
|
||||
examples/platforms/Makefile
|
||||
examples/platforms/cc2538/Makefile
|
||||
examples/platforms/posix/Makefile
|
||||
tests/Makefile
|
||||
tests/scripts/Makefile
|
||||
tests/unit/Makefile
|
||||
|
||||
@@ -79,9 +79,6 @@ LDFLAGS = \
|
||||
-Wl,-Map=map.map \
|
||||
$(NULL)
|
||||
|
||||
LIBS = \
|
||||
$(NULL)
|
||||
|
||||
ECHO := @echo
|
||||
MAKE := make
|
||||
MKDIR_P := mkdir -p
|
||||
@@ -91,8 +88,8 @@ RM_F := rm -f
|
||||
INSTALL := /usr/bin/install
|
||||
INSTALLFLAGS := -p
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))../../
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))../../
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
BuildPath = build
|
||||
TopBuildDir = $(BuildPath)
|
||||
@@ -119,7 +116,7 @@ define configure-arch
|
||||
$(ECHO) " CONFIG $(1)-$(TargetTuple)..."
|
||||
(cd $(BuildPath)/$(1)-$(TargetTuple) && $(AbsTopSourceDir)/configure \
|
||||
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
|
||||
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" LIBS="$(LIBS)" \
|
||||
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
|
||||
--host=arm-none-eabi \
|
||||
--target=arm-none-eabi \
|
||||
--prefix=/ \
|
||||
@@ -42,8 +42,8 @@ RM_F := rm -f
|
||||
INSTALL := /usr/bin/install
|
||||
INSTALLFLAGS := -p
|
||||
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
|
||||
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
|
||||
|
||||
BuildPath = build
|
||||
TopBuildDir = $(BuildPath)
|
||||
@@ -53,15 +53,17 @@ ResultPath = output
|
||||
TopResultDir = $(ResultPath)
|
||||
AbsTopResultDir = $(PWD)/$(TopResultDir)
|
||||
|
||||
TargetTuple = $(shell ${AbsTopSourceDir}/build/nlbuild-autotools/repo/autoconf/config.guess | sed -e 's/[[:digit:].]*$$//g')
|
||||
TargetTuple = $(shell ${AbsTopSourceDir}/third_party/nlbuild-autotools/repo/autoconf/config.guess | sed -e 's/[[:digit:].]*$$//g')
|
||||
|
||||
# If the user has asserted COVERAGE, alter the configuration options
|
||||
# accordingly.
|
||||
|
||||
configure_OPTIONS = --with-examples=posix --enable-cli --enable-ncp
|
||||
|
||||
ifeq ($(COVERAGE),1)
|
||||
configure_OPTIONS = --enable-coverage
|
||||
configure_OPTIONS += --enable-coverage
|
||||
else
|
||||
configure_OPTIONS =
|
||||
configure_OPTIONS +=
|
||||
endif
|
||||
|
||||
# If the user has asserted DEBUG, alter the configuration options
|
||||
+9
-10
@@ -31,25 +31,24 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
# Always package (e.g. for 'make dist') these subdirectories.
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
posix \
|
||||
cc2538 \
|
||||
platforms \
|
||||
apps \
|
||||
$(NULL)
|
||||
|
||||
# Always build (e.g. for 'make all') these subdirectories.
|
||||
|
||||
if OPENTHREAD_EXAMPLES_POSIX
|
||||
SUBDIRS = posix
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_CC2538
|
||||
SUBDIRS = cc2538
|
||||
if OPENTHREAD_EXAMPLES
|
||||
SUBDIRS = \
|
||||
platforms \
|
||||
apps \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
# Always pretty (e.g. for 'make pretty') these subdirectories.
|
||||
|
||||
PRETTY_SUBDIRS = \
|
||||
posix \
|
||||
cc2538 \
|
||||
platforms \
|
||||
apps \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
|
||||
@@ -28,28 +28,36 @@
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
bin_PROGRAMS = \
|
||||
ot-cli \
|
||||
bin_PROGRAMS = \
|
||||
ot-cli \
|
||||
$(NULL)
|
||||
|
||||
ot_cli_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/cc2538/platform \
|
||||
ot_cli_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/platforms \
|
||||
$(NULL)
|
||||
|
||||
ot_cli_LDADD = \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/src/cli/libopenthread-cli.a \
|
||||
$(top_builddir)/examples/cc2538/platform/libopenthread-cc2538.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
ot_cli_LDADD = \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/src/cli/libopenthread-cli.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
-lstdc++ \
|
||||
$(NULL)
|
||||
|
||||
ot_cli_LDFLAGS = \
|
||||
-T $(top_srcdir)/examples/cc2538/platform/cc2538.ld \
|
||||
if OPENTHREAD_EXAMPLES_POSIX
|
||||
ot_cli_LDADD += \
|
||||
$(top_builddir)/examples/platforms/posix/libopenthread-posix.a \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ot_cli_SOURCES = \
|
||||
main.c \
|
||||
if OPENTHREAD_EXAMPLES_CC2538
|
||||
ot_cli_LDADD += \
|
||||
$(top_builddir)/examples/platforms/cc2538/libopenthread-cc2538.a \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ot_cli_SOURCES = \
|
||||
main.c \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -9,10 +9,9 @@ another emulated Thread device.
|
||||
## 1. Build
|
||||
|
||||
```bash
|
||||
$ cd openthread
|
||||
$ cd <path-to-openthread>
|
||||
$ ./bootstrap
|
||||
$ ./configure --enable-cli --with-examples=posix
|
||||
$ make
|
||||
$ make -f examples/Makefile-posix
|
||||
```
|
||||
|
||||
## 2. Start node 1
|
||||
@@ -26,8 +26,6 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread.h>
|
||||
#include <cli/cli-serial.h>
|
||||
#include <platform.h>
|
||||
@@ -38,7 +36,7 @@ void otSignalTaskletPending(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
PlatformInit();
|
||||
PlatformInit(argc, argv);
|
||||
otInit();
|
||||
otCliSerialInit();
|
||||
|
||||
@@ -28,25 +28,36 @@
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
bin_PROGRAMS = \
|
||||
ot-ncp \
|
||||
bin_PROGRAMS = \
|
||||
ot-ncp \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/posix/platform \
|
||||
ot_ncp_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/platforms \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_LDADD = \
|
||||
$(top_builddir)/src/ncp/libopenthread-ncp.a \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/examples/posix/platform/libopenthread-posix.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
-lstdc++ \
|
||||
ot_ncp_LDADD = \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/src/ncp/libopenthread-ncp.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
-lstdc++ \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_SOURCES = \
|
||||
main.c \
|
||||
if OPENTHREAD_EXAMPLES_POSIX
|
||||
ot_ncp_LDADD += \
|
||||
$(top_builddir)/examples/platforms/posix/libopenthread-posix.a \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_CC2538
|
||||
ot_ncp_LDADD += \
|
||||
$(top_builddir)/examples/platforms/cc2538/libopenthread-cc2538.a \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
ot_ncp_SOURCES = \
|
||||
main.c \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -26,8 +26,6 @@
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread.h>
|
||||
#include <ncp/ncp.h>
|
||||
#include <platform.h>
|
||||
@@ -38,7 +36,7 @@ void otSignalTaskletPending(void)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
PlatformInit();
|
||||
PlatformInit(argc, argv);
|
||||
otInit();
|
||||
otNcpInit();
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
0.5
|
||||
@@ -1,57 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
EXTRA_DIST = \
|
||||
Makefile-cc2538 \
|
||||
README.md \
|
||||
$(NULL)
|
||||
|
||||
# Always package (e.g. for 'make dist') these subdirectories.
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
platform \
|
||||
app \
|
||||
$(NULL)
|
||||
|
||||
# Always build (e.g. for 'make all') these subdirectories.
|
||||
|
||||
SUBDIRS = \
|
||||
platform \
|
||||
app \
|
||||
$(NULL)
|
||||
|
||||
# Always pretty (e.g. for 'make pretty') these subdirectories.
|
||||
|
||||
PRETTY_SUBDIRS = \
|
||||
platform \
|
||||
app \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -1,73 +0,0 @@
|
||||
# OpenThread CLI Example
|
||||
|
||||
This example application demonstrates a minimal OpenThread application
|
||||
that exposes the OpenThread configuration and management interfaces
|
||||
via a basic command-line interface. The steps below take you through
|
||||
the minimal steps required to ping one emulated Thread device from
|
||||
another emulated Thread device.
|
||||
|
||||
## 1. Build
|
||||
|
||||
Follow the [CC2538 example build instructions](../../README.md).
|
||||
|
||||
## 2. Start node 1
|
||||
|
||||
Open a terminal to UART0 on node 1 (115200 8-N-1).
|
||||
|
||||
Start OpenThread:
|
||||
|
||||
```bash
|
||||
> start
|
||||
Done
|
||||
```
|
||||
|
||||
Wait a few seconds and verify that the device has become a Thread Leader:
|
||||
|
||||
```bash
|
||||
> state
|
||||
leader
|
||||
Done
|
||||
```
|
||||
|
||||
View IPv6 addresses assigned to Node 1's Thread interface:
|
||||
|
||||
```bash
|
||||
> ipaddr
|
||||
fdde:ad00:beef:0:0:ff:fe00:0
|
||||
fe80:0:0:0:0:ff:fe00:0
|
||||
fdde:ad00:beef:0:558:f56b:d688:799
|
||||
fe80:0:0:0:f3d9:2a82:c8d8:fe43
|
||||
Done
|
||||
```
|
||||
|
||||
## 2. Start node 2
|
||||
|
||||
Open a terminal to UART0 on node 2 (115200 8-N-1).
|
||||
|
||||
Start OpenThread:
|
||||
|
||||
```bash
|
||||
> start
|
||||
Done
|
||||
```
|
||||
|
||||
Wait a few seconds and verify that the device has become a Thread Router:
|
||||
|
||||
```bash
|
||||
> state
|
||||
router
|
||||
Done
|
||||
```
|
||||
|
||||
## 3. Ping Node 1 from Node 2
|
||||
|
||||
```bash
|
||||
> ping fdde:ad00:beef:0:558:f56b:d688:799
|
||||
16 bytes from fdde:ad00:beef:0:558:f56b:d688:799: icmp_seq=1 hlim=64
|
||||
```
|
||||
|
||||
## 4. Want more?
|
||||
|
||||
You may note that the example above did not include any network parameter configuration, such as the IEEE 802.15.4 PAN ID or the Thread Master Key. OpenThread currently implements default values for network parameters, however, you may use the CLI to change network parameters, other configurations, and perform other operations.
|
||||
|
||||
See the [OpenThread CLI Reference README.md](../../../../src/cli/README.md) to explore more.
|
||||
@@ -1,55 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
bin_PROGRAMS = \
|
||||
ot-ncp \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/cc2538/platform \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_LDADD = \
|
||||
$(top_builddir)/src/ncp/libopenthread-ncp.a \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/examples/cc2538/platform/libopenthread-cc2538.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_LDFLAGS = \
|
||||
-T $(top_srcdir)/examples/cc2538/platform/cc2538.ld \
|
||||
$(NULL)
|
||||
|
||||
ot_ncp_SOURCES = \
|
||||
main.c \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nest Labs, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes the platform-specific initializers.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_H_
|
||||
#define PLATFORM_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This method performs all platform-specific initialization.
|
||||
*
|
||||
*/
|
||||
void PlatformInit(void);
|
||||
|
||||
/**
|
||||
* This method performs all platform-specific processing.
|
||||
*
|
||||
*/
|
||||
void PlatformProcessDrivers(void);
|
||||
|
||||
/**
|
||||
* This method initializes the alarm service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void PlatformAlarmInit(void);
|
||||
|
||||
/**
|
||||
* This method performs alarm driver processing.
|
||||
*
|
||||
*/
|
||||
void PlatformAlarmProcess(void);
|
||||
|
||||
/**
|
||||
* This method initializes the radio service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void PlatformRadioInit(void);
|
||||
|
||||
/**
|
||||
* This method performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void PlatformRadioProcess(void);
|
||||
|
||||
/**
|
||||
* This method initializes the random number service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void PlatformRandomInit(void);
|
||||
|
||||
/**
|
||||
* This method performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void PlatformSerialProcess(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // PLATFORM_H_
|
||||
@@ -31,28 +31,29 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
# Always package (e.g. for 'make dist') these subdirectories.
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
cli \
|
||||
ncp \
|
||||
cc2538 \
|
||||
posix \
|
||||
$(NULL)
|
||||
|
||||
# Always build (e.g. for 'make all') these subdirectories.
|
||||
|
||||
SUBDIRS = \
|
||||
if OPENTHREAD_EXAMPLES_POSIX
|
||||
SUBDIRS = posix
|
||||
endif
|
||||
|
||||
if OPENTHREAD_EXAMPLES_CC2538
|
||||
SUBDIRS = cc2538
|
||||
endif
|
||||
|
||||
noinst_HEADERS = \
|
||||
platform.h \
|
||||
$(NULL)
|
||||
|
||||
if OPENTHREAD_ENABLE_CLI
|
||||
SUBDIRS += cli
|
||||
endif
|
||||
|
||||
if OPENTHREAD_ENABLE_NCP
|
||||
SUBDIRS += ncp
|
||||
endif
|
||||
|
||||
# Always pretty (e.g. for 'make pretty') these subdirectories.
|
||||
|
||||
PRETTY_SUBDIRS = \
|
||||
cli \
|
||||
ncp \
|
||||
cc2538 \
|
||||
posix \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -32,7 +32,6 @@ lib_LIBRARIES = libopenthread-cc2538.a
|
||||
|
||||
libopenthread_cc2538_a_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
$(NULL)
|
||||
|
||||
@@ -48,7 +47,11 @@ libopenthread_cc2538_a_SOURCES = \
|
||||
|
||||
noinst_HEADERS = \
|
||||
cc2538-reg.h \
|
||||
platform.h \
|
||||
platform-cc2538.h \
|
||||
$(NULL)
|
||||
|
||||
if OPENTHREAD_BUILD_COVERAGE
|
||||
CLEANFILES = $(wildcard *.gcda *.gcno)
|
||||
endif # OPENTHREAD_BUILD_COVERAGE
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -1,7 +1,7 @@
|
||||
# OpenThread on CC2538 Example
|
||||
|
||||
This directory contains example applications and platform drivers for
|
||||
the [Texas Instruments CC2538][cc2538].
|
||||
This directory contains example platform drivers for the [Texas
|
||||
Instruments CC2538][cc2538].
|
||||
|
||||
[cc2538]: http://www.ti.com/product/CC2538
|
||||
|
||||
@@ -9,13 +9,6 @@ The example platform drivers are intended to present the minimal code
|
||||
necessary to support OpenThread. As a result, the example platform
|
||||
drivers do not necessarily highlight the platform's full capabilities.
|
||||
|
||||
## What's Included
|
||||
|
||||
Folder | Description
|
||||
-----------|-----------------------------------------
|
||||
`apps/cli` | Example application that exposes the CLI over UART
|
||||
`platform` | Minimal implementation of `otPlat*` APIs
|
||||
|
||||
## Toolchain
|
||||
|
||||
Download and install the [GNU toolchain for ARM
|
||||
@@ -28,7 +21,7 @@ Cortex-M][gnu-toolchain].
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./bootstrap
|
||||
$ make -f examples/cc2538/Makefile-cc2538
|
||||
$ make -f examples/Makefile-cc2538
|
||||
```
|
||||
|
||||
After a successful build, the `elf` files are found in
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <platform/alarm.h>
|
||||
#include "cc2538-reg.h"
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nest Labs, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file
|
||||
* This file includes the platform-specific initializers.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PLATFORM_CC2538_H_
|
||||
#define PLATFORM_CC2538_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cc2538-reg.h"
|
||||
|
||||
/**
|
||||
* This function initializes the alarm service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void cc2538AlarmInit(void);
|
||||
|
||||
/**
|
||||
* This function performs alarm driver processing.
|
||||
*
|
||||
*/
|
||||
void cc2538AlarmProcess(void);
|
||||
|
||||
/**
|
||||
* This function initializes the radio service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void cc2538RadioInit(void);
|
||||
|
||||
/**
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void cc2538RadioProcess(void);
|
||||
|
||||
/**
|
||||
* This function initializes the random number service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void cc2538RandomInit(void);
|
||||
|
||||
/**
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void cc2538SerialProcess(void);
|
||||
|
||||
#endif // PLATFORM_CC2538_H_
|
||||
@@ -33,13 +33,13 @@
|
||||
*/
|
||||
|
||||
#include <platform/serial.h>
|
||||
#include "platform.h"
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
void PlatformInit(void)
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
PlatformAlarmInit();
|
||||
PlatformRadioInit();
|
||||
PlatformRandomInit();
|
||||
cc2538AlarmInit();
|
||||
cc2538RadioInit();
|
||||
cc2538RandomInit();
|
||||
otPlatSerialEnable();
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ void PlatformProcessDrivers(void)
|
||||
{
|
||||
// should sleep and wait for interrupts here
|
||||
|
||||
PlatformSerialProcess();
|
||||
PlatformRadioProcess();
|
||||
PlatformAlarmProcess();
|
||||
cc2538SerialProcess();
|
||||
cc2538RadioProcess();
|
||||
cc2538AlarmProcess();
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/radio.h>
|
||||
#include "cc2538-reg.h"
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -35,7 +35,7 @@
|
||||
*/
|
||||
|
||||
#include <platform/random.h>
|
||||
#include "cc2538-reg.h"
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
static uint32_t s_state = 1;
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <openthread-types.h>
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/serial.h>
|
||||
#include "cc2538-reg.h"
|
||||
#include "platform-cc2538.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -29,10 +29,22 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief
|
||||
* This file includes the platform-specific initializers.
|
||||
* This file includes the posix platform-specific initializers.
|
||||
*/
|
||||
|
||||
#include <posix-platform.h>
|
||||
#ifndef PLATFORM_H_
|
||||
#define PLATFORM_H_
|
||||
|
||||
uint32_t NODE_ID = 1;
|
||||
/**
|
||||
* This function performs all platform-specific initialization.
|
||||
*
|
||||
*/
|
||||
void PlatformInit(int argc, char *argv[]);
|
||||
|
||||
/**
|
||||
* This function performs all platform-specific processing.
|
||||
*
|
||||
*/
|
||||
void PlatformProcessDrivers(void);
|
||||
|
||||
#endif // PLATFORM_H_
|
||||
@@ -32,9 +32,7 @@ lib_LIBRARIES = libopenthread-posix.a
|
||||
|
||||
libopenthread_posix_a_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/examples/posix/platform \
|
||||
-D_GNU_SOURCE \
|
||||
$(NULL)
|
||||
|
||||
@@ -42,20 +40,17 @@ libopenthread_posix_a_SOURCES = \
|
||||
alarm.c \
|
||||
logging.c \
|
||||
platform.c \
|
||||
posix-platform.c \
|
||||
radio.c \
|
||||
random.c \
|
||||
serial.c \
|
||||
$(NULL)
|
||||
|
||||
include_HEADERS = \
|
||||
posix-platform.h \
|
||||
noinst_HEADERS = \
|
||||
platform-posix.h \
|
||||
$(NULL)
|
||||
|
||||
install-headers: install-includeHEADERS
|
||||
|
||||
if OPENTHREAD_BUILD_COVERAGE
|
||||
CLEANFILES = $(wildcard *.gcda *.gcno)
|
||||
CLEANFILES = $(wildcard *.gcda *.gcno)
|
||||
endif # OPENTHREAD_BUILD_COVERAGE
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -0,0 +1,57 @@
|
||||
# OpenThread on POSIX Emulation Example
|
||||
|
||||
This directory contains example platform drivers for POSIX emulation.
|
||||
|
||||
## Build Examples
|
||||
|
||||
```bash
|
||||
$ cd <path-to-openthread>
|
||||
$ ./bootstrap
|
||||
$ make -f examples/Makefile-posix
|
||||
```
|
||||
|
||||
After a successful build, the `elf` files are found in
|
||||
`<path-to-openthread>/output/x86_64-apple-darwin/bin`.
|
||||
|
||||
##
|
||||
|
||||
## Interact
|
||||
|
||||
1. Spawn the process:
|
||||
|
||||
```bash
|
||||
$ cd openthread/examples/posix/app/cli
|
||||
$ ./ot-cli 1
|
||||
```
|
||||
|
||||
2. Type `help` for list of commands.
|
||||
|
||||
```bash
|
||||
> help
|
||||
help
|
||||
channel
|
||||
childtimeout
|
||||
contextreusedelay
|
||||
extaddr
|
||||
extpanid
|
||||
ipaddr
|
||||
keysequence
|
||||
leaderweight
|
||||
masterkey
|
||||
mode
|
||||
netdataregister
|
||||
networkidtimeout
|
||||
networkname
|
||||
panid
|
||||
ping
|
||||
prefix
|
||||
releaserouterid
|
||||
rloc16
|
||||
route
|
||||
routerupgradethreshold
|
||||
scan
|
||||
start
|
||||
state
|
||||
stop
|
||||
whitelist
|
||||
```
|
||||
@@ -32,13 +32,13 @@
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <platform/alarm.h>
|
||||
#include <posix-platform.h>
|
||||
#include "platform-posix.h"
|
||||
|
||||
static bool s_is_running = false;
|
||||
static uint32_t s_alarm = 0;
|
||||
static struct timeval s_start;
|
||||
|
||||
void posixPlatformAlarmInit(void)
|
||||
void posixAlarmInit(void)
|
||||
{
|
||||
gettimeofday(&s_start, NULL);
|
||||
}
|
||||
@@ -64,7 +64,7 @@ void otPlatAlarmStop(void)
|
||||
s_is_running = false;
|
||||
}
|
||||
|
||||
void posixPlatformAlarmUpdateTimeout(struct timeval *aTimeout)
|
||||
void posixAlarmUpdateTimeout(struct timeval *aTimeout)
|
||||
{
|
||||
int32_t remaining;
|
||||
|
||||
@@ -95,7 +95,7 @@ void posixPlatformAlarmUpdateTimeout(struct timeval *aTimeout)
|
||||
}
|
||||
}
|
||||
|
||||
void posixPlatformAlarmProcess(void)
|
||||
void posixAlarmProcess(void)
|
||||
{
|
||||
int32_t remaining;
|
||||
|
||||
+21
-41
@@ -32,17 +32,13 @@
|
||||
* This file includes the posix platform-specific initializers.
|
||||
*/
|
||||
|
||||
#ifndef POSIX_PLATFORM_H_
|
||||
#define POSIX_PLATFORM_H_
|
||||
#ifndef PLATFORM_POSIX_H_
|
||||
#define PLATFORM_POSIX_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Unique node ID.
|
||||
*
|
||||
@@ -56,83 +52,67 @@ extern uint32_t NODE_ID;
|
||||
extern uint32_t WELLKNOWN_NODE_ID;
|
||||
|
||||
/**
|
||||
* This method performs all platform-specific initialization.
|
||||
* This function initializes the alarm service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void posixPlatformInit(void);
|
||||
void posixAlarmInit(void);
|
||||
|
||||
/**
|
||||
* This method performs all platform-specific processing.
|
||||
*
|
||||
*/
|
||||
void posixPlatformProcessDrivers(void);
|
||||
|
||||
/**
|
||||
* This method initializes the alarm service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void posixPlatformAlarmInit(void);
|
||||
|
||||
/**
|
||||
* This method retrieves the time remaining until the alarm fires.
|
||||
* This function retrieves the time remaining until the alarm fires.
|
||||
*
|
||||
* @param[out] aTimeval A pointer to the timeval struct.
|
||||
*
|
||||
*/
|
||||
void posixPlatformAlarmUpdateTimeout(struct timeval *tv);
|
||||
void posixAlarmUpdateTimeout(struct timeval *tv);
|
||||
|
||||
/**
|
||||
* This method performs alarm driver processing.
|
||||
* This function performs alarm driver processing.
|
||||
*
|
||||
*/
|
||||
void posixPlatformAlarmProcess(void);
|
||||
void posixAlarmProcess(void);
|
||||
|
||||
/**
|
||||
* This method initializes the radio service used by OpenThread.
|
||||
* This function initializes the radio service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void posixPlatformRadioInit(void);
|
||||
void posixRadioInit(void);
|
||||
|
||||
/**
|
||||
* This method updates the file descriptor sets with file descriptors used by the radio driver.
|
||||
* This function updates the file descriptor sets with file descriptors used by the radio driver.
|
||||
*
|
||||
* @param[inout] aReadFdSet A pointer to the read file descriptors.
|
||||
* @param[inout] aWriteFdSet A pointer to the write file descriptors.
|
||||
* @param[inout] aMaxFd A pointer to the max file descriptor.
|
||||
*
|
||||
*/
|
||||
void posixPlatformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
|
||||
void posixRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
|
||||
|
||||
/**
|
||||
* This method performs radio driver processing.
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void posixPlatformRadioProcess(void);
|
||||
void posixRadioProcess(void);
|
||||
|
||||
/**
|
||||
* This method initializes the random number service used by OpenThread.
|
||||
* This function initializes the random number service used by OpenThread.
|
||||
*
|
||||
*/
|
||||
void posixPlatformRandomInit(void);
|
||||
void posixRandomInit(void);
|
||||
|
||||
/**
|
||||
* This method updates the file descriptor sets with file descriptors used by the serial driver.
|
||||
* This function updates the file descriptor sets with file descriptors used by the serial driver.
|
||||
*
|
||||
* @param[inout] aReadFdSet A pointer to the read file descriptors.
|
||||
* @param[inout] aWriteFdSet A pointer to the write file descriptors.
|
||||
* @param[inout] aMaxFd A pointer to the max file descriptor.
|
||||
*
|
||||
*/
|
||||
void posixPlatformSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
|
||||
void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd);
|
||||
|
||||
/**
|
||||
* This method performs radio driver processing.
|
||||
* This function performs radio driver processing.
|
||||
*
|
||||
*/
|
||||
void posixPlatformSerialProcess(void);
|
||||
void posixSerialProcess(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
|
||||
#endif // POSIX_PLATFORM_H_
|
||||
#endif // PLATFORM_POSIX_H_
|
||||
@@ -36,25 +36,33 @@
|
||||
#include <errno.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include <openthread.h>
|
||||
#include <platform/alarm.h>
|
||||
#include <platform/serial.h>
|
||||
#include <posix-platform.h>
|
||||
#include "platform-posix.h"
|
||||
|
||||
uint32_t NODE_ID = 1;
|
||||
uint32_t WELLKNOWN_NODE_ID = 34;
|
||||
|
||||
void posixPlatformInit(void)
|
||||
void PlatformInit(int argc, char *argv[])
|
||||
{
|
||||
posixPlatformAlarmInit();
|
||||
posixPlatformRadioInit();
|
||||
posixPlatformRandomInit();
|
||||
if (argc != 2)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NODE_ID = atoi(argv[1]);
|
||||
|
||||
posixAlarmInit();
|
||||
posixRadioInit();
|
||||
posixRandomInit();
|
||||
otPlatSerialEnable();
|
||||
}
|
||||
|
||||
void posixPlatformProcessDrivers(void)
|
||||
void PlatformProcessDrivers(void)
|
||||
{
|
||||
fd_set read_fds;
|
||||
fd_set write_fds;
|
||||
@@ -65,9 +73,9 @@ void posixPlatformProcessDrivers(void)
|
||||
FD_ZERO(&read_fds);
|
||||
FD_ZERO(&write_fds);
|
||||
|
||||
posixPlatformSerialUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixPlatformRadioUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixPlatformAlarmUpdateTimeout(&timeout);
|
||||
posixSerialUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixRadioUpdateFdSet(&read_fds, &write_fds, &max_fd);
|
||||
posixAlarmUpdateTimeout(&timeout);
|
||||
|
||||
if (!otAreTaskletsPending())
|
||||
{
|
||||
@@ -75,8 +83,8 @@ void posixPlatformProcessDrivers(void)
|
||||
assert(rval >= 0 && errno != ETIME);
|
||||
}
|
||||
|
||||
posixPlatformSerialProcess();
|
||||
posixPlatformRadioProcess();
|
||||
posixPlatformAlarmProcess();
|
||||
posixSerialProcess();
|
||||
posixRadioProcess();
|
||||
posixAlarmProcess();
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <platform/radio.h>
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include "posix-platform.h"
|
||||
#include "platform-posix.h"
|
||||
|
||||
enum
|
||||
{
|
||||
@@ -289,7 +289,7 @@ ThreadError otPlatRadioSetShortAddress(uint16_t address)
|
||||
return kThreadError_None;
|
||||
}
|
||||
|
||||
void posixPlatformRadioInit(void)
|
||||
void posixRadioInit(void)
|
||||
{
|
||||
struct sockaddr_in sockaddr;
|
||||
memset(&sockaddr, 0, sizeof(sockaddr));
|
||||
@@ -521,7 +521,7 @@ int radioTransmit(void)
|
||||
return rval;
|
||||
}
|
||||
|
||||
void posixPlatformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
|
||||
void posixRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
|
||||
{
|
||||
if (aReadFdSet != NULL &&
|
||||
(s_state == kStateDisabled || s_state == kStateSleep || s_state == kStateListen || s_state == kStateAckWait))
|
||||
@@ -545,7 +545,7 @@ void posixPlatformRadioUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int
|
||||
}
|
||||
}
|
||||
|
||||
void posixPlatformRadioProcess(void)
|
||||
void posixRadioProcess(void)
|
||||
{
|
||||
const int flags = POLLRDNORM | POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd = { s_sockfd, flags, 0 };
|
||||
@@ -35,11 +35,11 @@
|
||||
*/
|
||||
|
||||
#include <platform/random.h>
|
||||
#include <posix-platform.h>
|
||||
#include "platform-posix.h"
|
||||
|
||||
static uint32_t s_state = 1;
|
||||
|
||||
void posixPlatformRandomInit(void)
|
||||
void posixRandomInit(void)
|
||||
{
|
||||
s_state = NODE_ID;
|
||||
}
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
#include <common/code_utils.hpp>
|
||||
#include <platform/serial.h>
|
||||
#include <posix-platform.h>
|
||||
#include "platform-posix.h"
|
||||
|
||||
#ifdef OPENTHREAD_TARGET_LINUX
|
||||
int posix_openpt(int oflag);
|
||||
@@ -163,7 +163,7 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
void posixPlatformSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
|
||||
void posixSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int *aMaxFd)
|
||||
{
|
||||
if (aReadFdSet != NULL)
|
||||
{
|
||||
@@ -186,7 +186,7 @@ void posixPlatformSerialUpdateFdSet(fd_set *aReadFdSet, fd_set *aWriteFdSet, int
|
||||
}
|
||||
}
|
||||
|
||||
void posixPlatformSerialProcess(void)
|
||||
void posixSerialProcess(void)
|
||||
{
|
||||
const int flags = POLLRDNORM | POLLERR | POLLNVAL | POLLHUP;
|
||||
struct pollfd pollfd = { s_in_fd, flags, 0 };
|
||||
@@ -1,52 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
# Always package (e.g. for 'make dist') these subdirectories.
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
platform \
|
||||
app \
|
||||
$(NULL)
|
||||
|
||||
# Always build (e.g. for 'make all') these subdirectories.
|
||||
|
||||
SUBDIRS = \
|
||||
platform \
|
||||
app \
|
||||
$(NULL)
|
||||
|
||||
# Always pretty (e.g. for 'make pretty') these subdirectories.
|
||||
|
||||
PRETTY_SUBDIRS = \
|
||||
platform \
|
||||
app \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -1,52 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2016, Nest Labs, Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
# 1. Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# 2. Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# 3. Neither the name of the copyright holder nor the
|
||||
# names of its contributors may be used to endorse or promote products
|
||||
# derived from this software without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
#
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
|
||||
bin_PROGRAMS = \
|
||||
ot-cli \
|
||||
$(NULL)
|
||||
|
||||
ot_cli_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/examples/posix/platform \
|
||||
$(NULL)
|
||||
|
||||
ot_cli_LDADD = \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/src/cli/libopenthread-cli.a \
|
||||
$(top_builddir)/examples/posix/platform/libopenthread-posix.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
-lstdc++ \
|
||||
$(NULL)
|
||||
|
||||
ot_cli_SOURCES = \
|
||||
main.c \
|
||||
$(NULL)
|
||||
|
||||
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nest Labs, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread.h>
|
||||
#include <cli/cli-serial.h>
|
||||
#include <posix-platform.h>
|
||||
|
||||
void otSignalTaskletPending(void)
|
||||
{
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NODE_ID = atoi(argv[1]);
|
||||
|
||||
posixPlatformInit();
|
||||
otInit();
|
||||
otCliSerialInit();
|
||||
|
||||
while (1)
|
||||
{
|
||||
otProcessNextTasklet();
|
||||
posixPlatformProcessDrivers();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Nest Labs, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the copyright holder nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <openthread.h>
|
||||
#include <ncp/ncp.h>
|
||||
#include <posix-platform.h>
|
||||
|
||||
void otSignalTaskletPending(void)
|
||||
{
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
NODE_ID = atoi(argv[1]);
|
||||
|
||||
posixPlatformInit();
|
||||
otInit();
|
||||
otNcpInit();
|
||||
|
||||
while (1)
|
||||
{
|
||||
otProcessNextTasklet();
|
||||
posixPlatformProcessDrivers();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -54,7 +54,7 @@ class Node:
|
||||
""" Initialize a simulation node. """
|
||||
if "top_builddir" in os.environ.keys():
|
||||
srcdir = os.environ['top_builddir']
|
||||
cmd = '%s/examples/posix/app/cli/ot-cli' % srcdir
|
||||
cmd = '%s/examples/apps/cli/ot-cli' % srcdir
|
||||
else:
|
||||
cmd = './ot-cli'
|
||||
cmd += ' %d' % nodeid
|
||||
|
||||
+27
-27
@@ -32,60 +32,60 @@ include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
|
||||
# Local headers to build against and distribute but not to install
|
||||
# since they are not part of the package.
|
||||
#
|
||||
noinst_HEADERS = \
|
||||
test_util.h \
|
||||
test_util.hpp \
|
||||
test_vector.h \
|
||||
noinst_HEADERS = \
|
||||
test_util.h \
|
||||
test_util.hpp \
|
||||
test_vector.h \
|
||||
$(NULL)
|
||||
|
||||
#
|
||||
# Other files we do want to distribute with the package.
|
||||
#
|
||||
EXTRA_DIST = \
|
||||
EXTRA_DIST = \
|
||||
$(NULL)
|
||||
|
||||
if OPENTHREAD_BUILD_TESTS
|
||||
# C preprocessor option flags that will apply to all compiled objects in this
|
||||
# makefile.
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/third_party/mbedtls/repo/include \
|
||||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/include \
|
||||
-I$(top_srcdir)/src \
|
||||
-I$(top_srcdir)/src/core \
|
||||
-I$(top_srcdir)/third_party/mbedtls/repo/include \
|
||||
$(NULL)
|
||||
|
||||
COMMON_LDADD = \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/examples/posix/platform/libopenthread-posix.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
-lpthread \
|
||||
COMMON_LDADD = \
|
||||
$(top_builddir)/src/core/libopenthread.a \
|
||||
$(top_builddir)/examples/platforms/posix/libopenthread-posix.a \
|
||||
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
|
||||
-lpthread \
|
||||
$(NULL)
|
||||
|
||||
# Test applications that should be run when the 'check' target is run.
|
||||
|
||||
check_PROGRAMS = \
|
||||
test-aes \
|
||||
test-hmac-sha256 \
|
||||
test-lowpan \
|
||||
test-link-quality \
|
||||
test-mac-frame \
|
||||
test-message \
|
||||
test-timer \
|
||||
test-toolchain \
|
||||
check_PROGRAMS = \
|
||||
test-aes \
|
||||
test-hmac-sha256 \
|
||||
test-lowpan \
|
||||
test-link-quality \
|
||||
test-mac-frame \
|
||||
test-message \
|
||||
test-timer \
|
||||
test-toolchain \
|
||||
$(NULL)
|
||||
|
||||
# Test applications and scripts that should be built and run when the
|
||||
# 'check' target is run.
|
||||
|
||||
TESTS = \
|
||||
$(check_PROGRAMS) \
|
||||
TESTS = \
|
||||
$(check_PROGRAMS) \
|
||||
$(NULL)
|
||||
|
||||
# The additional environment variables and their values that will be
|
||||
# made available to all programs and scripts in TESTS.
|
||||
|
||||
TESTS_ENVIRONMENT = \
|
||||
TESTS_ENVIRONMENT = \
|
||||
$(NULL)
|
||||
|
||||
# Source, compiler, and linker options for test programs.
|
||||
|
||||
Reference in New Issue
Block a user