Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
gjc13 committed Jul 3, 2020
1 parent 741bdad commit c4a1658
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 210 deletions.
53 changes: 28 additions & 25 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1788,48 +1788,51 @@ fi
# otbr-client
#

AC_ARG_ENABLE(otbr-client,
[AS_HELP_STRING([--enable-otbr-client], [Enable OpenThread Linux client])],
NL_WITH_OPTIONAL_INTERNAL_PACKAGE(
[ot_br_posix],
[OT_BR_POSIX],
[ot_br_posix],
[-lot_br_client],
[
case "${enableval}" in
no|yes)
enable_otbr_client=${enableval}
;;
*)
AC_MSG_ERROR([Invalid value ${enableval} for --enable-java])
;;
esac
OT_BR_POSIX_CPPFLAGS="-I\${abs_top_srcdir}/third_party/ot-br-posix/repo/include/ -I\${abs_top_srcdir}/third_party/ot-br-posix/repo/src/"
OT_BR_POSIX_LDFLAGS="-L${ac_pwd}/third_party/ot-br-posix/"
OT_BR_POSIX_LIBS="-lot_br_client"
],
[ enable_otbr_client="no" ]
[
# Check for required nlfaultinjection headers.
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([dbus/client/thread_api_dbus.hpp],
[],
[
AC_MSG_ERROR(The OpenThread border router header "$ac_header" is required but cannot be found.)
])
AC_LANG_POP([C++])
]
)

AC_MSG_NOTICE("enable_otbr_client=${enable_otbr_client}")
AC_MSG_NOTICE("nl_with_ot_br_posix=${nl_with_ot_br_posix}")

if test "${enable_otbr_client}" = "yes"; then
maybe_otbr_client_dirstem="ot-br-posix"
otbr_client_dirstem="third_party/${maybe_otbr_client_dirstem}/repo"
if test "${nl_with_ot_br_posix}" = "internal" && test "${with_device_layer}" = "linux"; then
maybe_ot_br_posix_dirstem="ot-br-posix"
ot_br_posix_dirstem="third_party/${maybe_ot_br_posix_dirstem}/repo"

AC_MSG_NOTICE([attempting to create internal ${otbrclient_dirstem}])
AC_MSG_NOTICE([attempting to create internal ${ot_br_posix_dirstem}])

