-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[linux] add ThreadStackManager for Linux Device layer #1320
Conversation
configure.ac
Outdated
# otbr-client | ||
# | ||
|
||
AC_ARG_ENABLE(otbr-client, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my mind "OpenThread Linux Client" would be 'otlc' ... alternatively could we make the command line argument longer to be easier to read?
Like 'openthread-border-router-client'? This abbreviation is not as intuitive, even though it follows the short repo name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my reply to Grant's comment, I've proposed to combine ENABLE_OPENTHREAD
and DEVICE_LAYER==Linux
to replace this option. The only concern is whether there will be other linux Thread solutions.
namespace Internal { | ||
|
||
/** | ||
* Ids for well-known network provision types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The items below contains IDs and lengths.
Could we separate them? Also lenghts are generally not enums. I believe it would be clearer if they would be constexpr, like:
constexpr int kThreadMeshPrefixLength = 8;
and similar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int -> size_t since lengths generally are not negative.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
kThreadMeshPrefixLength = 8, | ||
kThreadNetworkKeyLength = 16, | ||
kThreadPSKcLength = 16, | ||
kThreadChannel_NotSpecified = UINT8_MAX, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wny are channels and PANId mixed in the same anum with a different max? I find this a bit too data dependent: one assumes max 8 bit and one max 16 bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This enum is for defining constants. And the width of channel and panid is specified in the 15.4 standard. The channel is between 11 and 26 and the panid bust be 16 bits long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this may be an unusual enum usage. Enum seems to be an enumeration of distinct values. Here tehe values are not distinct (lengths may have similar values) and not as related.
I believe constexpr actual constants would be better than enums.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
public: | ||
// ---- Thread-specific Fields ---- | ||
char ThreadNetworkName[kMaxThreadNetworkNameLength + 1]; | ||
/**< The Thread network name as a NULL-terminated string. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we add some spacing here? I am used to having comments on top of thigs (like method comments) and as code is so tight together, it tents to make me believe that comments apply to the next item instead of the previous. Messes with my brain a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
case DeviceRole::OTBR_DEVICE_ROLE_ROUTER: | ||
case DeviceRole::OTBR_DEVICE_ROLE_LEADER: | ||
type = ConnectivityManager::ThreadDeviceType::kThreadDeviceType_Router; | ||
default: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should going to the default log an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
namespace chip { | ||
namespace DeviceLayer { | ||
|
||
class ThreadStackManagerImpl : public ThreadStackManager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we get some comments on what this does? I see it as an implementation of the tread stack using dbus to talk to the ble chip ... is that correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Thread network stack use the 802.15.4 radio rather than BLE. It's talking to the Thread border router daemon process otbr-agent
. This process is in charge of Thread network interface management and all the Thread border routing features.
src/platform/Makefile.am
Outdated
@@ -142,6 +142,18 @@ libDeviceLayer_a_SOURCES += \ | |||
Linux/SystemTimeSupport.cpp \ | |||
$(NULL) | |||
|
|||
if CHIP_WITH_OTBR_CLIENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also be conditioned with CHIP_ENABLE_OPENTHREAD
? Is it possible to have CHIP_ENABLE_OPENTHREAD
but not CHIP_WITH_OTBR_CLIENT
or vice versa?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the otbr-client
doesn't depend on the openthread
code. The current implementation of CHIP_ENABLE_OPENTHREAD
will download the openthread
code once enabled so I decided to add an extra option.
If otbr-client
is the only OpenThread solution for linux, maybe we can combine DEVICE_LAYER==LINUX
and CHIP_ENABLE_OPENTHREAD
to decide it.
configure.ac
Outdated
# otbr-client | ||
# | ||
|
||
AC_ARG_ENABLE(otbr-client, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this interplay with CHIP_ENABLE_OPENTHREAD
or vice versa?
src/platform/tests/Makefile.am
Outdated
@@ -68,13 +68,31 @@ AM_CPPFLAGS = \ | |||
$(NLUNIT_TEST_CPPFLAGS) \ | |||
$(NULL) | |||
|
|||
if CHIP_DEVICE_LAYER_TARGET_LINUX | |||
if CHIP_WITH_OTBR_CLIENT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See prior comments about CHIP_ENABLE_OPENTHREAD
.
CHIP_LDADD = \ | ||
$(top_builddir)/src/platform/libDeviceLayer.a \ | ||
$(top_builddir)/src/inet/libInetLayer.a \ | ||
$(top_builddir)/src/system/libSystemLayer.a \ | ||
$(top_builddir)/src/lib/support/libSupportLayer.a \ | ||
$(NULL) | ||
|
||
if CHIP_DEVICE_LAYER_TARGET_LINUX |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The block above is also conditioned with CHIP_WITH_OTBR_CLIENT
, why not this block?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some naming and conditional rationalization requested.
@gerickson @andy31415 The build flags |
Size increase report for "Build Examples [nRF]"
Full report output
|
Size increase report for "Build Examples [ESP32]"
Full report output
|
Size increase report for "Build Examples [main-build]"
Full report output
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- OT-BR-POSIX package needs to be capable of being sourced out of project.
- What happened to the openthread package dependency? I suspect OT-BR-POSIX takes care of that for POSIX systems; however, what about non-POSIX systems?
configure.ac
Outdated
# OpenThread | ||
# | ||
|
||
NL_WITH_OPTIONAL_INTERNAL_PACKAGE( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did we get rid of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we need to determine whether or not we are using the linux device layer, I added the --enable-openthread
option.
Maybe we can have both --enable-openthread
and --with-openthread
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't need both.
In autoconf, --enable-foo is equivalent to --with-foo and --disable-foo is equivalent to --without-foo or --with-foo=no. However, the added benefit of the --with-foo syntax is that an argument can be provided that is the location of the final artifacts for that package. The NL_WITH_PACKAGE family of constructs provides a convenience semantics around that --with-foo syntax by also providing --with-foo-libs and --with-foo-includes variants for formalizing FOO_CPPFLAGS, FOO_LDFLAGS, and FOO_LIBS.
src/platform/Makefile.am
Outdated
endif | ||
|
||
libDeviceLayer_a_CPPFLAGS += \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if I want to use an ot-br-posix package outside of CHIP, for example were Google integrating CHIP into a repo-managed project in which --with-ot-br-posix=${BUILD_ROOT}/tps/ot-br-posix
or some such?
This should be indirected via something like OT_BR_POSIX_CPPFLAGS
.
src/platform/Makefile.am
Outdated
|
||
libDeviceLayer_a_CPPFLAGS += \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/src \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See prior.
src/platform/tests/Makefile.am
Outdated
if CHIP_WITH_OT_BR_CLIENT | ||
AM_CPPFLAGS += \ | ||
$(DBUS_CFLAGS) \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See prior.
src/platform/tests/Makefile.am
Outdated
AM_CPPFLAGS += \ | ||
$(DBUS_CFLAGS) \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/src \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See prior.
src/platform/tests/Makefile.am
Outdated
if CHIP_WITH_OT_BR_CLIENT | ||
CHIP_LDADD += \ | ||
$(DBUS_LIBS) \ | ||
$(top_builddir)/third_party/ot-br-posix/libotbrclient.a \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See prior.
third_party/ot-br-posix/Makefile.am
Outdated
$(NULL) | ||
|
||
libotbrclient_a_CPPFLAGS = \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be fine as-is since you're already in the third_party
directory and building the source there; however, it wouldn't be harmful to indirect this through OT_BR_POSIX_CPPFLAGS
.
third_party/ot-br-posix/Makefile.am
Outdated
|
||
libotbrclient_a_CPPFLAGS = \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/include \ | ||
-I$(top_srcdir)/third_party/ot-br-posix/repo/src \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above.
The openthread package dependency is passed by the NRF build system(which is the only place it's used now). The autoconf option is for feature flag only now. This holds true for the current master as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we update the code to not use enums for constants but rather real constants (usually consexpr size_t or similar)?
@gerickson @andy31415 |
Problem
This PR adds ThreadStack manager in the linux device layer.
It relies on otbr-agent as the Thread daemon.
Summary of Changes
fixes #740