${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${otbr_client_dirstem}
${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${ot_br_posix_dirstem}

if test $? -ne 0; then
AC_MSG_ERROR([failed to create ${otbr_client_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
AC_MSG_ERROR([failed to create ${ot_br_posix_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
fi

# otbrclient requires dbus
PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.4)
AC_SUBST([DBUS_CFLAGS])
AC_SUBST([DBUS_LIBS])
else
maybe_otbr_client_dirstem=
maybe_ot_br_posix_dirstem=
fi

AC_SUBST(OTBR_CLIENT_SUBDIRS, [${maybe_otbr_client_dirstem}])
AM_CONDITIONAL([CHIP_WITH_OTBR_CLIENT], [test "${enable_otbr_client}" != "no"])
AC_SUBST(OT_BR_POSIX_SUBDIRS, [${maybe_ot_br_posix_dirstem}])
AM_CONDITIONAL([CHIP_WITH_OT_BR_POSIX], [test "${nl_with_ot_br_posix}" != "no"])

#
# Nlunit-test
Expand Down
150 changes: 0 additions & 150 deletions examples/lock-app/nrf5/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,7 @@ extern "C" {

#include "chipinit.h"
#include <AppTask.h>
#if CHIP_ENABLE_OPENTHREAD
#include <mbedtls/platform.h>
#include <openthread/cli.h>
#include <openthread/dataset.h>
#include <openthread/error.h>
#include <openthread/heap.h>
#include <openthread/icmp6.h>
#include <openthread/instance.h>
#include <openthread/link.h>
#include <openthread/platform/openthread-system.h>
#include <openthread/tasklet.h>
#include <openthread/thread.h>
#include <platform/CHIPDeviceLayer.h>
#include <support/logging/CHIPLogging.h>
#endif // CHIP_ENABLE_OPENTHREAD

using namespace ::chip;
using namespace ::chip::Inet;
Expand Down Expand Up @@ -214,148 +200,12 @@ int main(void)

#endif // defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT

<<<<<<< HEAD
ret = ChipInit();
if (ret != NRF_SUCCESS)
||||||| parent of d9660a4... new configure logic
NRF_LOG_INFO("Init CHIP stack");
ret = PlatformMgr().InitChipStack();
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("PlatformMgr().InitChipStack() failed");
APP_ERROR_HANDLER(ret);
}

#if CHIP_ENABLE_OPENTHREAD
NRF_LOG_INFO("Initializing OpenThread stack");

mbedtls_platform_set_calloc_free(calloc, free);
nrf_cc310_platform_abort_init();
nrf_cc310_platform_mutex_init();
mbedtls_platform_setup(NULL);
otHeapSetCAllocFree(calloc, free);

otSysInit(0, NULL);

// Configure multiprotocol to work with BLE.
{
uint32_t retval = multiprotocol_802154_mode_set(MULTIPROTOCOL_802154_MODE_FAST_SWITCHING_TIMES);

if (retval != NRF_SUCCESS)
{
NRF_LOG_INFO("multiprotocol 15.4 failed");
APP_ERROR_HANDLER(CHIP_ERROR_INTERNAL);
}
}

ret = ThreadStackMgr().InitThreadStack();
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("ThreadStackMgr().InitThreadStack() failed");
APP_ERROR_HANDLER(ret);
}

// Configure device to operate as a Thread sleepy end-device.
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("ConnectivityMgr().SetThreadDeviceType() failed");
APP_ERROR_HANDLER(ret);
}
#endif // CHIP_ENABLE_OPENTHREAD

NRF_LOG_INFO("Starting CHIP task");
ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("PlatformMgr().StartEventLoopTask() failed");
APP_ERROR_HANDLER(ret);
}

#if CHIP_ENABLE_OPENTHREAD
NRF_LOG_INFO("Starting OpenThread task");

// Start OpenThread task
ret = ThreadStackMgrImpl().StartThreadTask();
if (ret != CHIP_NO_ERROR)
=======
NRF_LOG_INFO("Init CHIP stack");
ret = PlatformMgr().InitChipStack();
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("PlatformMgr().InitChipStack() failed");
APP_ERROR_HANDLER(ret);
}

#if CHIP_ENABLE_OPENTHREAD
NRF_LOG_INFO("Initializing OpenThread stack");

mbedtls_platform_set_calloc_free(calloc, free);
nrf_cc310_platform_abort_init();
nrf_cc310_platform_mutex_init();
mbedtls_platform_setup(NULL);
otHeapSetCAllocFree(calloc, free);

otSysInit(0, NULL);

// Configure multiprotocol to work with BLE.
{
uint32_t retval = multiprotocol_802154_mode_set(MULTIPROTOCOL_802154_MODE_FAST_SWITCHING_TIMES);

if (retval != NRF_SUCCESS)
{
NRF_LOG_INFO("multiprotocol 15.4 failed");
APP_ERROR_HANDLER(CHIP_ERROR_INTERNAL);
}
}

ret = ThreadStackMgr().InitThreadStack();
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("ThreadStackMgr().InitThreadStack() failed");
APP_ERROR_HANDLER(ret);
}

// Configure device to operate as a Thread sleepy end-device.
ret = ConnectivityMgr().SetThreadDeviceType(ConnectivityManager::kThreadDeviceType_Router);
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("ConnectivityMgr().SetThreadDeviceType() failed");
APP_ERROR_HANDLER(ret);
}
#endif // CHIP_ENABLE_OPENTHREAD

NRF_LOG_INFO("Starting CHIP task");
ret = PlatformMgr().StartEventLoopTask();
if (ret != CHIP_NO_ERROR)
{
NRF_LOG_INFO("PlatformMgr().StartEventLoopTask() failed");
APP_ERROR_HANDLER(ret);
}

#if CHIP_ENABLE_OPENTHREAD
NRF_LOG_INFO("Starting OpenThread task");

// Start OpenThread task
ret = ThreadStackMgrImpl().StartThreadTask();
if (ret != CHIP_NO_ERROR)
>>>>>>> d9660a4... new configure logic
{
NRF_LOG_INFO("ChipInit() failed");
APP_ERROR_HANDLER(ret);
}
<<<<<<< HEAD
<<<<<<< HEAD
||||||| parent of d9660a4... new configure logic
#endif // CHIP_ENABLE_OPENTHREAD
=======
#endif // CHIP_WITH_OPENTHREAD
>>>>>>> d9660a4... new configure logic
||||||| parent of 062c503... Revert "new configure logic"
#endif // CHIP_WITH_OPENTHREAD
=======
#endif // CHIP_ENABLE_OPENTHREAD
>>>>>>> 062c503... Revert "new configure logic"

ret = GetAppTask().StartAppTask();
if (ret != NRF_SUCCESS)
Expand Down
20 changes: 8 additions & 12 deletions src/include/platform/internal/DeviceNetworkInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef DEVICE_NETWORK_INFO_H
#define DEVICE_NETWORK_INFO_H

#include <stddef.h>
#include <stdint.h>

namespace chip {
Expand All @@ -29,18 +30,13 @@ namespace Internal {
/**
* Ids for well-known network provision types.
*/
enum
{
kThreadNetworkId = 1,
kWiFiStationNetworkId = 2,
kMaxThreadNetworkNameLength = 16,
kThreadExtendedPANIdLength = 8,
kThreadMeshPrefixLength = 8,
kThreadNetworkKeyLength = 16,
kThreadPSKcLength = 16,
kThreadChannel_NotSpecified = UINT8_MAX,
kThreadPANId_NotSpecified = UINT16_MAX,
};
constexpr size_t kMaxThreadNetworkNameLength = 16;
constexpr size_t kThreadExtendedPANIdLength = 8;
constexpr size_t kThreadMeshPrefixLength = 8;
constexpr size_t kThreadNetworkKeyLength = 16;
constexpr size_t kThreadPSKcLength = 16;
constexpr size_t kThreadChannel_NotSpecified = UINT8_MAX;
constexpr size_t kThreadPANId_NotSpecified = UINT16_MAX;

class DeviceNetworkInfo
{
Expand Down
7 changes: 4 additions & 3 deletions src/platform/Linux/ThreadStackManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ using otbr::DBus::NeighborInfo;
namespace chip {
namespace DeviceLayer {

ThreadStackManagerImpl::ThreadStackManagerImpl(DBusConnection *aConnection) :
mThreadApi(nullptr), mConnection(aConnection), mNetworkInfo(), mAttached(false) {}
ThreadStackManagerImpl::ThreadStackManagerImpl(DBusConnection * aConnection) :
mThreadApi(nullptr), mConnection(aConnection), mNetworkInfo(), mAttached(false)
{}

CHIP_ERROR ThreadStackManagerImpl::_InitThreadStack()
{
Expand Down Expand Up @@ -174,7 +175,7 @@ bool ThreadStackManagerImpl::_IsThreadProvisioned()
return mNetworkInfo.ThreadNetworkName[0] != '\0';
}

void ThreadStackManagerImpl::_ClearThreadProvision()
void ThreadStackManagerImpl::_ErasePersistentInfo()
{
mNetworkInfo = Internal::DeviceNetworkInfo{};
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform/Linux/ThreadStackManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace DeviceLayer {
class ThreadStackManagerImpl : public ThreadStackManager
{
public:
ThreadStackManagerImpl(DBusConnection *aConnection);
ThreadStackManagerImpl(DBusConnection * aConnection);

CHIP_ERROR _InitThreadStack();
CHIP_ERROR _ProcessThreadActivity();
Expand All @@ -49,7 +49,7 @@ class ThreadStackManagerImpl : public ThreadStackManager

CHIP_ERROR _SetThreadProvision(const Internal::DeviceNetworkInfo & netInfo);

void _ClearThreadProvision();
void _ErasePersistentInfo();

bool _IsThreadProvisioned();

Expand Down
9 changes: 4 additions & 5 deletions src/platform/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,16 @@ libDeviceLayer_a_SOURCES += \
Linux/SystemTimeSupport.cpp \
$(NULL)

if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_POSIX
libDeviceLayer_a_SOURCES += \
Linux/ThreadStackManagerImpl.cpp \
$(NULL)
endif

libDeviceLayer_a_CPPFLAGS += \
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \
-I$(top_srcdir)/third_party/ot-br-posix/repo/src \
$(DBUS_CFLAGS) \
$(OT_BR_POSIX_CPPFLAGS) \
$(DBUS_CFLAGS) \
$(NULL)
endif

endif # CHIP_DEVICE_LAYER_TARGET_LINUX

Expand Down
11 changes: 6 additions & 5 deletions src/platform/tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,10 @@ AM_CPPFLAGS = \
$(NULL)

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_POSIX
AM_CPPFLAGS += \
$(DBUS_CFLAGS) \
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \
-I$(top_srcdir)/third_party/ot-br-posix/repo/src \
$(OT_BR_POSIX_CPPFLAGS) \
$(NULL)
libPlatformTests_a_SOURCES += TestThreadStackMgr.cpp
endif
Expand All @@ -87,11 +86,13 @@ CHIP_LDADD = \
$(NULL)

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OT_BR_POSIX
CHIP_LDADD += \
$(DBUS_LIBS) \
$(top_builddir)/third_party/ot-br-posix/libotbrclient.a \
$(OT_BR_POSIX_LDFLAGS) $(OT_BR_POSIX_LIBS) \
$(NULL)
endif
endif

COMMON_LDADD = \
libPlatformTests.a \
Expand All @@ -112,7 +113,7 @@ check_PROGRAMS = \
$(NULL)

if CHIP_DEVICE_LAYER_TARGET_LINUX
if CHIP_WITH_OTBR_CLIENT
if CHIP_WITH_OT_BR_POSIX
check_PROGRAMS += TestThreadStackMgr

TestThreadStackMgr_LDADD = $(COMMON_LDADD)
Expand Down
2 changes: 1 addition & 1 deletion third_party/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ SUBDIRS = \
$(NLIO_SUBDIRS) \
$(NLUNIT_TEST_SUBDIRS) \
$(MBEDTLS_SUBDIRS) \
$(OTBR_CLIENT_SUBDIRS) \
$(OT_BR_POSIX_SUBDIRS) \
$(NULL)

include $(abs_top_nlbuild_autotools_dir)/automake/post.am
Loading

0 comments on commit c4a1658

Please sign in to comment.