Compare commits

..

1095 Commits

Author SHA1 Message Date
Simon Lin 54b31928cf [cli] fix crash when full logs is on (#5408)
It is possible that log is printed before the Interpreter (UART or
CONSOLE) object is created when FULL LOGS is enabled. In such case, OT
crashes. This commit fixes this bug.
2020-08-18 08:43:12 -07:00
Jing Ma 962c06f8e7 [thread-cert] refactor case 5.5.4 using pktverify (#5331) 2020-08-17 22:37:30 -07:00
Jintao Lin 3f38068a71 [mac] change address filter and seek function to accept frame without PAN ID (#5389)
In 802.15.4-2015 spec Table 7-2, it is possible to receive frame with
destination address but without destination PAN ID. This commit
changes the address filter function to avoid dropping such frames.
2020-08-17 22:34:38 -07:00
Michael Spang 5e34b5062d [efr32] switch to proper config #include style (#5409)
Use the config specified on the command line, so that overriding this
with a project specific config doesn't cause preprocessor macro
redefinition errors.
2020-08-16 20:48:21 -07:00
Abtin Keshavarzian 9c8f0951df [udp6] fix 'Udp::Socket::Connect(uint16_t aPort)' (#5407) 2020-08-16 20:37:15 -07:00
Simon Lin 0729138e7b [otns] implement otPlatOtnsStatus for posix (#5357) 2020-08-16 20:36:24 -07:00
kangping 0e11f8bd9b [posix] fix typo in error handling on macOS (#5394) 2020-08-15 16:46:10 -07:00
Abtin Keshavarzian c923dff5c7 [non-copyable] remove empty destructor per style guide (#5401) 2020-08-15 14:38:21 -07:00
Abtin Keshavarzian 78d567a4f6 [mesh-forwarder] add new class 'ThreadLinkInfo' (#5399)
The `ThreadLinkInfo` mirrors the `otThreadLinkInfo` definition.
It is mostly used in `MeshForwarder` and `Mle` class. Here are
some related helper methods:
- New helper methods in `Ip6::MessageInfo` to get and set the
  link info as `ThreadLinkInfo`.
- Helper method `ThreadLinkInfo::SetFrom()` allows it to be set
  from a given `Mac::RxFrame`.
- Helper method `Message::SetLinkInfo()` allows message link info
  related fields (in message metadata) to be set/updated from a
  given `ThreadLinkInfo`.
2020-08-15 13:17:18 -07:00
Simon Lin 02c7c6440a [mle] fix FTD unable to restore link to parent (#5301) 2020-08-15 12:33:14 -07:00
Simon Lin c7cda1feb2 [github-actions] fix otns test failure (#5403) 2020-08-15 10:05:52 -07:00
Simon Lin d7a025cb91 [pretty] shfmt only git files (#5395) 2020-08-14 22:17:45 -07:00
Yakun Xu 8370395c47 [cli] remove multiple servers support (#5387) 2020-08-14 22:15:32 -07:00
Yakun Xu 16a5c52d9f [netdata] add api to check if joiner is in steering data (#5392) 2020-08-14 22:09:14 -07:00
Jing Ma bc195d1329 [thread-cert] refactor case 5.5.2 using pktverify (#5330) 2020-08-14 22:06:01 -07:00
Abtin Keshavarzian 1ad22bac21 [netif] add helper methods to init 'NetifUnicastAddress' (#5390)
This commit adds a group of `Init` methods in `NetifUnciastAddress`
for common initializations of a unicast address with different
parameters (origin, scope, prefix length, and preferred/valid flags).
2020-08-13 22:21:09 -07:00
Abtin Keshavarzian 9481634ccc [mle] use helper method 'Mac::GenerateRandomPanId()' (#5391) 2020-08-13 22:14:25 -07:00
Jing Ma 93243b5f1d [thread-cert] refactor case 5.8.2 and 5.8.3 using pktverify (#5291) 2020-08-12 23:18:33 -07:00
Abtin Keshavarzian 528f8a1208 [neighbor-table] move "neighbor changed callback" and signaling (#5385)
This commit moves the code related to `otNeighborTableCallback`
and signaling `NeighborTable::Event` to `NeighborTable` class
(from `MleRouter`).
2020-08-12 22:18:59 -07:00
Simon Lin 9dbebfc2fe [github-actions] run packet verification for multiple times (#5380)
This commit makes packet verification to run for multiple times.

Since now we are developing many packet verification scripts, this
commit can help us reduce the chance of merging a verification code
that could fail by chance, which is very often for packet verification
code.
2020-08-12 22:15:28 -07:00
Abtin Keshavarzian 1ad2c04bdb [build] add missing header in BUILD.gn (neighbor_table.hpp) (#5386) 2020-08-12 14:50:58 -07:00
Michael Spang a24737a2ad [build] update GN build file for OpenThread (#5358)
Add the CLI & configuration to the build file.
2020-08-12 10:27:52 -07:00
Li Cao 7dc3b2696a [github-action] change the way to upload coverage report (#5375) 2020-08-11 21:30:47 -07:00
Yakun Xu f2d026729d [posix] use raw mode for CLI (#5377)
This commit turns on CLI raw mode on POSIX platform, which is causing
some unstable issues in CI tests.
2020-08-11 13:23:34 -07:00
Jonathan Hui b47dda45cf [test] add test for router reattach with many routers 2020-08-11 13:22:01 -07:00
Jonathan Hui a6865e03e4 [mle] work around MLE Link Accept messages that are too large
This commit addresses an issue where the MLE Link Accept message may
be too large to fit within a single IEEE 802.15.4 frame. Thread
requires any MLE message transported using 6LoWPAN fragmentation to
also enable IEEE 802.15.4 MAC frame security. However, the purpose of
MLE Link Accept messages is to establish a secure link and cannot
itself be transported with IEEE 802.15.4 MAC frame security enabled.

An MLE Link Accept message may carry a Route64 TLV that has a length
dependent on the number of active routers in the network. When there
are many active routers, the Route64 TLV is large and the MLE Link
Accept message can no longer fit within a single IEEE 802.15.4
frame. The side effect is that a router coming out of reset will not
be able to diretly restore its router role and must first attach as an
end device.

This commit limits the size of a Route64 TLV when included in MLE Link
Accept messages. When the number of active routers is above a
threshold, some routers will be elided from the Route64 TLV and the
Router ID Sequence value is decremented. This allows the device coming
out of reset to restore its router role and retrieve the current
Route64 TLV in a subsequent message exchange.
2020-08-11 13:22:01 -07:00
Yakun Xu b5e17e07ee [mle] log handling parent request failures (#5355)
This commit adds a few logs when handling MLE Parent Request, so that
when a child failed to receive a response, the logs can tell what
happened.
2020-08-11 10:22:57 -07:00
Yakun Xu 66dcbac15d [mle] add discovery request callback (#5131)
This commit allows notifying the application a discovery request is
received, which is useful if the application wants to be more active
when a joiner comes.
2020-08-11 10:22:10 -07:00
Yakun Xu 644e0a30f7 [test] only check include/openthread for API version (#5370) 2020-08-11 10:18:25 -07:00
Abtin Keshavarzian 40c7a14b23 [mesh-forwarder] simplify 'FragmentPriorityList' (#5374)
This commit simplifies management of "Fragment Priority Entries"
defining a new class `FragmentPriorityList` with helper method to
allocate/find entries in/from the list. The `Entry` types is also
moved/defined as a nested type of `FragmentPriorityList`.
2020-08-11 10:17:05 -07:00
Zhanglong Xia 9af8fe8cc5 [cli] add cli commands to set unsecure port and link security (#5349) 2020-08-11 09:28:55 -07:00
Simon Lin ecd9436427 [scripts] add packet verification framework (#4428)
This commit introduces the packet verification (PV) framework for
certification tests.

- Add packet verification framework code

- Implement packet verification for cert 5.1.7 as a minimal
  example. There will be more 1.1/1.2 tests with PV submitted in the
  future.

- Download pre-built thread-wireshark binaries from
  openthread/wireshark/releases for packet dissecting (used by
  pyshark)

- Added a Github Action job for Packet Verification
2020-08-11 09:26:28 -07:00
Jonathan Hui 6dddd555e4 [style] clean up lingering NULL -> nullptr (#5373) 2020-08-10 14:28:07 -07:00
Jonathan Hui 376f35a49e [cli] add length check on dataset 'set' command (#5361) 2020-08-10 10:02:11 -07:00
Abtin Keshavarzian 07221dd85c [notifier] simplify how 'Notifier' emits events to core/internal modules (#5365)
This commit changes the way the `Notifier` class emits events to other
OpenThread core/internal modules by having `Notifier` directly invoke
their callbacks, i.e., `Notifier::EmitEvents()` uses a hard-coded list
of all core modules/objects that want to receive events and it then
directly calls `HandleNotifierEvents()` on each object.

This change replaces/removes the `Notifier::Receiver` model and
simplifies the approach (reduces code-size and memory/RAM use).

For external modules (or in case the new model cannot be used by an
internal module), `Notifier` still provides the `RegisterCallback()`
model.
2020-08-10 09:15:42 -07:00
Simon Lin e4a9281054 [otns] fix otns status emission built by cmake (#5362)
Seems the strong otPlatOtnsStatus is not used, but the weak
otPlatOtnsStatus was used in the original code if built by cmake.

This commit fixes this issue. Now both cmake and make builds
correctly.
2020-08-10 09:12:38 -07:00
Abtin Keshavarzian 36b9ecbf11 [neighbor-table] add 'NeighborTable' class (#5354)
This commit adds a `NeighborTable` class which provides helper methods
dealing with neighbor, e.g., finding a `Neighbor` (i.e., a `Child`
from `ChildTable`, a `Router` from `RouterTable`, or parent or parent
candidate entries), or iterating through all neighbors.  These methods
use the newly added `Neighbor::AddressMacther` to simplify the
implementation. The `NeighborTable` methods replace the similar ones
in `Mle` and `MleRouter`.
2020-08-10 09:07:52 -07:00
Abtin Keshavarzian 6c75a53bdc [topology] adding 'Neighbor::AddressMatcher' (#5354)
This commit adds new a type `Neighbor::AddressMactehr` which is used
to filter and find a neighbor (child/router) with a given MAC address
matching a given `Neighbor::StateFilter`. This new type helps simplify
related code in `ChildTable`/`RouterTbale`.
2020-08-10 09:07:52 -07:00
Jonathan Hui 5bac12f9d6 [network-diagnostic] fix ConnectivityTlv::GetParentPriority() (#5360) 2020-08-07 12:26:54 -07:00
Jonathan Hui 03bcb408f9 [network-data] add nullptr check in Iterate() (#5359) 2020-08-07 12:26:29 -07:00
Simon Lin c112b9351d [docs] fix typo fortkey (#5356) 2020-08-07 10:31:17 -07:00
Moandor 45713b0dd2 [build] exclude URL library where unused (#5351)
This sets the URL library to be included only in POSIX builds,
removing unnecessary dependencies.
2020-08-07 10:23:55 -07:00
Abtin Keshavarzian b06f4cad20 [mac-frame] misc enhancements and simplifications (#5348)
- Use array indexing style `mPsdu[index]`.
- Update `InitMacHeader()` to use `mLength` directly.
- Add `using ot::Encoding::LittleEndian`
- Simplify `HeaderIe` definition (use `union`).
- Simplify `VendorIe` (use `uint32_t` for OUI).
- Simplify processing of Header IE(s) (using index) in
  `FindPayloadIndex()`, `GetHeaderIe()`, and `AppendHeaderIe()`.
2020-08-07 10:22:36 -07:00
Simon Lin d7343c877b [style] change python yapf column_limit to 119 (#5339) 2020-08-06 21:40:24 -07:00
Jonathan Hui e810357adb [cli] support reading individual operational dataset values (#5344) 2020-08-06 11:52:35 -07:00
Jonathan Hui f8a6d52695 [cli] add '::' to end of mesh local prefix output (#5344) 2020-08-06 11:52:35 -07:00
Jonathan Hui 73afdadaa8 [cli] print channel mask with leading '0x' (#5344)
To be conssitent with intput format.
2020-08-06 11:52:35 -07:00
Abtin Keshavarzian 0af18a54ae [mac-frame] fix/enhance parsing of Header IEs (#5342)
This commit changes `MacFrame::FindPayloadIndex()`:

- Ensure that at least one Header IE is included when FCF indicates
  that Header IE is present.

- Detect error case where Header IE(s) are partially included.

- Handle the case where frame contains Header IE(s) but no data
  payload (spec does not require Header IE termination in this
  case).
2020-08-05 21:30:20 -07:00
Simon Lin 36926a610a [tests] add build test for OT_ASSERT=OFF (#5333)
This commit adds a build test without OT_ASSERT to catch compile issues.
- Add cmake option: OT_ASSERT=ON
- Add build test with OT_ASSERT=OFF
- Fixes 2 compile errors.
2020-08-05 21:29:28 -07:00
Abtin Keshavarzian b9040673c9 [dns-client] move 'QueryMetadata' as a a private nested type (#5345) 2020-08-05 21:09:41 -07:00
Nate Drake 73a874ff9f [cli] add docs for 'commissioner state' command (#5343) 2020-08-05 21:06:56 -07:00
Jonathan Hui 659cf55a5a [coap] reduce OT_COAP_MAX_RETRANSMIT to 20 (#5338)
Also add a note to clarify the set of valid CoAP transmission
parameters.
2020-08-05 21:06:15 -07:00
Krzysztof Bogucki 3c132d4620 [ncp] fix spinel encrypter compilation errors after recent refactoring (#5341) 2020-08-05 13:00:53 -07:00
Krzysztof Bogucki 7183b24e65 [build] add SPINEL_ENCRYPTER_LIBS option to common switches (#5334)
This option allows to pass Spinel Encrypter library to predefined
Makefiles for different platforms.

Example usage:
make -f examples/Makefile-nrf52840 SPINEL_ENCRYPTER_LIBS=my_encrypter_lib.a
2020-08-05 12:59:28 -07:00
Abtin Keshavarzian 1cdb0e7767 [child-table] move child related methods to 'ChildTable' (#5335)
This commit moves `GetChildInfoById()`, `GetChildInfoByIndex()`, and
`HasSleepyChildWithAddress()`, along with methods for saving/restoring
child entries in/from non-volatile settings (e.g., `Restore()`,
`RemoveStoredChild()`, etc.) from `Mle` module to `ChildTable`. It also
removes/inlines the `MleRouter::IsSleepyChildSubscribed()` method.
2020-08-04 21:41:36 -07:00
Abtin Keshavarzian 3cd5f49d71 [encoding] add '{Read/Write}Uint24()` (#5329)
This commit adds `ReadUint24()`, `WriteUint24()` in `encoding.hpp`
for both little and big endian formats. These methods are then used
for reading/writing OUI in `MechCop::Tlv` sub-classes. This commit
also adds a check in `DiscoverScanner` to ensure the given OUI in
`SetJoinerAdvertisement` is within the valid range.
2020-08-04 09:07:25 -07:00
Abtin Keshavarzian 481f69703b [topology] define 'Neighbor::Info', 'Child::Info', and 'Router::Info' (#5328)
This commit adds new class definitions in `topology` to represent
neighbor/child/router info.
2020-08-03 21:33:34 -07:00
Simon Lin 5c6c798576 [scripts] add live capture for sniffer.py on simulation traffic (#5327)
This commit enhances sniffer.py so that we can use it as a standalone
sniffer for non Virtual Time simulations.
2020-08-03 09:25:14 -07:00
Abtin Keshavarzian be288331ac [mle-router] simplify 'GetNeighbor(const Ip6::Address &)' (#5326)
This commit simplifies `MleRouter:GetNeighbor(const Ip6::Address &)`
handling of mesh-local router locator IPv6 addresses.
2020-08-03 09:06:18 -07:00
Abtin Keshavarzian 471129460e [udp6] adding new flavors of Bind() and Connect() in Socket (#5319)
This commit adds new flavors of methods `Bind()` and `Connect()` in
`Udp6::Socket` allowing user to only specify a port number or provide
no input (address and/or port are determined by the UDP module itself
when not provided). The new methods help simplify `Socket` use in
different modules. This commit also enhances `SockAddr` class adding
new constructors to allow a `SockAddr` instance to be initialized with
a given port number or a given IPv6 address and port number.
2020-08-03 08:53:07 -07:00
Yuwen Lan addb1936c3 [joiner-adv] initial implementation of Joiner Advertisement (#5299)
This commit implements Thread based Joiner Advertisement from Joiner
side, including:

- A new MeshCop TLV: Joiner Advertisement TLV which includes IEEE OUI
  and the Advertisement Data.

- New APIs to set Joiner Advertisement which will be sent along with
  Discovery Request messages.
2020-08-03 08:38:58 -07:00
Rongli Sun b2f7414dac [dua] fix 1.2 compile issue without DUA flag (#5325) 2020-08-03 08:35:42 -07:00
Abtin Keshavarzian 3b6eb7de42 [core] use range-based 'for' loop (#5323) 2020-08-01 12:24:26 -07:00
Jonathan Hui 3b877e54ae [posix] fix macOS build with PLATFORM_NETIF=1 (#5318) 2020-08-01 10:54:20 -07:00
Jonathan Hui 075017bedc [commissioner] add 'state' CLI command (#5317) 2020-08-01 10:50:07 -07:00
Abtin Keshavarzian ccbb304969 [ip6] remove unused mScopeId from otSockAddr (#5316) 2020-08-01 10:40:49 -07:00
Abtin Keshavarzian cca72a660f [network-data] enhance OnMeshPrefix/ExternalRoute/Service configs (#5315)
This commit updates `OnMeshPrefixConfig` and `ExternalRouteConfig` to
be `Equatable`. It also adds a `ServerConfig` and adds overloads of
operator `==` to `Service/Server` configs. It also adds new method
`SetFrom()` to all configuration types to set them from a given set of
related TLVs.
2020-08-01 10:35:47 -07:00
Yakun Xu 114a0e7dc7 [posix] add UART flush and clean up (#5312)
This commit mainly implements the otPlatUartFlush().
- fix code because MSG_NOSIGNAL is not a macro.
- set SO_NOSIGPIPE once.
2020-08-01 09:41:58 -07:00
kangping f0f924a747 [tests] fix external commissioner building options (#5321)
This commit aligns the external commissioner building options with OT
commissioner.
2020-08-01 09:38:27 -07:00
Simon Lin 6488b25484 [netif] check address type when adding addresses (#5297) 2020-07-31 09:33:48 -07:00
Rongli Sun 82e7e32bb5 [dua] dua registration and re-registration (#5276)
- registration workflow framework
- registration and reregistration
- registration and reregistration on behalf of children
- add pseudo response status for test/certification purpose
- add unit test
2020-07-30 14:10:22 -07:00
Abtin Keshavarzian 8c094c6ac2 [ip6] adding Ip6::Prefix class (#5306)
This commit adds `Ip6::Prefix` class as a sub-class of `otIp6Prefix`
representing an IPv6 Prefix. Helper methods are provided in `Prefix`
and `Address` to perform prefix matching.

Different core modules such as `network-data`, `lowpan`, `dhcp6`,
`slaac`, and, `backbone-router` are updated to use the new `Prefix`
and its helper methods.

This commit also updates the unit test `test_ip6_address` to verify
behavior of `Prefix` and its helper methods.
2020-07-30 08:25:02 -07:00
Simon Lin b49ee0879a [posix] ot-ctl process lines for non-interactive mode (#5134)
This commit enhances ot-ctl to process only after a full line is read
in non-interactive mode.

This eliminates the complex and error-prone states handling, which
still has potential issues (despite of small chance):

- If Done\r\n is received in two chunks: Done\r and \n, the original
  implementation won't output \n

- If Error 7: InvalidArgs is received in two chunks: Error and 7:
  InvalidArgs, the original implementation won't output 7: InvalidArgs
2020-07-29 11:38:28 -07:00
Moandor 0ef8f510c5 [test] fix network name capturing in expect scripts (#5284)
This fixes some expect test failures caused by the following scenario:
Sometimes the command prompt > can be put after the echo of the input
command when inputs come too fast, because we are sending the next
command as soon as we see Done, we don't wait for the next > .

This commit adds expect "> " before sending the command to fix this.
2020-07-29 11:36:06 -07:00
Li Cao 7fe1d29ab4 [cmake] fix link issues of unit tests (#5309)
I think openthread-ncp-ftd is added to unit tests' link libraries by
mistake. It's not required and as it depends on OT_PLATFORM, it would
cause openthread-simulation linked in unit test executables, which
would lead to a redefinition as some methods are defined in
test-platform.cpp.
2020-07-29 11:24:57 -07:00
Abtin Keshavarzian 1dd46f9d93 [posix] fix netif use of IPv6 Prefix Match method (#5305) 2020-07-28 10:48:18 -07:00
Simon Lin d46c03b588 [bit-vector] refactor methods (#5302)
This commit refactors BitVector to use one method for setting or
clearing masks.
2020-07-28 09:09:52 -07:00
Abtin Keshavarzian 89b657cc60 [dhcp6] misc enhancements (#5294)
This commit contains a bunch of smaller changes and enhancements
in dhcp6 modules:

- Add and use `TransactionId` class.
- Rename header to `Dhcp6::Header` and update `Dhcp6::Type`.
- Rename server/client to `Dhcp6::Server` and `Dhcp6::Client`.
- Rename/update `DuidType` constants.
- Use `Mac::ExtAddress` as link address in `Server/ClinetIndentifer`.
- Use `Ip6::Address` instead of `otIp6Address`.
- Add `enum` constants for default values (remove `#define`)
- Define `IdentityAssociation` as nested type of `Client`.
- Update documentation.
2020-07-28 08:33:52 -07:00
Simon Lin 1081b45bec [mlr] Parent send MLR.req on behalf of Children (#5236)
This commit implements parents sending MLR.req on behave of Children.

- Parent sends MLR.req for Children after delaying for a random time <
  PARENT_AGGREGATE_DELAY (5s).
- Update test script to check for proxied MLR.req
- Parent proxy MLR.req for Children after a delay t in [0, 5]
2020-07-27 20:29:08 -07:00
Yakun Xu cbf1a19483 [cli] support joiner discerner (#5298)
This commit adds support joiner discerner in CLI. The format of joiner
discerner is `number/length`. For example `0xabc/12` means the discerner
value is `0xabc` and the length is `12`.
2020-07-27 20:27:21 -07:00
Rongli Sun 2117dae5f8 [mle] kAppendMeshLocalOnly for Child Update Request when detached (#5295)
When the child reboot, only register the mesh local address to avoid
possible large Child Update Response which would be fragmented, thus
avoiding reattach process.
2020-07-26 22:16:13 -07:00
Jonathan Hui c5e7252fed [docs] update Docker badge to GitHub Action (#5287) 2020-07-24 22:47:58 -07:00
Simon Lin adde385643 [netif] enhance IterateExternalMulticastAddresses (#5277)
This commit enhances IterateExternalMulticastAddresses to use further
filter external multicast addresses.
2020-07-24 22:47:18 -07:00
Abtin Keshavarzian ac86fe52e6 [bit-vector] add missing header includes (#5289) 2020-07-23 22:56:03 -07:00
Li Cao 692511070f [data-poll-handler] fix doc typo for DataPollHandler::Callbacks (#5288) 2020-07-23 22:55:24 -07:00
Abtin Keshavarzian 25c058d8ad [mle] use newly added Netif::IterateExternalMulticastAddresses (#5286)
This commit updates `Mle` class to use the newly added `Netif`
iterator for external multicast addresses. It also adds a helper
method in `Netif` to indicate if it is subscribed to any external
multicast address.
2020-07-23 22:53:55 -07:00
Simon Lin fd66f2399f [thci] add OpenThread_BR THCI for OTBR CLI (#5085) 2020-07-23 16:34:19 -07:00
Abtin Keshavarzian c89fd9a8f5 [mesh-forwarder] simplify GetFramePriority() (#5282)
This commit simplifies the `GetFramePriority()` implementation
mainly avoiding copying of ICMP6/UDP header when possible.

It also updates unit test `test-toolchain` to verify alignment
behavior of packed structure.
2020-07-23 12:54:44 -07:00
Abtin Keshavarzian 2efe99c507 [child] enhance Child::AddressIterator (#5269)
This commit enhances the iterator `Child::AddressIterator` which is
used to iterate over IPv6 address list of a `Child`. The new model
enables range-based `for` loops to be used. It also enables filtering
addresses based on type (e.g., iterate over multicast addresses only).
The unit test `test_child.cpp` is also updated to verify the newly
added functionalities of `AddressIterator`.
2020-07-23 12:16:45 -07:00
Jonathan Hui 7a612437ed [github-actions] add building Docker images (#5273)
The openthread/environment and openthread/codelab_sim images are
currently built and updated via the Docker Hub service. Docker Hub
only allows a single runner at a time and is generally slower than
GitHub Actions.

This commit moves the Docker image build and update to GitHub Actions.
2020-07-23 10:49:55 -07:00
Simon Lin d14a14a494 [core] add BitVector template class (#5267) 2020-07-23 00:33:09 -07:00
Kamil Kasperczyk 6640e7d865 [cmake] added ncp vendor hook include directories for .hpp files from src (#5275)
Added include directories to enable including .hpp ncp files
outside src directory, what is needed for vendor hooks concept.

Signed-off-by: Kamil Kasperczyk <kamil.kasperczyk@nordicsemi.no>
2020-07-22 23:19:36 -07:00
Abtin Keshavarzian 90db2d2ee7 [core] replace memcpy with assignment (#5280)
Also remove few unncessary uses of `this` pointer.
2020-07-22 17:17:47 -07:00
Abtin Keshavarzian bd197d3f47 [settings] use Equatable/Clearable in Settings structures (#5281) 2020-07-22 16:05:44 -07:00
Jonathan Hui 85de837187 [github-actions] fix external-commissioner test (#5279)
- Install avahi-daemon and avahi-utils packages.
- Remove ot-br-posix dependencies.
2020-07-22 14:09:03 -07:00
Piotr Koziar a374905a1d [nrf_security] remove inconsistency from nrf_security config file (#5265) 2020-07-22 10:05:59 -07:00
Abtin Keshavarzian 812eeee027 [settings] enhance Settings::ChildInfoIterator (#5272)
This commit updates `ChildInfoIterator` in `Settings` class to
enable range-based `for` loop.
2020-07-22 08:48:12 -07:00
Abtin Keshavarzian df2fa4c548 [router-table] add documentation for Iterate() method (#5270) 2020-07-22 08:40:22 -07:00
Simon Lin 00f3043a06 [mlr] send MLR.req for local multicast addresses (#5248)
This commit includes:

- Adding compile configurations necessary for MLR features
- Adding source/header files necessary for MLR features
- Send MLR.req for local MAs on ThreadNetif
  - At most one MLR.req is outstanding
  - Reregistration according to PBBR configuration
  - Renewing periods according to PBBR configuration
- BBRs receive MLR.req with minimal processing and send MLR.rsp
- Add a test to verify that MLR.req is sent for local MAs.
2020-07-22 08:38:05 -07:00
Simon Lin 2129b567b4 [otns] emit device mode (#5268)
This commit allows OTNS to correctly visualize node mode when it
changes.
2020-07-21 23:09:18 -07:00
Simon Lin 5e9b2818eb [style] convert to C++11 for loops (#5263) 2020-07-21 09:41:40 -07:00
Rongli Sun 57ee45be21 [mle] enhance IsExpectedToBecomeRouter() (#5261) 2020-07-20 23:27:56 -07:00
Rongli Sun 5f01bc48f5 [dua] apply DUA logging region (#5262) 2020-07-20 23:26:12 -07:00
Rongli Sun 8d1060fb60 [logging] Add DUA region (#5262) 2020-07-20 23:26:12 -07:00
Rongli Sun 6c1abeab90 [mle] add mHasRestored flag (#5228)
This commit introduces the mHasRestored flag and a common
HasRestored() method as devices may decide to introduce some
jitter/randomization to avoid the burst of traffic in cases a bunch of
devices nearby resets/reboots together.
2020-07-20 23:24:57 -07:00
Abtin Keshavarzian 2d38c59a5a [key-manager] add GenerateRandom() to MasterKey class (#5260) 2020-07-20 23:19:10 -07:00
Rongli Sun c0442e88e8 [address-resolver] TimeSinceLastTransaction should be in seconds (#5264) 2020-07-20 23:07:29 -07:00
Abtin Keshavarzian ceb63f97d5 [router-table] enable use of range-based "for" loop (#5254)
This commit updates `RouterTable` class to add support for using
range-based "for" loops to iterate over all routers.
2020-07-20 08:42:01 -07:00
Jing Ma e8fe3bd6e7 [thread-cert] deprecate certification test case 5.5.8, 5.6.8, 5.8.1 (#5246)
5.5.8, 5.6.8 and 5.8.1 were deprecated in Thread Certification test plan.
2020-07-20 08:40:04 -07:00
Abtin Keshavarzian d5370ac4cd [ip6] define NetworkPrefix type (#5213)
This commit adds `Ip6::NetworkPrefix` mirroring `otIp6NetworkPrefix`
which represents the Network Prefix (most significant 64 bits) of an
IPv6 address. Methods in `Ip6::Address` are updated to use the new
type. The `otMeshLocalPrefix` and `Mle::MeshLocalPrefix` are also
updated use the `NetworkPrefix` type.
2020-07-20 08:38:16 -07:00
Simon Lin 434e6bbffc [logging] add MLR log region (#5250) 2020-07-17 08:53:40 -07:00
Jonathan Hui 85af5f1963 [meshcop] do not allow timestamp rollback on leader (#5249) 2020-07-17 08:50:09 -07:00
Jonathan Hui c394080617 [ncp] only allow promiscuous mode in link raw mode (#5245)
Many existing IEEE 802.15.4 radios do not support both promiscuous
mode and auto generation of immediate ACKs. This commit prevents
promiscuous mode when the interface is up.
2020-07-17 08:49:51 -07:00
Abtin Keshavarzian a1f0b21c16 [coap-secure] inline simpler methods (#5255) 2020-07-17 08:49:10 -07:00
Abtin Keshavarzian 77d35929ce [dns/sntp-client] use Instance as a constructor parameter (#5253) 2020-07-17 08:47:52 -07:00
kangping c6d5c4aae0 [dtls] increase maximum length of DTLS application data (#5125)
This commit increases the maximum allowed length of DTLS application
data from 512 bytes to 1152 bytes.

The maximum possible length of application data is just around 512
bytes, and we observed that a Client Hello with cookie encoded in
RLY_RX.ntf message could be 520 bytes.
2020-07-16 11:17:02 -07:00
Simon Lin d2a625eb41 [logging] fix typo in comments (#5251) 2020-07-16 08:52:25 -07:00
Yaoxing Shan a67fa9b5e7 [docs] add Chinese translation for Thread Primer (#5106) 2020-07-16 08:44:02 -07:00
Yakun Xu 89cd4b59f8 [url] move url to library (#5233)
This commit moves the URL parser to src/lib.

Also includes the following changes:
- Split URL on initialization.
- Make a GetValue() const method.
- Check aLastValue.
- Add some negative tests.
2020-07-15 23:39:02 -07:00
Abtin Keshavarzian 4e8836cbec [child-table] enable use of range-based "for" loop (#5239)
This commit updates `ChildTable` class. It mainly adds support for
using range-based `for` loops to iterate over all child entries
(matching a given state filter). It also simplifies the `Iterator`
implementation (removing the now unused behavior to start the
iteration from a specific child in the table). The unit test
`test_child_table` is also updated to add tests for the newly added
behavior.
2020-07-15 23:07:16 -07:00
Moandor 6e98f3bb5b [test] move expect timeout settings to _common.exp (#5242)
This moves all settings of timeout to one place. Also changes the
default timeout to 10 seconds, can probably solve the occasional
timeout when dataset commit active.
2020-07-15 20:57:56 -07:00
Bob MacDonald b6027f9e65 [efr32] fix build errors due to recent change of otUdp APIs (#5243)
The commit which resulted in the compilation issues is: dc1d47
2020-07-15 14:37:12 -07:00
Rongli Sun 32618835c2 [bbr] rename as HandleBackboneRouterPrimaryUpdate (#5240) 2020-07-15 12:25:58 -07:00
Rongli Sun daf89169c6 [bbr] rename file name with bbr_ prefix (#5240) 2020-07-15 12:25:58 -07:00
Yakun Xu 4886b53b5c [github-action] remove unused apt source lists (#5237)
These sources break easily, removing them so that apt-get update
doesn't fail.
2020-07-15 10:48:23 -07:00
Yakun Xu bd3332810a [script] use real time when run expect tests (#5130) 2020-07-15 10:47:29 -07:00
Mason Tran 5ce29eb89c [efr32] fix otPlatRadioGetRssi() for MG1, MG12, MG13 (#5238)
This fixes an issue with Channel Monitoring for the EFR32 platform
(MG1, MG12, MG13), where in, turning the radio to a new channel and
immediately gathering background RSSI information was returning
invalid results.

A further investigation with the RAIL team indicated that this issue
was occurring because the usage of `RAIL_GetRssi()` is
incorrect. While the Rail_GetRssi API functions as documented, the
problem is that the current implementation of this API returns valid
results only in certain specified radio states and does not fit the
use case for the OpenThread Channel Monitoring feature. (i.e computing
RSSI value in the RxWarm radio state).

To fix the issue, I am switching the affected platforms to the
efr32mg21 implementation for `otPlatRadioGetRssi()`, which uses
`RAIL_StartAverageRssi()` instead of
`RAIL_GetRssi()`. `RAIL_StartAverageRssi()` uses hardware to trigger
an interrupt once the RSSI is valid and should provide valid results.

This approach was added by Marven when testing DMP support with
OpenThread (https://github.com/openthread/openthread/pull/4321)
2020-07-14 20:48:54 -07:00
Simon Lin 51f9d2cb9d [tests] ignore unknown TLV (#5232)
This commit ignores unknown TLVs when parsing a message and continues
to parse the rest parts of the message.

An unknown TLV can cause the simulator to drop the whole packet, which
could lead to packet parsing issues.  For example, if a Child ID
Response message is dropped, the dissector will fail to add the Short
Address and Extended Address to the Device Descriptors, causing
subsequent secure packets unable to be decrypted.
2020-07-14 20:40:34 -07:00
Yakun Xu b88f4fccba [flash] avoid build when not needed (#5235) 2020-07-14 10:04:12 -07:00
Abtin Keshavarzian dc1d47d2c0 [udp6] update UDP socket definitions (#5231)
This commit updates the  public OT `otUdp{}` (like `otUdpConnect`, or
`otUpdSend()`) functions to requires a pointer the OpenThread instance
to be passed as their first parameter (this harmonizes the definitions
with other public APIs and removes the need for `otUdpSocket` to track
the instance).

The core implementation in `udp6` module is updated to define
`SocketHandle` as an internal mirror of `otUdpSocket` structure. The
socket related methods `Open`(), `Bind()`, `Connect()`, etc., are
moved to `Udp` class itself (with a `SocketHandle` passed as a
parameter). For core internal use `Socket` class is defined as a
sub-class of `SocketHandle` and `InstanceLocator` providing same
helper methods. The separation between `SocketHandle` and `Socket`
type addresses the problem that can be caused by the treating/casting
publicly provided `otUdpSockt` objects as `InstanceLocator`.
2020-07-14 10:03:03 -07:00
Rongli Sun 9c660f6425 [dua] add IsDomainUnicast() helper method (#5230) 2020-07-13 20:53:43 -07:00
Yakun Xu b9a7903f19 [github-action] check with cmake version 3.10 (#5229) 2020-07-13 08:22:00 -07:00
Rongli Sun 32a3bef6dd [test] fix python formatting in v1_2_* tests (#5225)
In some test scripts, %s and format() are used by mistake.
2020-07-13 08:18:51 -07:00
Simon Lin 848feb5aa5 [bbr] validate BBR configuration (#5221)
This commit makes sure BBR configuration is valid according to Thread
Spec 5.21.3.3.
2020-07-13 08:16:47 -07:00
Jintao Lin 4806fa4d0d [platform] fix transmit security for RCP (#5223) 2020-07-10 15:05:54 -07:00
Jonathan Hui aa1a610203 [docker] remove stale Dockerfiles (#5214) 2020-07-10 11:05:21 -07:00
Abtin Keshavarzian cd2b183251 [dtls] small enhancements (#5220)
This commit contains few small enhancements in `Dtls`:

- It renames the `GetPeerAddress()` to `GetMessageInof()` (to indicate
  that it returns `Ip6::MessageInfo` and not just peer socket address).
  (it also renames the variable to `mMessageInfo` from `mPeerAddress`).

- Declares `Ip6::MessageInfo` to be `Clearable` and uses the `Clear()
  method instead of `new` operator to clear the `mMessageInfo`.

- Uses helper methods to set the peer socket address (remove `memcpy`).
2020-07-10 10:11:10 -07:00
Simon Lin a7c0f51b9b [utils] add ChildMask class (#5206)
This commit adds the ChildMask class so that it can be reused by other
modules.
2020-07-10 10:03:17 -07:00
Mason Tran 71c16d9558 [efr32] fix broken radio.c in EFR32MG21 (#5217)
processNextRxPacket() on the EFR32MG21 platform takes a RAIL handle as
a second argument.
2020-07-09 09:15:40 -07:00
Colin Tan ff712ca8e1 [otns] fix extaddr byte order (#5216)
The extended address already has byte order reversed when calling
aFrame.GetDstAddr(dst). The reversal logic is therefore not
needed.
2020-07-08 22:46:50 -07:00
Abtin Keshavarzian 83d5bcf70b [diag-tlvs] remove unused TLV types (#5215)
This commit removes unused simple `NetworkDiagnosticTlv` sub-types.
For simple TLVs we use helper method to directly parse/append the TLV
from/to a message, so the TLV sub-type class is not needed or used.
2020-07-08 22:43:46 -07:00
Abtin Keshavarzian 9acd16a1a2 [string] add String::AppendHexBytes() (#5212)
This method appends a given array of bytes in hex representation
(`%02x` style) to a `String` object. This method helps simplify the
`ToString()` methods in simpler types (e.g., `Mac::ExtAddress`).
2020-07-08 22:36:16 -07:00
Moandor 4e0dc03e96 [cli] add netstat command (#5202) 2020-07-08 22:26:41 -07:00
Mason Tran d964694d19 [efr32] process received packet immediately (#5197)
When analyzing the energy mode transitions for a sleepy node, running
the sleepy-demo-mtd app, it was observed that, the current
implementation of the platform radio driver (efr32RadioProcess())
although correct, can be optimized by processing the next received
packet (processNextRxPacket()) before other actions being carried out
in this routine. For example, in a situation where a 802.15.4 MAC Ack
needs to be processed in response to a sent packet, adding this call
towards the end of this routine then delays stack notification (that a
Tx was done) until the next call to efr32RadioProcess().
2020-07-08 18:05:36 -07:00
Yakun Xu 36533b01e1 [script] fix unbound variable in macOS (#5210) 2020-07-08 10:44:44 -07:00
Jonathan Hui 6dd57816ee [cmake] move minimum version to 3.10.2 (#5208)
To support automated armv7 docker builds.
2020-07-08 10:42:09 -07:00
Abtin Keshavarzian 04b35d0422 [udp/tcp/icmp] simplify Header parsing, and declare related types as nested (#5203)
This commit contains two main changes in `Ip6` modules: `Udp`, `Tcp`,
and `Icmp`. First, it simplifies the `Header` types defining constant
`enum` for byte offset of different fields in the header (these
replace the static methods and avoid use of `offsetof` macro). Second
change is it declare related types in each module as nested types of
the the main class (place them under the namespace of the main type).
For example `Icmp::Header`, `Udp::Socket` respectively replace
`IcmpHeader`, `UdpSocket` types.
2020-07-08 10:41:00 -07:00
Moandor abeb02fc52 [test] fix external commissioner coverage data uploading (#5207)
This makes the external commissioner test to copy coverage files from
otbr to $PWD/build so they are uploaded correctly.
2020-07-08 00:04:53 -07:00
Eduardo Montoya 396d23cd06 [dtls] explicitly configure ECJPAKE parameters (#5192)
This commit:

- Uses the mbedtls API to explicitly fix the number of used curves to
  one when using ECJPAKE, as required by Section 3 of
  draft-cragie-tls-ecjpake-01.

- Uses the mbedtls API to explicitly remove the Signature Hash
  Algorithms when using ECJPAKE.
2020-07-07 19:05:19 -07:00
Abtin Keshavarzian eee173af0b [ip6-address] update and use Ip6::InterfaceIdentifier class (#5194)
This commit updates `Ip6::InterfaceIdentifier` class adding new helper
methods to it (e.g., generate random IID, or convert IID to/from a MAC
Extended Address). It also updates the `Ip6::Address` methods (related
to getting/setting/checking IID) to use the `Ip6::InterfaceIdentifier`
type.

The larger change in this commit is to update other core classes and
modules (`Lowpan`, `Mle`, `Settings`, 'AddressResolver', `Child`,
etc.) to use the `Ip6::InterfaceIdentifier`/`Ip6::Address` type and
their new/changed methods.

This commit also adds a new `struct` type `otIp6AddressComponents` to
the public OT API header `ip6.h`. This type represents the components
of a (unicast) IPv6 address, i.e. a network prefix and an IID. The
`otIp6Address` uses the new type as one of its `union` representations
of an IPv6 address.
2020-07-07 18:02:34 -07:00
Abtin Keshavarzian e29143b089 [pool] introducing a generic object pool class (#5193)
This commit adds a template `Pool<Type, kPoolSize>` class representing
an object pool. `Message`, `Netif`, and `AddressResolver` classes are
respectively updated to use `Pool` for managing their buffer pool,
external unicast/multicast address pool, and address cache entry pool.
This commit also adds a unit test for the `Pool` class.
2020-07-07 17:59:25 -07:00
Jintao Lin f7e16fec24 [nrf528xx] add platform radio support for transmit security (#5184) 2020-07-07 13:12:50 -07:00
Eduardo Montoya 9f0df30493 [meshcop] JR: don't wait for previous rsp to send a new JOIN_ENT.ntf (#5199)
The existing Joiner Entrust process is as follows:

- The Joiner sends JOIN_FIN.req and receives JOIN_FIN.rsp from the
  Joiner Router.

- The Joiner sets up a 4000 ms timer to receive the JOIN_ENT.ntf.

- The Joiner Router generates the JOIN_ENT.ntf and enqueues it,
  setting up a 50 ms timer to send it.

- When the Joiner Router timer triggers it sends the heading message
  from the queue ONLY if the previous transaction already
  completed. This is done like this because whenever a new
  JOIN_ENT.ntf is sent the KEK in the KeyManager is changed, and it's
  required to keep it in order to decrypt the CoAP ACK.

This approach presents a couple of issues:

- It blocks the message queue up to the maximum CoAP transaction time,
  which can be much longer than the Joiner 4 seconds timeout.

- Even worse, if the CoAP ACK never arrives, no more messages would be
  released from the queue, even future enqueued ones.

This commit removes this queue blocking, assuming the risk of an
enqueued JOIN_ENT.ntf being sent before the previous ACK has
arrived. In that case there are two options:

- The previous JOIN_ENT.ntf was not delivered and the previous Joiner
  would need to start over the whole Commissioning process again.

- The previous JOIN_ENT.ntf was delivered but the ACK was not
  received. This has impact only in the Joiner Router logs.

But even for the first case the chances are very low (a JOIN_ENT.ntf
enqueued to be triggered just a few milliseconds after the first one)
and situation is much better than the previously existing one.
2020-07-07 11:40:26 -07:00
Simon Lin d3a429b1ea [mle] fix invalid router after ProcessRouteTlv (#5200)
We always need to update existing router references after calling
ProcessRouteTlv.
2020-07-07 11:11:17 -07:00
Moandor f490ea658c [test] add external commissioner tests (#5187)
This adds tests of ot-commissioner as part of GitHub Action workflows.
2020-07-06 20:34:21 -07:00
Gary Palmer 180f5824dc [logging] fix benign typecast issue in otDump (#5198)
Fixes a benign typecast issue found when using the IAR compiler.
2020-07-06 20:26:11 -07:00
gabekassel 716e5f0726 [efr32] Silabs EFR32MG1 Platform Support (#5191)
This adds platform support for Silabs EFR32MG1 (series1 Mighty Gecko
with 32K RAM + 64K flash).

A few notes on this commit:

- MG1 cannot fit FTD builds with certain options enabled (like
  diagnostics). In testing, I simply removed FTD from build
  options. We may want to add this to README

- Most platform files are directly duplicated from MG12

- Only created BRD4151A reference. Suspect Silabs team will want to
  add other reference platforms like Thunderboard 1

- Should include latest crypto acceleration changes made by Silabs
  team

- This has been tested using RCP and CLI builds both on BRD4151A WSTK
  and a custom design based on MG1.
2020-07-06 20:08:09 -07:00
Colin Tan e7e69065b6 [otns] add radio event status emission (#5195)
This commit adds code in base radio implementation to emit radio
events to logs, when OTNS is turned on. This is for Silk-OTNS
integration's message visualizations.
2020-07-06 15:15:10 -07:00
Moandor 203774c181 [test] add expect tests for commissioner and udp (#5196) 2020-07-06 08:39:53 -07:00
Moandor f75076078c [test] add missing expect test cases for dataset commands (#5182) 2020-07-06 08:13:14 -07:00
Moandor d164146010 [test] print debug info when expect tests fail (#5181)
This stores debug logs from expect and prints them if a test fails to
enable easier debugging.
2020-07-03 09:29:54 -07:00
Yakun Xu 74fd255465 [joiner] check Thread state on start (#5173) 2020-07-03 09:24:52 -07:00
Bob MacDonald 2a05a4c5f2 [efr32] fix compilation issues efr32*/flash.c (#5189) 2020-07-03 09:22:35 -07:00
Gary Palmer 5f0e36eeb2 [mac-frame] remove unused variable in TxFrame::ProcessTransmitAesCcm() (#5185)
Eliminated an unused variable discovered when building using IAR.
2020-07-02 15:49:06 -07:00
Abtin Keshavarzian 4584deeae0 [udp6] use newly added linked-list to search for a matching socket (#5180)
This commit adds `UdpSocket::Matches()` to match a UDP socket with a
given `MessageInfo`. This is then used alongw with the newly added
linked-list `FindMatching()` method to find a matching socket from the
list of UDP sockets in `Udp::HandlePayload()`.
2020-07-02 15:46:11 -07:00
Abtin Keshavarzian 2184d2ce0f [netif] use newly added linked-list helper methods (#5179)
This commit simplifies the `Netif` implementation by using newly added
`LinkedList::FindMatching()` methods to search in unicast/multicast
address list for an entry matching a given IPv6 address.
2020-07-02 15:44:42 -07:00
Mason Tran 53c3940c1a [efr32] remove unnecessary nvm3 calls (#5178)
This removes unnecessary open/close calls that were being made when
handling nvm operations.

In a normal mode of operation, the nvm open call should be made only
once during initialization.

The only way these changes could be verified was by building a binary,
flashing it on a node and making sure that the node's network operations
(like forming a network) were okay.
2020-07-02 15:43:43 -07:00
Moandor fbacefe85c [test] add expect tests for coap and coaps (#5172)
Also adds command coaps set to make it consistent with coap set.
2020-07-02 15:40:18 -07:00
Abtin Keshavarzian ce9040950e [dtls] misc enhancements (remove unused defs, declare enum as private) (#5176)
This commit contains the following:

- Remove unused `SendHandler` type and `mSendHandler` variable.
- Follow style guide for `#endif` comments.
- Define `Dtls::State` as private.
- Define DTLS module constant enums as private.
- Ensure `mReceiveHandler` is not null before invoking.
- Inline simple setter `SetSslAuthMode()`.
- Follow style guide for param names in `HandleMbedtlsDebug()`.
2020-07-01 16:51:51 -07:00
Abtin Keshavarzian 30343ce753 [addr-resolver] use new linked list method to find cache entry matching an EID (#5174) 2020-07-01 16:51:10 -07:00
Abtin Keshavarzian 5ebd885996 [linked-list] add new template {Contains/Find/Remove}Matching() methods (#5174)
This commit adds new methods in `LinkedList` to search in the list for
an entry matching a given entry indicator (specified with a template
`Indicator` type). To use these methods, users are expected to provide
method `bool Matches(const Indicator &aIndicator) const` on the entry
`Type` itself (which is then used to match each entry in the list with
the indicator). This commit also changes the linked-list methods to
use `Find()` internally. Finally it updates the linked-list unit test
to cover behavior of the newly added methods.
2020-07-01 16:51:10 -07:00
Jonathan Hui a795db710f [dhcp6-client] update DHCPv6 service RLOC on new network data (#5169) 2020-07-01 16:48:27 -07:00
Jonathan Hui 88e2ca5714 [dhcp6-client] only close socket if no agents exist (#5169) 2020-07-01 16:48:27 -07:00
Abtin Keshavarzian ae34357023 [netif] misc enhancement (#5168)
This commit contains some smaller enhancements in netif:

- Add method to check if unicast/multicast address is external or
  internal (e.g., `IsUnicastAddressExternal`)
- Simplify iteration over (external) multicast addresses and remove
  `GetNextExternalMulticast()`.
- Use range-based `for` loop for iteration over external address
  arrays.
- Rename `IsUnicastAddress()` to `HasUnicastAddress()`.
- Clarify method documentation specially between internal and
  external addresses (how the passed-in address parameter is used,
  i.e., copied into another entry from an address pool for external
  vs. directly used for internal addresses).
2020-07-01 14:24:03 -07:00
Yaoxing Shan 9920685b8d [devsite] fix wrong description in Thread Primer (en) (#5163) 2020-07-01 10:43:05 -07:00
Moandor 68e66bc633 [continuous-integration] add SPI build check (#5165)
Enables NCP SPI in build checks. Also fixes some build errors in SPI code.
2020-06-30 22:52:31 -07:00
Simon Lin baa6523766 [otns] fix simulation to use strong otPlatOtnsStatus definition (#5171)
- fix otPlatOtnsStatus(weak) is not used
- use the current openthread rather than openthread master
2020-06-30 22:49:50 -07:00
Colin Tan 5ce4046751 [otns] add default implementation for otPlatOtnsStatus (#5155)
This commit adds a default implementation for otPlatOtnsStatus, which
emits OTNS status messages to log, so that OTNS=1 could be used with
real devices. This is required for the Silk-OTNS integration work, as
Silk will pick up these messages and reroute them to OTNS for
visualization purposes.
2020-06-30 13:02:50 -07:00
Simon Lin b0bff4f8c3 [github-actions] fix expects fail by chance (#5157)
This commit tries to reduce expects fails in GitHub actions:
- wait_for only sends command when it's not empty
- increases the default expect timeout from 1s to 3s.
2020-06-30 11:01:10 -07:00
Yakun Xu eaaaa59071 [posix] wait for writable before next try (#5143)
This commit waits fd to be writable before try writing next time.
2020-06-30 11:00:11 -07:00
Jonathan Hui 284cd96886 [devsite] add clarifications to multicast addressing primer (#5160) 2020-06-30 08:48:08 -07:00
Jonathan Hui 6930dd3603 [bootstrap] update bootstrap user messages (#5161)
- Indicate that pretty tools are primarily used for code contributions.

- Change to bash.
2020-06-30 08:47:01 -07:00
Abtin Keshavarzian 0ae329c21d [linked-list] fix Find() when list is empty (#5164)
This commit fixes the `LinkedList::Find()` implementation when list is
empty. It also updates the unit test for linked-list to verify the
`Find()` (particularly when it is expected to fail and not find the
entry in the list).
2020-06-30 08:43:31 -07:00
Moandor 5acad30791 [test] include CLI tests in RCP mode (#5159)
This makes expect run all cli-*.exp and posix-*.exp tests in RCP mode.
New scripts should use the function spawn_node in _common.exp to spawn
new processes. This is compatible with both simulation mode and RCP
mode.
2020-06-30 08:40:46 -07:00
Abtin Keshavarzian d65f8a3812 [meshcop] fix typos in joiner/commissioner method documentation (#5154) 2020-06-29 12:53:00 -07:00
Abtin Keshavarzian 560fee9698 [toranj] add test covering meshcop with Joiner Discerner (#5154)
This commit adds a `toranj` test-case covering the commissioning
behavior using a Joiner Discerner:
- Verifies setting and clearing discriminator with different values
  and bit-lengths (on a Joiner).
- Verifies commissioning using discerner (and EUI64).
- Verifies that commissioner would prefer a Joiner entry with the
  longest matching discerner length.
2020-06-29 12:53:00 -07:00
Yakun Xu bd078f1b30 [test] fix multiple extra options (#5158) 2020-06-29 09:04:01 -07:00
Abtin Keshavarzian 6f1fc2e6c2 [mac-filter] misc enhancements (#5151)
This commit contains some smaller enhancements in `Mac::Filter`:

- Use C++11 range-based `for` loop when iterating over filter entries
- Define `Filter:Mode` enum (mirror of `otMacFilterAddressMode`)
- Change `Filter::SetMode()` and `otLinkFilterSetAddressMode()` to
  return `void`.
- Simplify `Filter::Apply()` implementation.
- Add new separate public OT and internal APIs to set/clear default
  RSS-In (e.g., `SetDefaultRssIn()`/`ClearDefaultRssIn()`).
- Return no error (instead of `ALREADY`) from `Filter::AddAddress()`
  and its corresponding public `otLinkFilter` API when entry is already
  present in the list.
- Do not return `NOT_FOUND` error from `Filter::Remove{Address/RssIn}()`.
- Update public `otLinkFilter{API}` documentation.
- Update NCP and CLI code to adopt new `otLinkFilter` APIs.
2020-06-29 08:59:34 -07:00
Rongli Sun ce1b8e6762 [mle] suppress parent response when >= 32 active routers (#5156)
This commit introduces one extra parent response rule:
REED doesn't respond parent request if there are already
`kMaxRouters` active routers in the Thread network as it's
for sure that Leader will reject its address solicit.
2020-06-29 08:57:01 -07:00
Abtin Keshavarzian 9e291e62ed [commissioner] use c++11 range-based for and explicitly typed enum (#5137) 2020-06-26 16:02:09 -07:00
Abtin Keshavarzian a7415b53a4 [ncp] add support for Joiner Discerner and getting list of joiners (#5137)
This commit adds/updates spinel properties to add Joiner Discerner
support on joiner and commissioner side. It also adds support for
getting the list of joiners on commissioner by implementing property
get handler for spinel property `MESHCOP_COMMISSIONER_JOINERS`.
2020-06-26 16:02:09 -07:00
Abtin Keshavarzian c7dc2be7d2 [joiner] adding otJoinerPskd and JoinerPskd types (#5137) 2020-06-26 16:02:09 -07:00
Abtin Keshavarzian 5210ca3eee [meshcop] adding otJoinerDiscerner (#5137)
The `otJoinerDiscerner` enables new a mechanism for Thread
commissioning. The traditional Thread commissioning process uses
factory assigned EUI-64 of the device to derive the Joiner ID and
identify/filter a joiner (through steering data bloom filter). The
Joiner Discerner (which is an unsigned value along with a
user-specified bit length up to 64 bits) allows users to have more
control and do not rely on factory-assigned EUI-64.

On joiner side, when a a Joiner Discerner value is provided, the
Joiner code uses the discerner value to derive Joiner ID (appending a
random prefix to extend the value to 64 bits) and bloom filter.

On commissioner side, users can add different joiners providing either
an EUI-64 or an associated Joiner Discerner and the code accordingly
match the Joiner IDs and compute steering data bloom filter.
2020-06-26 16:02:09 -07:00
Jonathan Hui 2ebdf874eb [utils] remove wrap_string.h (#5150) 2020-06-25 09:14:18 -07:00
Abtin Keshavarzian 95679f1d83 [net-data-tlvs] update documentation and index parameter name style (#5148) 2020-06-24 21:03:51 -07:00
Abtin Keshavarzian d787ad0a95 [dtls] remove unused method decelerations (#5147) 2020-06-24 21:03:06 -07:00
Moandor 1cd9bb3074 [test] add expect tests for dataset and networktime (#5145) 2020-06-24 12:48:03 -07:00
Jonathan Hui 6e80c8b058 [tests] add test for prefix without on-mesh flag set (#5116) 2020-06-23 18:01:20 -07:00
Jonathan Hui 95a434d737 [slaac] set plen to 128 if prefix is not on-mesh (#5116) 2020-06-23 18:01:20 -07:00
Jonathan Hui 15c3463cec [tests] fix prefix configuration in 5_6_05 and 5_6_06 (#5116)
Prefix 3 should be configured as on-mesh.
2020-06-23 18:01:20 -07:00
Jonathan Hui 6897dffb57 [network-data] fix IsOnMesh() to check on-mesh flags (#5116) 2020-06-23 18:01:20 -07:00
Jintao Lin 474cd5fd86 [posix] Backwark compatible with older RCP image (#5139) 2020-06-23 13:41:23 -07:00
Jeff Bumgardner 4975681a97 [docker] build ot-daemon/ot-ctl in codelab_otsim (#5115)
Also remove wpantund from codelab_otsim.
2020-06-23 13:38:25 -07:00
Abtin Keshavarzian b17327456c [spinel] fix use of OT header file in spinel.c (#5141)
`spinel.h` and `spinel.c` are soruce files that may be used by host
side drivers and therefore the souurce code itself should not use any
of OT header files. Spienl file provide `SPINEL_PLATFORM_HEADER` to
allow platform to add their own includes if they want to.
2020-06-23 13:36:43 -07:00
Jintao Lin 5c722a770c [simulation] support transmit security at simulation radio (#5118)
This commit adds transmit security support for simulation radio so
that security Enh-ACK could be handled at radio layer. This commit
also fixes issue #5041.
2020-06-22 12:23:16 -07:00
Abtin Keshavarzian 4e1a3bf670 [tasklet] use function reference (instead of pointer) for tasklet handler (#5136) 2020-06-22 11:23:20 -07:00
Moandor ede592918c [test] add expect tests for sntp, mac, netif, and more (#5140)
Also does some minor enhancements.
2020-06-22 10:11:55 -07:00
Bob MacDonald a6116725c0 [efr32] remove extra parenthesis causing compilation problems (#5135)
Remove extra parenthesis introduced with commit b66ac5d causing
compilation error for all efr32mg builds.
2020-06-22 10:09:41 -07:00
Abtin Keshavarzian d6f2a155fc [ncp] ensure JOINER_STATE is not limited to FTD only (#5129)
This commit fixes the entry for getter in `ncp_dispacther` for spinel
`SPINEL_PROP_MESHCOP_JOINER_STATE` ensuring it is available in MTD
build as well as FTD when joiner feature is enabled.
2020-06-20 18:39:47 -07:00
Yakun Xu a344fb5969 [style] remove c++11 check and OT_NCP_CONST (#5132) 2020-06-20 18:11:12 -07:00
Yakun Xu f79406418a [android] enable commissioner (#5128) 2020-06-20 18:09:53 -07:00
Abtin Keshavarzian 53d23b511d [core] use C++11 static_assert (#5127)
This commit uses C++11 `static_assert()` replacing the existing
`OT_STATIC_ASSERT()` macro definitions (intended to support build-time
assertion in C++003 (oder) tool-chains).
2020-06-20 18:09:14 -07:00
Moandor 0cf84da100 [test] add expect tests for channel, coex, and discover (#5123) 2020-06-19 16:53:19 -07:00
Yakun Xu 8248c3d9df [posix] use real time signal for microsecond timer (#5122) 2020-06-19 16:12:55 -07:00
Yakun Xu b66ac5d907 [logging] remove NCP_SPINEL output (#5104)
This commit removes log output NCP_SPINEL and update the original log
output APP to use NCP_SPINEL behavior.
2020-06-19 10:02:53 -07:00
Abtin Keshavarzian c4fd7df086 [logging] add OPENTHREAD_CONFIG_LOG_MESHCOP (#5124)
This commit adds `OPENTHREAD_CONFIG_LOG_MESHCOP` which enable
MeshCoP modules logging. This replaces the use of MLE log config
`OPENTHREAD_CONFIG_LOG_MLE` for controlling MeshCop logging.

The makefiles are also updated to include the new config when
"FULL_LOGS" option is used.
2020-06-19 09:49:38 -07:00
Jiacheng Guo 8367f885ea [simulation] remove linux specific prctl (#5126)
These code is not used since we remove OPENTHREAD_TARGET_DEFINES in
examples/ in 2016.
2020-06-19 08:55:51 -07:00
Jiacheng Guo 5c13cec30b [posix] only update timeout with a lower value (#5119) 2020-06-18 20:27:14 -07:00
Simon Lin 2399220cc5 [otns] allow build without JOINER=1 (#5120) 2020-06-18 19:54:04 -07:00
Moandor 7574cde264 [cmake] fix error messages on macOS (#5117)
- check version of unifdef

- rename mbedtls-config.h to openthread-mbedtls-config.h to enable
  in-source build
2020-06-18 19:36:19 -07:00
Abtin Keshavarzian 96509d36ec [commissioner] prefer entry with Joiner ID match over one accepting any (#5110)
This commit includes a group of smaller enhancements in commissioner
module:

It adds `FindBestMatchingJoinerEntry()` which finds the best matching
joiner entry preferring an entry with full Joiner ID match over an
entry accepting any joiner.

`AddJoiner()` is changed to first try to find and update an existing
entry matching the given EUI64 before allocating a new entry. This
change in turn removes the need to call `RemoveJoiner()` from
`AddJoiner()` and the use of `JoinerOpFlag` to skip notifying the
leader from the unnecessary remove.

This commit also simplifies updating of joiner expiration timer,
changes the `SendCommissionerSet()` to be `void` (to avoid
`IgnoreError()`), adopts the use of `Ip6::InterfaceIdentifier` type to
store Joiner IID, and adds method `LogJoinerEntry()` to help with
logging of Joiner List updates.
2020-06-18 19:34:01 -07:00
Simon Lin a3860d6036 [size-report] retry multiple times (#5111) 2020-06-18 14:48:25 -07:00
Jonathan Hui 1326d64a64 [style] replace NULL with nullptr (#5109) 2020-06-17 22:44:54 -07:00
Yakun Xu 3b362071e5 [link-raw] set receive done callback when enabled (#5108) 2020-06-17 14:42:39 -07:00
Simon Lin f5d7f50f44 [tests] ignore otError in spinel tests (#5093) 2020-06-17 10:48:01 -07:00
Abtin Keshavarzian 55785040c9 [discover-scanner] allow filtering based on a user given bloom filter indexes (#5075)
This commit enhances the filtering behavior of Discover Scan. When
filtering is enabled, MLE Discovery Responses with steering data
(bloom filter) not containing a set of bloom filter indexes are
filtered. This commit updates the `DiscoverScanner::Discover()` to
allow filter indexes used for filtering to be optionally specified by
the caller. It can be set to NULL (for default behavior) where the
hash of factory-assigned EUI64 of the device would be used to derive
the bloom filter indexes
2020-06-17 10:38:03 -07:00
Abtin Keshavarzian 6094db2b96 [toranj] enhance discover scan test - cover filtering, channel-mask (#5075)
This commit enhances `test-005-discover-scan` to cover discover
scan over subset of channels, PAN ID filtering, and joiner only,
bloom filter scan behavior.
2020-06-17 10:38:03 -07:00
Abtin Keshavarzian 54ad5a3960 [discover-scanner] adding Mle::DiscoverScanner (#5075)
This commit adds new class `DiscoverScanner` which implements the MLE
Discover Scan process (moving and simplifying all the code related to
this from `Mle` and `MeshForwarder` into same file/class).
2020-06-17 10:38:03 -07:00
Jintao Lin e653478c50 [posix] get time offset between host and rcp (#5089)
To support CSL on RCP mode, POSIX host needs to know current time on
RCP. This commit adds function to periodically calculate the time
offset between host and RCP so that host can get an estimated RCP time
by adding its current time with this offset.
2020-06-16 22:53:29 -07:00
Moandor 0db8dbeef3 [cmake] generate a mbedtls-config.h without private headers (#5084) 2020-06-16 21:56:15 -07:00
Jonathan Hui d81d769e68 [style] advance C++ language standard to C++11 (#5077) 2020-06-16 13:02:53 -07:00
Simon Lin b50f33365c [github-actions] fix version workflow's name (#5103) 2020-06-16 08:55:10 -07:00
Moandor 5ec3848005 [test] add expect tests for macfilter, childip, version (#5107) 2020-06-16 08:53:37 -07:00
Abtin Keshavarzian bbb77b7658 [encoding] add uint64_t read/write methods for big/little endian encodings (#5105) 2020-06-16 08:51:30 -07:00
Simon Lin 9488d4bc48 [settings] fix DUA logging (#5095) 2020-06-15 21:29:50 -07:00
Markus Becker bad53a2e95 [ip6-address] add a type flag to addresses (#5019)
Add a origin flag to addresses so that applications are able to behave
differently on the type of address (System, SLAAC, DHCPv6, Manual).

Bumping OpenThread API version number.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-15 18:24:14 -07:00
Marvin ROGER ae4dfca5dd [posix] fix build errors on macOS (#5101)
This commit fixes 3 implicit conversion changes signedness errors,
when trying to build the posix core in daemon mode on darwin.
2020-06-15 18:12:48 -07:00
Simon Lin 44f1a8bf29 [tests] use longer timeouts for simulation tests (#5094)
* use longer duration for pexpect and socket
* use 10s timeouts
2020-06-15 18:11:34 -07:00
Jeff Bumgardner 79c564fc6e [docs] add English source for the Thread Primer (#5088) 2020-06-15 11:41:55 -07:00
Marvin ROGER 8856ce132d [bootstrap] add missing newlib on Ubuntu >= 20.04 (#5100) 2020-06-15 11:15:30 -07:00
Moandor 4910f91e8c [test] add expect tests for ipmaddr, neighbor, leaderdata (#5097) 2020-06-15 10:19:08 -07:00
Steven Cooreman 30f40fc0fa [efr32] turn off warnings which break certain configurations of mbed TLS (#5091)
Detected on EFR32MG21 with hardware acceleration turned on, all inside
mbedTLS' library/ecdsa.c:

* Turning on ECDSA signing acceleration (MBEDTLS_ECDSA_SIGN_ALT)
  triggers an unused parameter on rs_ctx in
  mbedtls_ecdsa_write_signature_restartable

* Turning on ECDSA verification acceleration
  (MBEDTLS_ECDSA_VERIFY_ALT) triggers an unused parameter on rs_ctx in
  mbedtls_ecdsa_read_signature_restartable

* Turning on both ECDSA signing & verification acceleration
  (MBEDTLS_ECDSA_SIGN_ALT + MBEDTLS_ECDSA_VERIFY_ALT) triggers an
  unused function error on static function derive_mpi

Looking at the latest mbed TLS development branch, it seems this issue
will not be resolved soon. Therefore, we're turning off warnings for
unused parameters and unused functions inside mbedTLS for the platform
which uses this configuration (EFR32MG21).
2020-06-12 10:32:35 -07:00
Simon Lin 9aadfd0cdf [script] install shellcheck in bootstrap (#5067) 2020-06-11 18:26:18 -07:00
Steven Cooreman 29bcfee0df [efr32] update mbedTLS configuration to use more hardware acceleration (#5074)
Turns on the following:
* SHA256 acceleration on all EFR32 devices (used for SHA256,
  HMAC-SHA256, ECDSA and DRBG)
* ECDSA/ECDH acceleration on EFR32MG21 (used in DTLS and exposed to
  application through otCryptoEcdsaSign)
* AES-CCM acceleration on EFR32MG21 (in case OT is updated to take
  advantage of mbedTLS' AES-CCM API)
* AES-CMAC acceleration on EFR32MG21 (used for PBKDF2)

Awaiting new GSDK release:
* end-to-end EC-JPAKE acceleration on EFR32MG21 (used in DTLS)
2020-06-11 15:53:05 -07:00
Simon Lin 7f3013cb06 [posix] fix ot-ctl CLI output missing (#5087)
An issue occurs when ot-ctl reads the CLI output in multiple chunks in
which the last line of a chunk does not ends with a '\r\n'. The last
line is then dropped incorrectly.

This commit fixes this issue:

- Output the last line (without \r\n) if it's not ">" (have to drop
  '>' because we can not determine whether or not to output '>')

- Output ">" if the first char is not ' ' but the previous promptState
  is 1 (meaning '>' was dropped previous but should have been
  printed).
2020-06-11 11:29:21 -07:00
Jonathan Hui 2c258a3f3e [network-data] in Validate() only check dups against prior prefixes (#5083)
To avoid buffer overrrun issues.
2020-06-11 10:25:53 -07:00
Simon Lin 8e124e6fac [cert] capitalize python class constants (#5080)
According to PEP8, constants should be written in all capital letters.

This commit capitalizes these constants:
- thread_cert.TestCase.topology
- thread_cert.TestCase.support_ncp
2020-06-10 18:14:59 -07:00
Abtin Keshavarzian 0ad3c20747 [mle-tlvs] remove unused type/constant definitions (#5082) 2020-06-10 17:06:39 -07:00
Yakun Xu 55790fb960 [cmake] use ot-config to umbrella private includes (#5079)
- add include directories to ot-config
- remove unused OT_PRIVATE_INCLUDES
2020-06-10 17:03:49 -07:00
Jonathan Hui 71c0def4f8 [fuzz] fix undefined macro warning (#5076) 2020-06-10 06:34:19 -07:00
Abtin Keshavarzian 4f85283fb3 [toranj] allow verbose mode (on all nodes) to be enabled using env variable (#5078)
This commit adds additional mechanism in `toranj` to enable verbose
mode on all nodes by setting the env variable `TORANJ_VERBOSE` (this is
in addition to existing mechanism where verbose mode can be enabled
per node from a test script). When `TORANJ_VERBOSE` env is used to
enable verbose mode, it also enables OT logging on all nodes (OT logs
are collected in the `wpantund-logs<node_index>.log` files along with
`wpantund` logs). This commit also updates the `toranj/README.md` to
describe the new mechanism.
2020-06-10 06:33:56 -07:00
Moandor 4d1197a34a [test] split cli-2-nodes.exp into multiple files (#5066)
This splits cli-2-nodes.exp into multiple files each of which contains
tests for a single command.
2020-06-09 19:05:05 -07:00
Yakun Xu dce84a77fb [cmake] add posix in platform list (#5071)
- rename "none" to NO, which computes to false in if()
- sort platform names
- add "posix" into the platform list so that it can be selected from cmake-gui
2020-06-09 16:14:10 -07:00
Rongli Sun bc9745584b [dua] save dad counter into non volatile memory (#4904) 2020-06-09 12:39:22 -07:00
paragdixit-g ef0045a6dd [posix] fix otPlatAlarmMicroGetNow to use scaled time (#5070)
This makes it consistent with MilliGetNow() counterpart.
2020-06-09 12:34:44 -07:00
Jonathan Hui f36ad41c62 [meshcop] support get/set operational dataset via raw TLVs (#5055)
- Add CLI commands to get/set operational dataset using TLVs.
2020-06-09 11:53:13 -07:00
Jonathan Hui 5550a608d6 [fuzz] limit PBKDF2 iterations to avoid OSS-Fuzz timeout (#5069) 2020-06-09 10:47:37 -07:00
kangping 76b5270d8f [posix] fix spinel radio state transition (#5068) 2020-06-09 10:47:25 -07:00
kangping 8a1339a859 [meshcop] move Joiner::IsPskdValid() to MeshCoP::IsPskdValid() (#5065) 2020-06-09 10:45:27 -07:00
Rongli Sun b51d9100e6 [dua] support to specify iid for domain unicast address (#4900) 2020-06-09 10:38:13 -07:00
Yakun Xu b28d7c4a45 [test] split out 1.2 and posix from simulation (#5063)
This commit splits out 1.2 and posix workflows from simulation workflow
so that when an unstable job failed, just a few jobs need rerun.
2020-06-08 10:20:46 -07:00
Markus Becker 54f24c6074 [cmake] use the correct define for external heap (#5058)
In options.cmake OPENTHREAD_CONFIG_*EXTERNAL_HEAP*_ENABLE is used,
while in common-switches.mk and the source code the slightly different
OPENTHREAD_CONFIG_*HEAP_EXTERNAL*_ENABLE is used.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-06-08 10:19:37 -07:00
Abtin Keshavarzian f177acfc4a [notifier] add Notifier::Receiver (#5052)
This commit adds `Notifier::Receiver` class which is inherited by
OpenThread core types/classes to register themselves as a receiver
of `Notifier` events. This change helps simplify and replace the
previous `Notifier` callback model.
2020-06-08 10:17:52 -07:00
Abtin Keshavarzian adb57991e8 [notifier] add Event and Events types (#5052)
This commit adds `Event` enumeration type representing `Notifier`
events (mirroring `OT_CHANGED_{EVENT}` constants). It also adds
`Events` class which represents a collection of events. The `Events`
class provides helper methods to check whether a specific event has
happened, or whether any or all of a given subset of events are
present in the `Events` collection.

This commit also renames the `Notifier` handler method in different
core classes to `HandleNotifierEvents()`.
2020-06-08 10:17:52 -07:00
Abtin Keshavarzian 7ae409af65 [posix] rename struct Event to VirtualTimeEvent (#5052)
This `struct` is defined in a C header file and therefore it is not
scoped in a `namespae`. The rename is to avoid name conflicts with
OpenThread core definitions (allowing `ot::Event` to be defined).
2020-06-08 10:17:52 -07:00
Jing Ma 75e21adcec [harness-automation] add a parser tool for TopologyConfig file (#4975)
- parse TopologyConfig file in Thread Certification Test Harness
- list multi-vendor device numbers by case
- list needed vendor device numbers for the whole certification testbed
2020-06-08 10:15:59 -07:00
Yakun Xu fb39910402 [posix] fix build daemon mode (#5062) 2020-06-05 22:18:33 -07:00
Abtin Keshavarzian 5ef652b5aa [mle] simplify appending of MLE Discovery TLV in Mle::Discover() (#5059) 2020-06-05 22:17:47 -07:00
Moandor 4b5eeadee6 [test] modularize expect scripts (#5056)
This puts the scripts setting up Thread networks into separate files
so that they can be reused by multiple test scripts. After this we can
split the tests in cli-2-nodes.exp into multiple files without having
to repeat codes in each file.
2020-06-05 22:16:54 -07:00
Moandor 2e60748d5b [test] add expect tests for router, scan, and more (#5054)
- router
- scan
- parentpriority
- pollperiod
- prefix
- preferrouterid
- route
2020-06-05 12:40:59 -07:00
Jonathan Hui 616d8cb8a5 [cli] implement 'rcp version' command (#5051) 2020-06-05 12:24:54 -07:00
Abtin Keshavarzian 99a42ccadc [timer] use function reference (instead of pointer) as timer handler (#5050) 2020-06-05 12:24:28 -07:00
Yakun Xu 82053cc9db [tests] add dns client tests (#5049) 2020-06-04 13:24:43 -07:00
Yakun Xu 6a6cbe48f0 [posix] use os defined macros (#5048)
This helps the OT_ASSERT automatically adopt the posix provided assert.
2020-06-04 13:22:49 -07:00
Yakun Xu 61f24c70fb [radio-url] GetValue once and add missing doc (#5046) 2020-06-04 13:21:34 -07:00
Abtin Keshavarzian 1d9b705a48 [meshcop] adding SteeringData class (#5040)
This commit adds a new class `MeshCoP::SteeringData` which manages
the Steering Data and bloom filter generating and filtering. This
commit also adds a unit test `test-steering-data` for the newly
added `SteeringData` class.
2020-06-04 13:20:17 -07:00
Simon Lin 06025122c0 [posix] fix uart-baudrate argument of radio url (#5045) 2020-06-03 22:11:55 -07:00
Moandor ea7c76cc4b [test] add expect tests for pcap receiving (#5043)
This adds expect tests for testing the pcap receiving function of
promiscuous mode. Also makes otLinkSetPromiscuous be called before
otLinkSetPcapCallback so that the callback won't be set when
promiscuous mode fails to start.
2020-06-03 22:11:14 -07:00
Jintao Lin 201b7b1a3d [mac] move auxiliary frame counter from Mac to SubMac (#4976)
In Thread 1.2, it is possible to receive an IEEE 802.15.4-2015
packet. Per specification, receiver should acknowledge this packet
with an IEEE 802.15.4-2015 ACK(Enh-ACK). This Enh-ACK can include
header IE with it and requires security enabled bit in FCF be set to
true. It is impractical for the host to generate the Enh-ACK and send
to RCP for transmission within AIFS time(192us). So RCP should prepare
the Enh-ACK by itself, which requires it to fill in the frame counter
and do the encryption/authentication.

This commit tries to address the need of filling auxiliary frame
counter in RCP by including the following changes:

- Move frame counter related functions from MAC layer to SubMac layer,
  which is mirrored in RCP.

- Set mMacFrameCounter to RCP using newly added spinel properties.

- RCP reports last used frame counter to host in TxDone and RxDone.

- Add a simulation test for reset verification.
2020-06-03 22:09:16 -07:00
Abtin Keshavarzian 72c369ced3 [udp6] add method documentation for GetUdpSockets() (#5044) 2020-06-03 16:06:46 -07:00
Yakun Xu f302796bd2 [simulation] send enh-ack for 802.15.4-2015 frames (#5039)
This commit changes the simulation radio to send secured enh-ack for
secured frames. This improves code coverage for testing.
2020-06-03 10:59:19 -07:00
Yakun Xu 6de8d778b7 [tests] skip running expected fail tests (#5038)
This commit skips running expected fail tests so that it will be easier
to find real failures and saves some time.
2020-06-02 21:32:00 -07:00
Moandor ced3c08a04 [test] add expect tests for child (#5037)
This adds test cases for child command. Also moves ping tests with 2
nodes to cli-2-nodes.exp, future tests requiring 2 nodes will be
placed in this file.
2020-06-02 21:20:24 -07:00
Yaoxing Shan f0d07ae6d3 [bootstrap] remove PPA on Ubuntu 20.04 and later (#5009) 2020-06-02 21:17:15 -07:00
Jonathan Hui 0565f44a4c [mle] restore operational datasets when becoming leader (#5036)
The leader is authoritative in the operational datasets that it
distributes. This commit ensures that a device becoming a leader
restores the operational dataset from non-volatile. This ensures that
the operational datasets that the leader attempts to distribute are
the same as in its non-volatile storage.
2020-06-02 13:37:54 -07:00
Yakun Xu aa19e77ac7 [continuous-integration] add version number check (#5034) 2020-06-02 13:37:42 -07:00
Abtin Keshavarzian 1ce2a07afd [core] add Clearable class providing simple Clear() method (#5029)
This commit adds new class `Clearable` (inherited by other types)
providing simple implementation of `Clear()` which sets all the
instance bytes to zero (using `memset()`).
2020-06-02 13:36:24 -07:00
Abtin Keshavarzian 71575ff76a [core] add Equatable class providing overloads of == and != operator (#5029)
This commit adds new class `Equatable` (inherited by other types)
providing overloads of operators `==` and `!=`. The implementation
simply compares all the bytes of two instances of same type to be
equal (using `memcmp`).
2020-06-02 13:36:24 -07:00
Yakun Xu 2b9e8facba [test] cover micro timer in unittest (#5030) 2020-06-01 22:05:42 -07:00
Li Cao 70f2e54d06 [low-power] encapsulate method to update header IE (#4999)
OpenThread currently implements a TIME_SYNC IE. The presence of IEs
also affects the frame version and IE present field. This commit
encapsulates the process to update these things so that it could be
easily extended to support other IEs that are introduced later.
2020-06-01 21:59:01 -07:00
Li Cao b9d348c328 [simulation] use ACK frame generation utils (#5033) 2020-06-01 17:06:02 -07:00
Yakun Xu ba0b896b20 [continuous-integration] use apt-get instead of apt (#5032)
This commit changes apt to apt-get for the WARNING in build logs:

WARNING: apt does not have a stable CLI interface. Use with caution in
scripts.
2020-06-01 17:03:33 -07:00
Yakun Xu 075c46c7b5 [ot-ctl] no output prompt in non-interactive mode (#5026) 2020-06-01 16:59:19 -07:00
Jonathan Hui dfd022e1a4 [ip6] forward any packet with on-mesh destination. (#5024)
Existing implementation only looks at addresses configured on the
network interface to determine what prefixes are on-link (on-mesh for
Thread). When the network interface does not have an assigned address
for a given on-mesh prefix, any packet with that on-mesh prefix will
not be forwarded to the Thread network.

This commit also checks the destination address against Thread's set
of on-mesh prefixes, independent of whether addresses out are assigned
out of the on-mesh prefix.
2020-06-01 09:48:15 -07:00
Yakun Xu f8f75d6d05 [posix] clean up for radio url (#5027)
* fix max-power-table documentation
* rename `baudrate` to `uart-baudrate`, `arg` to `forkpty-arg`
* update command line enumeration
* update README
* remove trailing argument from node.py
2020-06-01 08:13:46 -07:00
Jiacheng Guo 115616c6bf [posix] add radio url (#4935)
Radio url provides a unified interface for users to specify the radio
peripheral device and arguments to the OpenThread core stack.
2020-05-29 17:34:29 -07:00
Jonathan Hui b0b2591bc0 [mle] fix bug in leader active/pending dataset synchronization (#5021)
The leader is the authoritative source when propagating active/pending
operational datasets. When the leader reboots, it is possible for the
leader to become out-of-sync. In particular, after the leader resets,
it restores its network data and active/pending operational datasets
using MLE Data Request/Response to retrieve them from a neighboring
device. If the neighboring device has an older active/pending
operational dataset, the leader will retrieve the older datasets and
never attempt to propagate the newer datasets that it may have stored
locally.

This commit makes the following changes:

- The leader does not accept any changes to the active/pending
  operational datasets.

- After retrieving the latest network data from a neighboring device
  (as part of resynchronizing after reset), the leader will increment
  the full and stable network data versions to ensure that the leader
  propagates the latest active/pending operational datasets.
2020-05-29 17:01:46 -07:00
Rongli Sun 46305be082 [script] echo RADIO_PTY properly (#5023) 2020-05-29 10:40:00 -07:00
Zhanglong Xia c5aff31327 [cmake] add a cmake build script to build OpenThread (#4969)
This commit adds a bash script to compile the platform that supports
cmake.

Usage examples:
    ./script/cmake-build cc1352
    ./script/cmake-build posix -DOT_MAC_FILTER=ON
2020-05-29 08:33:50 -07:00
Moandor f6956dfcc9 [test] add various CLI command tests (#5017) 2020-05-29 08:31:58 -07:00
Abtin Keshavarzian 456cdf3091 [mle] add constant kMleSecurityTagSize for MLE security tag size (#5015) 2020-05-28 22:02:22 -07:00
Abtin Keshavarzian 19e2d148a1 [ecdsa] use reference (instead of pointer) for output length (#5015) 2020-05-28 22:02:22 -07:00
Abtin Keshavarzian 615bf36d88 [crypto] update method documentation and style (#5015) 2020-05-28 22:02:22 -07:00
Abtin Keshavarzian f640774684 [aes-ccm] misc enhancements (#5015)
- add a new enumeration type `Mode` to indicate the encryption vs.
  decryption mode in `AesCcm::Payload()` method.
- add `GetTagLength()` method and simplify `Finalize()`.
- change `AesCcm::Init()` to assert on bad tag length input param
  instead of returning `OT_ERROR_INVALID_ARGS`.
- reorder AesCcm member variable to help with alignments
- use CHAR_BIT
- remove check of tag length from Finalize
- use `memcpy`/`memset` to copy/clear buffers
2020-05-28 22:02:22 -07:00
Yakun Xu 72717f5178 [api] add a monotonic version number (#5012) 2020-05-28 22:01:33 -07:00
Abtin Keshavarzian 752ad977db [tlvs] add ReadTlv (ReadUint8Tlv, etc) helper methods (#5008)
This commit adds new helper static methods in `Tlv` class to read a
(simple) TLV in a `Message` at a given offset. The TLV's value can be
an `uint` type or a fixed length data blob. These methods are used
in ML and network-diagnostics modules, and also internally by other
`Tlv` class methods.
2020-05-28 15:23:23 -07:00
Abtin Keshavarzian 46eb55bb09 [tlvs] change Tlv::AppendTlv value param to be void pointer (#5008)
This commit changes the `Tlv::AppendTlv()` value parameter to use
`void *` as its type. This helps simplify its used in different
modules (we can simply pass a pointer to the object that is to be
appended as the TLV's value and avoid casting or conversion to
`uint8_t *`).
2020-05-28 15:23:23 -07:00
Abtin Keshavarzian 8b387c5fb4 [tlvs] rename helper methods to FindTlv (FindUint8Tlv, etc) (#5008)
This commit renames the helper `static` methods in `Tlv` class. It
harmonizes the naming model to use `FindTlv()` for different flavors
of methods that search within a given `Message` (or buffer) to find a
TLV with a given type. This commit also removes the re-definition of
same `static` methods in sub-classes of `Tlv` class. This helps
simplify the use of such methods and avoids the shadowing of some
flavors of methods  due to their re-definition in the sub-class (the
sub-class re-definition allows a more specific TLV `Type` enumeration
parameter to be used, however the base case version will continue to
work due to implicit conversion of `enum` value to an integer).
2020-05-28 15:23:23 -07:00
Simon Lin 578b29fa60 [thci] fix address filter code issues (#4986)
This commit fixes existing issues in address filters.

- Fix misuse of address filter modes
  - disabled should be disable
  - Whitelist should be whitelist
  - Blacklist should be blacklist
- Fix errors in removing macfilter entries

Impact on 1.1 certification:

This commit does not impact 1.1 certification because only
OpenThread_WpanCtl.py is changed. In 1.1 certification, all golden
devices are controlled by OpenThread.py. OpenThread_WpanCtl.py is used
to control OTBR DUT, and mac filter feature is not useful for a
DUT.
2020-05-28 11:23:00 -07:00
Yakun Xu 8b904a30e6 [github-actions] split toranj into a separate workflow (#5016)
This commit split toranj tests into a separate workflow so that we can
re-run it only when it fails.
2020-05-28 10:52:17 -07:00
Yakun Xu 23ed067d68 [cmake] make ot-config private (#5014) 2020-05-28 10:36:59 -07:00
Jiacheng Guo 52f4125558 [posix] fix state changed chandler filter logic (#5013) 2020-05-28 10:35:57 -07:00
Yakun Xu 5e65833d72 [ot-ctl] fix reset in non-interactive mode (#5011)
* set close on exec
* explicitly close socket on reset
* enhance ot-ctl to exit on peer close
* added test for the change
2020-05-28 10:31:16 -07:00
Jing Ma 204308f4a7 [harness-automation] fix browser stuck in navigating to url (#5005) 2020-05-27 22:43:57 -07:00
Yakun Xu 50cfda10b1 [script] install shfmt (#4989)
This commit installs shfmt in script/bootstrap.
2020-05-27 16:12:22 -07:00
rob-the-dude 034f89d824 [posix] some platforms don't support MSG_NOSIGNAL (#4996)
On platforms that have SO_NOSIGPIPE, use that to achieve the same result.

On platforms that have neither, emit a compile-time warning -- you may
still receive the signal on those systems.
2020-05-27 13:08:36 -07:00
Jonathan Hui 958c3c12e5 [docker] remove wpantund from environment image (#5006) 2020-05-27 12:47:50 -07:00
Moandor 75a382d292 [cli] fix argument parsing for counters command (#5004)
This fixes the argument parsing for counters command. The lines
calling otLinkResetCounters and otThreadResetMleCounters are
unreachable and this fixes it.
2020-05-26 10:26:34 -07:00
Yakun Xu 9a3c2dc3b3 [cmake] add ot-config (#5003)
This commit adds an interface target ot-config for collecting compile definitions.
2020-05-26 10:24:22 -07:00
Yakun Xu dd1be49d5f [script] suppress GitHub Actions check annotations (#5001) 2020-05-26 10:21:14 -07:00
Li Cao cdd62370d6 [continuous-integration] add github action to run 1_2 with clang (#4993) 2020-05-26 10:18:12 -07:00
Piotr Koziar d281be6aef [build] change underscore to dash in libmbedcrypto name (#5002) 2020-05-25 17:17:18 -07:00
Yakun Xu 3bc67ee6f9 [posix] get node id from command line argument (#5000)
This simplify manually running posix virtual time mode when debugging.
2020-05-25 16:03:27 -07:00
Philipp-Wohlgenannt-Tridonic-com 7942b00eee [cmake] add NCP vendor hook option from Zephyr (#4983)
Signed-off-by: Philipp Wohlgenannt <philipp.wohlgenannt@tridonic.com>
2020-05-25 15:58:06 -07:00
rob-the-dude 657b4cb291 [cli] add command for getting the network interface name and index (#4985)
* add a CLI command for getting the network interface name and index

On some platform (mostly BSDs), we do not have the option to specify
the tunnel name, although most of those platforms do have a way to dynamically
obtain a unique interface name if desired.  Add a CLI command -- only enabled
on platforms that have PLATFORM_NETIF enabled -- that will return the
name of the tunnel interface, as well as it's index.  Both are useful in doing
automated tests on non-Linux systems.

* remove OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE from the "check" scripts

This option really only applies to the POSIX "management" applications
(ot-daemon, ot-ctl), and not to the core radio or simulation component
builds (ot-cli, etc).

My other change adds a command ("netif") that is only useful when the
netif code is enabled, and that only happens when the netif code is linked,
which is only in those "management" utilities.  Turning this setting off
allows the tests to pass, with no impact to the functionality previously
tested.  But if this setting remains on, then my new code creates a
dependency that cannot be resolved outside the management applications.
2020-05-21 21:58:29 -07:00
Jiacheng Guo 12ac7d2730 [posix] tolerate SIGPIPE under daemon mode (#4994)
Chances are that the ot-ctl client exits between read error check and
write. This will lead to a SIGPIPE crash. We can ignore this signal and
check the error code instead.
2020-05-21 16:52:51 -07:00
Abtin Keshavarzian 875a945123 [network-diagnostic] fix parsing of Type List TLV in HandleDiagnosticReset() (#4992) 2020-05-21 12:05:13 -07:00
Abtin Keshavarzian 582c2c136a [network-diagnostic] skip unrecognized TLV type in FillRequestedTlvs() (#4992) 2020-05-21 12:05:13 -07:00
Abtin Keshavarzian ec1ba12dfd [network-diagnostic] use Tlv helper methods to append simple TLVs (#4992) 2020-05-21 12:05:13 -07:00
Abtin Keshavarzian 6ad88b49ab [network-diagnostic] simplify GetNextDiagTlv() implementation (#4992)
This commit simplifies the implementation of `GetNextDiagTlv()` by
skipping unrecognized TLVs from `default` case and jumping to top of
the loop for a next TLV, and adding a common `ExitNow()` at the end of
`switch()` statement to handle when a TLV is found and successfully
parsed. This change helps remove the need for `OT_UNREACHABLE_CODE()`
use.
2020-05-21 12:05:13 -07:00
Abtin Keshavarzian f0df3e3d6b [network-diagnostic] add Iterator type (#4992) 2020-05-21 12:05:13 -07:00
Abtin Keshavarzian c90f5f3f3e [network-diagnostic] add method documentation for GetNextDiagTlv (#4992) 2020-05-21 12:05:13 -07:00
Abtin Keshavarzian c4faeea067 [network-diagnostic] update GetNextDiagTlv() parameter to use Message (#4992) 2020-05-21 12:05:13 -07:00
Abtin Keshavarzian 8160f3423b [message] adding Message::Settings (#4977)
The `Message::Settings` mirrors `otMessageSettings` and is used
when allocating a new `Message`.
2020-05-20 22:57:56 -07:00
Abtin Keshavarzian 17a0405c51 [message] add Message::Priority enumeration type (#4977) 2020-05-20 22:57:56 -07:00
Abtin Keshavarzian 6c0b9214d8 [message] add Message::SubType (#4977) 2020-05-20 22:57:56 -07:00
Abtin Keshavarzian 2b613be823 [message] add Message::Type (#4977) 2020-05-20 22:57:56 -07:00
Abtin Keshavarzian 66afc9a969 [message] add helper methods to get Message Metadata (#4977)
This commit renames the message metadata to `MessageMetadata` and
adds helper method `Buffer::GetMetadata()` to get the metadata.
2020-05-20 22:57:56 -07:00
Abtin Keshavarzian ff30eddfdb [message] update Buffer and MessagePool to use LinkedList methods (#4977) 2020-05-20 22:57:56 -07:00
Abtin Keshavarzian dd5c9d3cac [message] update method decelerations, add documentation (#4977) 2020-05-20 22:57:56 -07:00
Li Cao 903ea67505 [mac-frame] fix problems to generate enh ack (#4990)
- Existing code assumes security is always enabled in enhanced ack,
  however that's not always the case. So add security part only when
  it's required.

- FindHeaderIeIndex would return kInvalidIndex when IE is not
  present. It's possible that no IE is in an enh ack, so use
  SkipSecurityHeaderIndex instead.
2020-05-20 22:43:59 -07:00
Simon Lin c2126a392f [cmake] add long routes options (#4859) 2020-05-20 21:02:25 -07:00
Simon Lin bdfafb437e [github-actions] add test to verify OTNS works (#4847) 2020-05-20 20:34:19 -07:00
Simon Lin 99e0666082 [mle] fix MLE Router handling errors (#4860) 2020-05-20 20:22:15 -07:00
Moandor a142b4234c [test] add expect tests for extaddr, ping, promiscuous (#4954) 2020-05-20 19:37:50 -07:00
Jing Ma 25d90c7f92 [mac] count out-of-band Tx frames (#4936) 2020-05-20 19:37:05 -07:00
Moandor 93c55f5837 [continuous-integration] remove git clean in scripts (#4988)
This removes the use of `git clean` in scripts to prevent accidental
loss of work.
2020-05-20 17:55:50 -07:00
Simon Lin fa96bcd10f [otns] allow virtual time UART (#4818) 2020-05-20 17:52:36 -07:00
Jonathan Hui 2485f72d15 [meshcop] do not send MGMT_*_SET.req while one is outstanding (#4981)
This commit helps ensure the following:

- At most one MGMT_ACTIVE_SET.req message is outstanding.

- At most one MGMT_PENDING_SET.req message is outstanding.
2020-05-20 14:27:41 -07:00
Yakun Xu 883d32356f [posix] ot-cli be indepedent of openthread-ncp-ftd (#4953) 2020-05-20 11:30:23 -07:00
Yakun Xu 31e600f227 [cmake] allow just build NCP/CLI/RCP (#4953) 2020-05-20 11:30:23 -07:00
Moandor c3e7fdc83e [instance] disable instance member copying (#4973) 2020-05-19 22:07:06 -07:00
rob-the-dude 86369858f7 [posix] allow configuration of macOS tunnel driver selection outside of code (#4980)
In order to enable automated testing of mac OS, we're likely to need
the ability to build for utun instead of tun, so make that option
configurable via external options, and make the default utun, which
will be easier for most developers to use (the caveats are documented
in netif.cpp).
2020-05-19 17:26:26 -07:00
Jonathan Hui dd0fa0d34c [shell] resolve shellcheck warnings (#4966) 2020-05-19 13:04:42 -07:00
Jonathan Hui cb9b353fb3 [scripts] apply shfmt changes (#4966) 2020-05-19 13:04:42 -07:00
Jonathan Hui 916023b6e7 [pretty] add support for shell (#4966) 2020-05-19 13:04:42 -07:00
Simon Lin 8dbc0d9605 [test] fix python issues in tests (#4960) 2020-05-19 10:31:50 -07:00
kangping 154958aab9 [tests] fix wrong whitelist filter in commissioning tests (#4933)
This commit fixes the problem that `whitelist` is not enabled in
commissioning test cases which results in false pass of `Cert_8_2_01`
and `Cert_8_2_02`.

Without this commit, `Cert_8_2_01` and `Cert_8_2_02` will fail if we
turn on `whitelist`, because we now use random extaddress for
discovery requests.
2020-05-19 10:30:11 -07:00
rob-the-dude 6adfa966e0 [posix] two fixes for macOS and FreeBSD (#4979)
First, deal with the C++ crankiness about a structure defined inside
another structure, but make sure we don't get tripped up if the SDK
ever changes.

Second, macOS should not be using the IN6_IFF_NODAD, as rather than
avoiding DAD, it actually makes addresses remain in the "tentative"
state indefinitely.
2020-05-18 16:43:02 -07:00
rob-the-dude 730b94f4f7 [posix] allow compilation on FreeBSD (#4978) 2020-05-18 16:34:02 -07:00
Yakun Xu 7d1934202f [cmake] add ncurses dependency (#4971)
This is required on OpenWRT.
2020-05-18 09:36:55 -07:00
Jonathan Hui 132ba9d3fb [continuous-integration] add build checks for jn5189 and k32w061 (#4968) 2020-05-18 09:36:00 -07:00
Abtin Keshavarzian 436aba64c0 [mac] adding otMacKey and Mac::Key (#4967)
This commit adds a new type `otMacKey` which represents a MAC security
key (used by AES-CCM to perform frame security) and core subclass of
this as `Mac::Key`. The same type is used as `Mle::Key`. The
`KeyManager`, `Mac`, `Mle`, and other modules are updated to use the
new `Key` types. The public OT API `otLinkRawSetMacKey` and radio
platform `otPlatRadioSetMacKey()` are also updated to use `otMacKey`.
2020-05-18 09:35:45 -07:00
Łukasz Duda 72109da6f1 [nrf52833] use 2 flash pages for non-volatile memory by default (#4972) 2020-05-15 10:18:49 -07:00
Moandor 3d870fc312 [channel-monitor] remove channel monitor copying (#4970)
This removes the copying of `ChannelMonitor` in
`otChannelMonitorSetEnabled`, so channel monitor enable/disable can work.
2020-05-15 10:01:45 -07:00
Simon Lin 7a3b52ed87 [codecov] only comment after a number of builds (#4961) 2020-05-15 10:00:23 -07:00
doru91 3122132af8 [examples] add k32w061 platform (#4930) 2020-05-14 14:19:25 -07:00
Łukasz Duda 09dd07d823 [ip6] do not pass reassembled IPv6 packet to the host (#4964)
When Border Router is built with `OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE`
flag and receives the message to its Mesh-Local EID, for a small range of IPv6
lengths, NCP may forward both IPv6 fragments and reassembled packet. This commit
ensures the latter situation does not happen.
2020-05-14 10:29:12 -07:00
Duda, Lukasz 495f76571f [coap] ensure CoAP control messages are prioritized (#4962) 2020-05-14 09:09:17 -07:00
Duda, Lukasz 7edb455330 [icmp6] ensure ICMPv6 error messages are prioritized (#4962) 2020-05-14 09:09:17 -07:00
Jiacheng Guo 3e1bf97188 [posix] return INVALID_STATE on EINVAL (#4959)
After adding and removing addresses, sendmsg call will return EINVAL for
a short period of time. Return INVALID_STATE to inform callers to try
again later.
2020-05-14 09:01:34 -07:00
kangping 092eb186e1 [joiner] add validation of joiner PSKd (#4934) 2020-05-14 08:41:51 -07:00
Yakun Xu aa1b2927c8 [diag] check RCP diag commands (#4955) 2020-05-13 18:10:14 -07:00
Li Cao e3acd17466 [config] change macro define names for CSL feature (#4958) 2020-05-13 14:40:49 -07:00
Abtin Keshavarzian a272835196 [mle-tlvs] fix method documentation (#4956) 2020-05-13 10:22:39 -07:00
Zhanglong Xia 39567513eb [nrf528xx] add OT_UNUSED_VARIABLE to avoid compiler warning (#4951)
When the macro `SPIS_AS_SERIAL_TRANSPORT` is enabled,
`UART_AS_SERIAL_TRANSPORT` and `USB_CDC_AS_SERIAL_TRANSPORT`
are disabled, no one uses the argument `aPseudoReset`. The
compiler generates a warning.
2020-05-13 10:16:57 -07:00
Jonathan Hui 03d65251cb [message] change MoveOffset() to return void (#4949) 2020-05-13 10:16:19 -07:00
Jonathan Hui 1ce5064832 [message] change SetOffset() to return void (#4949) 2020-05-13 10:16:19 -07:00
Jintao Lin 2afbc59293 [mac] put transmission AES-CCM* to SubMac layer (#4919)
In Thread 1.2, it is possible to receive an IEEE 802.15.4-2015
packet. Per specification, receiver should acknowledge this packet
with an IEEE 802.15.4-2015 ACK(Enh-ACK). This Enh-ACK can include
header IE with it and requires security enabled bit in FCF be set to
true. It is impractical for the host to generate the Enh-ACK and send
to RCP for transmission within AIFS time(192us). So RCP should prepare
the Enh-ACK by itself, which requires it to fill in the frame counter
and do the encryption/authentication. This commit tries to address the
need of transmission security/authentication by including the
following changes,

- Move Key ID mode 1 AES-CCM* related functions from MAC layer to
  SubMac layer, which is mirrored in RCP.

- Distribute the MAC key and MAC key ID to RCP in posix app using
  newly added spinel properties.

- Make it possible for radio(either in radio driver or hardware) to do
  transmission AES-CCM* if the platform supports by adding radio
  capability OT_RADIO_CAPS_TRANSMIT_SEC.

- Enable this for RCP mode on simulation platform.
2020-05-13 10:15:39 -07:00
Li Cao cd9558ca91 [mac-frame] add util functions to generate ack (#4884)
This commit adds mac frame util functions to generate acks (both Imm
and Enh acks) from a received frame. These funtions are utils APIs for
platforms which don't provide ack generation.

This commit also introduces compile options for CSL to control the CSL
IE related part.
2020-05-12 22:20:03 -07:00
Zhanglong Xia 8e84e05429 [posix] fix inconsistent function definitions issue (#4950)
The arguments of the funtion `otPlatDiagProcess` in posix radio driver
is different from the one defined in the `diag.h`. It causes the diag
module uses the weak definition of the function `otPlatDiagProcess`.
This commit fixes this issue.
2020-05-12 18:03:32 -07:00
Moandor b4a5df49e6 [continuous-integration] enable most features on build check (#4946) 2020-05-11 16:45:38 -07:00
Abtin Keshavarzian 1016a5425b [toranj] add new test to verify lowpan fragmentation (#4945)
This commit adds a new test to verify 6LoWPAN fragmentation logic by
exchanging IPv6 messages with many different lengths between two
nodes.
2020-05-11 15:23:58 -07:00
Abtin Keshavarzian 48086040b7 [mesh-forwarder] allow last 6LoWPAN fragment to use longer length (#4945)
This commit relaxes the length check for the last 6LoWPAN fragment of
a message. The length of a 6LoWPAN fragment is truncated to be a
multiple of eight bytes (since fragment offset can be only expressed
as multiples of eight). However this requirement does not apply to the
last fragment. This change helps avoid an unnecessary extra fragment
for messages of certain length.
2020-05-11 15:23:58 -07:00
Duda, Lukasz 2f683e6e76 [ip6] enhance handling of IPv6 fragmentation (#4940)
This commit introduces a few enhancements:

- In NCP architecture forward the IPv6 fragments instead of the full
  reassembled IPv6 packet (which in the default configuration can't be
  forwarder due to SPINEL limitations). Without this fix the
  fragmentation does not work if Thread device wants to send more than
  MTU data through the Border Router (to the IPv6 address of NCP).

- Use OPENTHREAD_CONFIG_IP6_MAX_ASSEMBLED_DATAGRAM only for the
  receiving path. For transmitting path, relay on the message buffers
  pool. This is especially important for some of the use-cases we
  have, and also reduce a need for regenerating OpenThread libraries.

- In case receiving IPv6 packet is bigger than supported
  OPENTHREAD_CONFIG_IP6_MAX_ASSEMBLED_DATAGRAM, exit before trying to
  allocate the next message buffer.
2020-05-11 15:22:18 -07:00
Duda, Lukasz 069afa5a17 [ip6] do not free the same message twice while handling IPv6 fragment (#4940)
This commit fixes the serious bug when IPv6 fragmentation is
enabled. It is possible that HandleDatagram which is called on
complete reassembly, returns the error (e.g. because ICMPv6 Echo
Response can't be generated due to lack of buffers). In such case both
HandleDatagram method and HandleFragment tries to free the same
message which finally ends up in a crash of the system.
2020-05-11 15:22:18 -07:00
Duda, Lukasz 9aa7340eb2 [ncp] ensure IPv6 packet length does not exceed maximum size of SPINEL command payload (#4940)
With the current code, it is possible that NCP tries to send IPv6
packet larger than the maximum size of SPINEL command payload.

This commit adds additional defines to spinel.h and proper checks in
NCP codebase.
2020-05-11 15:22:18 -07:00
Jonathan Hui c5b9c3efac [netif] change UnsubscribeAllRoutersMulticast() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui f97aacb501 [netif] change SubscribeAllRoutersMulticast() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui 19ecc83acc [netif] change UnsubscribeAllNodesMulticast() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui 8ff86bba70 [netif] change SubscribeAllNodesMulticast() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui 6a3e04a48f [netif] change UnsubscribeMulticast() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui e8d6705fdd [netif] change SubscribeMulticast() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui 3bc11b88bf [netif] change RemoveUnicastAddress() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui 2607671f33 [netif] change AddUnicastAddress() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui cf57110c47 [message-queue] change Dequeue to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui 7540758076 [message-queue] change Enqueue() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui af207d18d7 [coap] change AddResource() to return void (#4942) 2020-05-11 14:07:25 -07:00
Jonathan Hui ccaefa3e39 [commissioner] change SendKeepAlive() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 988d39ba34 [joiner-router] change DelaySendingJoinerEntrust() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 97debabc03 [dhcp6-server] change AddPrefixAgent() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 0315ac0a0f [dhcp6-client] change Solicit() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui e79a7be773 [icmp] change SendIcmpError() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui d20a65b87c [meshcop] change "send" methods to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 4e9cefbb84 [energy-scan-server] change SendReport() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 5590771eb8 [coap] change SendCopy() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 5b8b36ab11 [sntp-client] change SendCopy() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 20ed51796d [dns-client] change SendCopy() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 71af8794bd [panid-query-server] change SendConflict() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 30bf77808e [network-data] change RegisterNetworkData() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 4f05c99e17 [network-data] change RemoveCommissioningData() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui e55906c5eb [mesh-forwarder] change GetForwardFramePriority() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 19ac977b08 [address-resolver] change SendAddressError() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 1e5d816838 [address-resolver] change AddSnoopedCacheEntry() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 29c2d11170 [mac] change RequestDirectFrameTransmission() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 1578346dce [indirect-sender] change AddMessageForSleepyChild() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 8172e31a47 [trickle-timer] change Start() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 8a27e6da83 [data-poll-sender] change StopFastPolls() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 11db44e36a [data-poll-sender] change StartPolling() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui eac2dd9d07 [data-poll-handler] change RequestIndirectFrameTransmission() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 7d8567d57b [announce-sender] change SendAnnounce() to return void (#4941)
- Move "start" log to common method.

- Use default param value instead of duplicate method.
2020-05-11 12:44:54 -07:00
Jonathan Hui 07120a8a54 [mle] change RefreshStoredChildren() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 3ce4159414 [mle] change SendAddressRelease() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui a173ed3838 [mle] change SendDataResponse() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 8ca96f0fd6 [mle] change SendAdvertisement() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 532a44b76d [mle] inline AddLeaderAloc() (#4941)
Also move Mle::AddLeaderAloc() to MleRouter::AddLeaderAloc().
2020-05-11 12:44:54 -07:00
Jonathan Hui 3f299d3701 [mle] change InformPreviousParent() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 40f4d20c9d [mle] change HandleChildStart() to return void (#4941) 2020-05-11 12:44:54 -07:00
Jonathan Hui 86be53e190 [mle] change message handlers to return void (#4941)
Returned errors were always being ignored.
2020-05-11 12:44:54 -07:00
Abtin Keshavarzian a1adaac91a [tasklet] change Post() to return void (#4939)
This commit changes the `Tasklet::Post()` method to return `void`
instead of `otError`. This helps simplify its use. The error indicated
whether the tasklet was already posted and was always ignored
(required `IgnoreError()` when posting tasklets). `IsPosted()` method
can be used to determine this when/if needed.
2020-05-11 10:24:58 -07:00
Yakun Xu 1dd0abc591 [style] fix unused variables in release build (#4938)
* change package check build Release
2020-05-09 17:15:21 -07:00
Moandor 92b290e018 [continuous-integration] avoid coverage data loss (#4937)
The code coverage data generated by ./script/test build expect will be
erased by VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build
expect's clean step, causing coverage less than actual value. This
adds an upload step after the first run to avoid the data loss.
2020-05-08 17:03:11 -07:00
Li Cao 417093e247 [tests] fix key_id_mode handling and add exception handle (#4927)
This commit fixes key_id_mode handling and added exception handling
when key_id_mode is 0.

According to IEEE Std 802.15.4-2015, when Key Id Mode is 0x00:

    Key is determined implicitly from the originator and recipient(s)
    of the frame, as indicated in the frame header.

Our test scripts cannot handle such packets. If we leave key_id_mode =
0 case unhandled, we would get some exceptions that may cause
developers to think that something is wrong. However dropping packets
in this case is a normal behavior.
2020-05-07 21:33:30 -07:00
Moandor 60aa241594 [error] disable error checking enforcement for old versions of clang (#4932)
With clang older than 3.9, the warn_unused_result feature works only
with functions and classes, not enums. This disables it if the clang
version is too old.
2020-05-07 10:36:06 -07:00
Abtin Keshavarzian f411a412be [toranj] update build script to treat "warning as error" under cmake (#4931) 2020-05-06 22:05:25 -07:00
Abtin Keshavarzian b07a33acec [continuous-integration] add macOS build config with clang compiler (#4931) 2020-05-06 22:05:25 -07:00
Abtin Keshavarzian 612e10e664 [error] add missing IgnoreError (#4931) 2020-05-06 22:05:25 -07:00
Moandor 64dfe6349c [posix] remove duplicate otExitCodeToString definition (#4928) 2020-05-06 18:45:03 -07:00
Yakun Xu f7a4d05219 [cmake] add project version (#4929)
* use an older version for better compatibility
* add version to project
* only use cpack when OpenThread is the top-level project
* exclude posix apps when BUILD_EXECUTABLES is OFF
* exclude all third_party
2020-05-06 17:46:13 -07:00
Diego Ismirlian eb4125c97d [build] add -Wcast-align to detect potential alignment issues when casting (#4923) 2020-05-06 17:42:48 -07:00
kangping 49f36f8c24 [error] force error checking (#4784) 2020-05-06 11:17:58 -07:00
Rongli Sun 6e8f2c9913 [dua] MTD prioritizes DUA in Address Registration TLV (#4862)
Thread 1.2 spec requires prioritizing DUA in Address Registration TLV
to ensure DUA could be stored in the limited addresses space for Child
on the parent.
2020-05-05 18:16:59 -07:00
doublemis1 2153f5a4f4 [harness-automation] add another PDU Controller for EATON by SNMP (#4688)
Another PDU Controller used to power cycle between tests. Based by
SNMP protocol. To use EATON_PDU_CONTROLLER is needed PySNMP module
(added to requirements.txt). Also extend settings_sample.py by
comments with needed parameters to create EATON_PDU_CONTROLLER.
2020-05-04 14:43:34 -07:00
kangping e08f5aebd9 [joiner] use random extended address for discovery request (#4920)
Thread specification requires the source address of Discovery Request
to be random value. While for subsequent messages, the joiner should
use hash of EUI-64 (joiner ID) value.
2020-05-04 11:04:05 -07:00
rob-the-dude 9faa71dc3e [logging] fix typo for otDumpNote definition (#4922) 2020-05-02 23:28:41 -07:00
rob-the-dude b378eb1aa8 [posix] fix two compile-time errors for macOS utun driver (#4921) 2020-05-02 23:27:22 -07:00
Yakun Xu 7b0cb98445 [posix] add argument to set max power table (#4878)
This commit adds a max power table for POSIX platform, which can
customize the max allowed transmit power of each channel with the
command line argument --max-power-table.
2020-04-30 14:23:16 -07:00
kangping c4b098f0d3 [instance] fix multiple instance compilation (#4915) 2020-04-30 12:27:42 -07:00
Yakun Xu 47ebcbd184 [cmake] add log output option (#4914)
This is required for running commissioning related tests for the
commissioning messages are retrieved from logs.
2020-04-30 10:45:14 -07:00
Moandor 8d6610f3d5 [continuous-integration] add POSIX SPI build (#4913)
This adds a CI build for POSIX platform with SPI enabled.

Also fixed a build error in `spi_interface.cpp`.
2020-04-30 10:42:44 -07:00
Abtin Keshavarzian 4cf2abc24e [toranj] fix typos (#4917) 2020-04-29 23:03:27 -07:00
Simon Lin 56cf651fb2 [test] fix script/test on macOS (#4916) 2020-04-29 23:02:58 -07:00
Rongli Sun 2e85801083 [dua] Domain Unicast Address generation (#4854)
This commit includes
[Y] add `OPENTHREAD_CONFIG_DUA_ENABLE` option for DUA feature
[Y] generate DUA via SLAAC
[Y] update test script to verify communication via DUA
2020-04-29 22:57:50 -07:00
Rongli Sun 904e12d047 [slaac] allow customized parameters when GenerateIid() (#4854) 2020-04-29 22:57:50 -07:00
Simon Lin bbcfc3ca1e [commissioner] remove duplicate MGMT_COMMISSISONER_SET.req (#4902)
- Remove the unnecessary MGMT_COMMISSISONER_SET.req sent by
  Commissioner to Leader when a Joiner is removed only to be added
  back.

- Use proper error codes for MleRouter::HandleDiscoveryRequest
2020-04-29 18:39:43 -07:00
Jing Ma 46d5343d95 [cmake] move cc1352 & cc2652 libs to third-party cmake file (#4875) 2020-04-29 15:48:55 -07:00
Yakun Xu 81fb1210c4 [continuous-integration] recover verbose check (#4911)
The error logs of `check` will only be printed when VERBOSE=1.
2020-04-29 11:03:21 -07:00
Abtin Keshavarzian 0ffe586ae8 [dataset-manager] adding DatasetTlv (a generic Dataset TLV to read from msg) (#4907) 2020-04-29 11:01:48 -07:00
Abtin Keshavarzian 0877efe2eb [mac] verify that Security Level is correct in rx frame (#4905)
This commit adds a check in `Mac::ProcessReceiveSecurity()` to verify
that the Security Level in the received frame is properly set to
`kSecEncMic32` before trying to decrypt and validate the frame. This
helps avoid performing AES-CCM when frame is invalid and also avoid
potentially reading beyond the frame length when checking MIC/footer.
2020-04-29 10:55:51 -07:00
Rafał Kuźnia 696d6389e6 [mac] disable SubMac on instance finalization (#4903)
When OT is initialized after boot, finalized, and initialized again
without reboot, assertion in SubMac::Enable is triggered. The reason
is that SubMac::Disable is never called during finalization and
platform radio is in unexpected state.
2020-04-29 10:54:46 -07:00
Simon Lin dd3b14dad0 [commissioner] fix duplicate commissioner start (#4899)
This commit fixes the bug that duplicate commissioner start will
incorrectly close CoapSecure.
2020-04-29 10:51:43 -07:00
Simon Lin e5069a41d5 [scripts] update cert tests to use thread_cert.TestCase (#4874)
- Update all test cases to inherit thread_cert.TestCase and update
  topologies accordingly. The topologies should all be correct because
  they are automatically generated, not hand written.

- Use default Thread version: 1.1

- Cleanup node tmp files in tmp directory according to the current
  PORT_OFFSET in setUp. This is required by
  test_reed_address_solicit_rejected.py and test_coap_observe.py since
  they define multiple test functions in one TestCase.

- Removed call to set_extaddr64 because it's not necessary and causing
  failures.
2020-04-29 10:41:04 -07:00
Jeff Bumgardner 90ecb574bb [docs] update Doxygen menu for OTNS and BBR (#4908) 2020-04-29 10:29:02 -07:00
Jonathan Hui ebb52da68e [continuous-integration] add macos posix build check (#4906) 2020-04-28 22:52:20 -07:00
rob-the-dude 1a43e27d47 [posix] refactoring of netif code, mostly to accommodate BSDs (#4664)
This code does the following:

- provides an implementation to manage networking notices from a PF_ROUTE socket,
	instead of (the Linux-specific) PF_NETLINK

- breaks out some of the platform-specific mechanisms for configuring a tunnel
	device (Linux, mac OS, and NetBSD are all different in some ways)

- provides handling of I/O to the tun drivers on BSDs (where there's a 4-byte
	header prepended to identify the IP version)

- adds some debugging info and more deliberate error handling (I suspect
	there are some more OpenThread-friendly ways to do some of the
	debugging, but I didn't try to figure them out)
2020-04-28 18:18:44 -07:00
Moandor-y c76d325b21 [continuous-integration] add clang 32 bit build (#4896) 2020-04-28 16:45:47 -07:00
Moandor-y 15a443dd0c [spinel] fix time narrowing conversion (#4896)
This makes narrowing conversions of time types explicit to fix build
errors.
2020-04-28 16:45:47 -07:00
Rongli Sun c8efee95f3 [nits] unify size_t type for local variable when OT_ARRAY_LENGTH is used (#4894) 2020-04-28 16:31:25 -07:00
Rongli Sun 79f1d4c5c8 [core] ApplyMeshLocalPrefix() to applicable ALOCs (#4894) 2020-04-28 16:31:25 -07:00
Seth Rickard 972acd734f [build] add unused code macros after asserts (#4885)
This change is to address some warninings present on the ti-cgt
toolchain. Code after a while(true) loop or an unconditional jump
results in a dead code warning.
2020-04-28 16:07:43 -07:00
kangping 80285206d2 [tests] add 5_7_01 network diagnostic test cases (#4663)
This commit adds Network Diagnostic TLV parsing and 5.7.01 test case.
2020-04-28 13:37:21 -07:00
Jonathan Hui 0778831ecd [toranj] update address cache table test (#4879)
Updated test-021-address-cache-table.py to reflect cache entry
invalidation when sending to a neighbor that does not have the
destination.
2020-04-28 11:30:13 -07:00
Jonathan Hui 3c09c378d4 [mesh-forwarder] ensure mesh dst checks for dst unreach (#4879)
An out-dated EID-to-RLOC map cache may lead a device to send an IPv6
datagram to a device that does not have the IPv6 Destination Address
assigned to its interface. However, the existing implementation would
not send back an ICMPv6 Destination Unreachable message necessary to
invalidate the originator's EID-to-RLOC cache entry.

This implementation adds reachability checks on the mesh destination
receive path to ensure that reachability checks are performed in the
above situation.
2020-04-28 11:30:13 -07:00
Jonathan Hui 2567aec36f [mesh-forwarder] send all message fragments to the same mesh dest (#4879)
All fragments for a given IPv6 datagram must be sent to the same
destination. Otherwise, there is not much point in transmitting the
messages.
2020-04-28 11:30:13 -07:00
kangping 509807e377 [cmake] enable user specified mbedtls target (#4812)
This commit allows users to specify the mbedtls target by a
OT_EXTERNAL_MBEDTLS option.

The native cmake build system of mbedtls is not so "modern" (for
backward compatibility, it maybe hard to change it soon) and
applications using mbedtls are likely to write wrapper cmake files and
targets by themselves.
2020-04-28 11:28:09 -07:00
Simon Lin c169c2c552 [tests] add Thread 1.2 all features build test (#4850) 2020-04-27 23:46:28 -07:00
Rongli Sun baa5fdfebe [bbr] move bbr relative addresses to BackboneRouter::Local (#4893) 2020-04-27 20:45:13 -07:00
Rongli Sun 5c7c147ff2 [address-resolver] fix ADDR_NTF.ans to use Child's Mesh Local IID (#4898) 2020-04-27 18:27:14 -07:00
Abtin Keshavarzian 83d73fc9f2 [mac-frame] helper methods to calculate size of headers/MIC (#4887)
This commit adds new helper methods in `Mac::Frame` to calculate the
size (number of bytes) of headers or security MIC. These are used by
different methods to simplify the code and avoid repeated patterns:
- `CalculateAddrFieldSize(aFcf)` to calculate the size of Address
  Fields given a Frame Control value.
- `CalculateSecurityHeaderSize(aSecurityControl)` to calculate size
  of Security Header given a Security Control value.
- `CalculateMicSize(aSecurityControl)` to get the size of MIC given
  a Security Control value.
2020-04-27 18:06:09 -07:00
Jonathan Hui c1f0856adb [style] remove const from uint16_t function/method params (#4901) 2020-04-27 12:59:24 -07:00
Yakun Xu 7c428118f0 [cmake] detect big endian (#4892) 2020-04-27 12:58:46 -07:00
Yakun Xu a58163c9a3 [test] allow extra options (#4891)
Example:

```bash
OT_OPTIONS="-DOT_FULL_LOGS=ON -DOT_LOG_LEVEL_DYNAMIC=OFF" ./script/test clean build
```
2020-04-27 09:37:29 -07:00
Yakun Xu 779da7c858 [diag] initialize tx power and channel on start (#4890) 2020-04-26 10:02:28 -07:00
Yakun Xu b19aafc76d [mac] fix warning in mac_types.hpp (#4889) 2020-04-26 10:01:55 -07:00
Abtin Keshavarzian 931cdedc84 [dataset] misc enhancements (#4888)
This commit contains a group of smaller enhancements/simplifications
in `Dataset` modules:
- Add helper `GetTlvsStart()` and `GetTlvsEnd()` to get start/end
  of Dataset TLVs sequence.
- Use `for` loop when iterating over TLVs.
- Simplify `RemoveTlv()` to get a pointer to TLV as input
- Remove single-use local TLV variables (in switch statements).
- Simplify `DatasetLocal::Compare()`.
2020-04-25 14:53:35 -07:00
Yakun Xu be48ea648c [thread-cert] use the same mesh local prefix as Thread harness (#4089) 2020-04-24 17:24:53 -07:00
Jonathan Hui 082f7e9fdc [docs] apply prettier changes (#4881) 2020-04-24 16:22:00 -07:00
Jonathan Hui c48f84d9ea [pretty] add markdown support (#4881) 2020-04-24 16:22:00 -07:00
Yakun Xu 32f8274395 [cmake] enhancements for supporting cmake in ot-br-posix (#4876) 2020-04-24 16:21:06 -07:00
Abtin Keshavarzian 7e5dce0542 [tests] update Mac::Frame unit test to check footer and frame length (#4883) 2020-04-24 16:15:02 -07:00
Abtin Keshavarzian 3921409859 [mac-frame] ensure frame length is correctly updated from InitMacHeader() (#4883)
This commit directly updates the `mLength` from `InitMacHeader()` as
it prepares the frame header (instead of setting it at the end).

This ensures that `InitMacHeader()` can safely call other `Frame`
helper methods (e.g. `GetFooterLength()` which itself does check
the frame length).
2020-04-24 16:15:02 -07:00
Rongli Sun 60be2be68a [mle] 1.2 MED registers MA (scope > 3) to its parent via AR TLV (#4837) 2020-04-24 10:17:55 -07:00
Yakun Xu a13d8b958f [cli] fix infinite loop on networkdiagnostic (#4882)
Reproduce by issuing networkdiagnostic get ff03::1 0 1 on one router.
2020-04-24 08:49:21 -07:00
Jonathan Hui c0075d42c3 [pretty] fix yapf version to 0.29.0 (#4880)
v0.30.0 (released on 2020-04-23) introduces formatting changes that
are not compatible with v0.29.0.
2020-04-23 17:14:58 -07:00
Sagar Chinchani 4f3b66bf7e [efr32] update NVM3 to use default instance (#4849)
This commit updates the nvm3 support implementation to use the nvm3
default instance instead of creating a separate nvm3 instance. This
approach enables us to share the nvm3 system using a single default
instance between OpenThread and any other stack or application used
along with OpenThread.

This commit also adds the otPlatFlash* APIs back in flash.c that were
incorrectly removed in a prior commit. These APIs are required when
using the default NV system.
2020-04-23 09:15:45 -07:00
Jing Ma 8822fcd590 [cmake] add support for cc2650, qpg6095, samr21 (#4729) 2020-04-22 18:43:44 -07:00
Jonathan Hui 577cccfeff [cli] add factoryreset for Joiner in README_COMMISSIONING.md (#4868) 2020-04-22 13:47:38 -07:00
richarddonkin c2f316fead [cc1352,cc26xx] fix unaligned access of ext address in radio.c (#4617)
This avoids misaligned  memory access that was caused by the
byte-aligned pointer being dereferenced as a uint64_t pointer.
2020-04-22 13:46:37 -07:00
Yakun Xu 5632c271b8 [posix] use enumerations for RCP bus (#4871)
This commit changes the way to define RCP bus type. It now defines two
enumerations for UART and SPI. This ensures only a single bus type is
enabled, and helps keep compatible with projects using UART bus.
2020-04-21 23:23:12 -07:00
Jiacheng Guo 25b29a1ade [platform] fix errno undefined on some libc (#4865) 2020-04-21 23:20:33 -07:00
Yakun Xu c034fd0c0c [size-report] support local check (#4866) 2020-04-21 15:37:46 -07:00
Bob MacDonald 85f40acbe4 [joiner] fix code coverage typo (#4867) 2020-04-21 15:05:30 -07:00
Abtin Keshavarzian 29d7e69f23 [dataset] add GetTlv<Type>(), and SetTlv() for simple TLVs (#4856)
This commit adds helper method `MeshCoP::Tlv::FindTlv()` to search
within a given sequence of TLVs for a specific TLV type. This is used
to simplify `Dataset::GetTlv()` and provide a template version
`GetTlv<TlvType>()`. This commit also adds new flavors of `SetTlv()`
for simple TLVs, i.e, TLVs with a single value which is either an
`uint16_t` or `uint32_t` value or can be treated a data blob.
2020-04-21 10:42:33 -07:00
Zhanglong Xia 7fd9715d71 [nrf52811] use the default heap size to save RAM (#4864)
The nRF52811 is designed to work in RCP architecture where DTLS is
established on the host level. The nRF52811 doesn't support Joiner or
Border Agent roles. This commit enables nRF52811 to use default heap
size to save RAM.
2020-04-21 09:26:17 -07:00
Li Cao e839100be1 [cmake] enable running simulation unit tests using cmake (#4842)
In this commit, we would be able to run all the simulation unit tests
easier with cmake:

./script/test clean build unit_tests
2020-04-20 20:52:38 -07:00
Jiacheng Guo 8de4ab4740 [spinel] platform independent spinel radio (#4705)
This change refactors radio-spinel into a platform independent
header-only library so that other platforms (baremetal/RTOS) can
enable Thread with RCP mode as well.
2020-04-20 20:50:58 -07:00
Jiacheng Guo f37d72e5ca [posix] open netif fds with O_NONBLOCK in a compatible way (#4804) 2020-04-20 19:06:07 -07:00
Jonathan Hui af4837d122 [network-data] fix length overflow in ServiceTlv::IsValid() (#4855) 2020-04-17 21:19:22 -07:00
Yakun Xu 68fc38865a [docker] add docker file for android check (#4852) 2020-04-17 18:43:02 -07:00
Jonathan Hui 5b44a7d595 [docs] update CONTRIBUTING.md (#4857) 2020-04-17 18:39:13 -07:00
Simon Lin 8efa1ee4c6 [mle] REED to handle rejected ADDR_SOL.rsp (#4834)
Currently, a REED which expects to become Router soon does not send
any SVR_DATA.ntf.  This commit handles rejecting ADDR_SOL.rsp to allow
REED to send SVR_DATA.ntf after it is rejected.
2020-04-17 17:03:45 -07:00
Yakun Xu 1089aa9ff4 [continuous-integration] move android check to GitHub Actions (#4829) 2020-04-17 16:46:44 -07:00
Yakun Xu 4b55284bd2 [tests] add cli pskc command test (#4853) 2020-04-17 08:29:07 -07:00
Simon Lin 39de36a9c9 [github-actions] use matrix for gcc builds (#4851) 2020-04-17 08:27:36 -07:00
Simon Lin f797a42069 [logging] fix compile error for BBR region (#4848) 2020-04-17 08:22:36 -07:00
Abtin Keshavarzian 4b47deee5a [dataset] multiple enhancements (add Type, rename to GetTlv/SetTlv, etc.) (#4844)
This commit contains multiple enhancements in `Dataset` modules. It
adds a new enumeration `Type` to specify the type of a Dataset
(active or pending). It also renames the methods that get or a set a
TLV within the dataset to `GetTlv()` and `SetTlv()`. It also renames
methods converting the TLV format to/from an `otOperationalDataset`
structure. With the renames, we can remove the re-definition of
`Get<Type>()` method (since no longer being shadowed by other
definitions). Finally this commit updates some of the method
documentation.
2020-04-17 08:21:43 -07:00
Jonathan Hui 542eff9ba4 [network-data] validate Prefix and Service TLVs have sub-TLVs (#4843) 2020-04-17 08:20:42 -07:00
Yakun Xu fd6cde5981 [size-report] support github actions (#4825) 2020-04-16 23:22:01 -07:00
Li Cao ab029ec0ac [mac-frame] enhance utility functions (#4826)
This commit enhances some utility functions in mac frame for frame
parsing and adds some basic testing.

- Currently the mac frame parsing only doesn't include the rule for
  version 2015. This commit adds the parsing of dstPanId for 2015
  frames.

- This commit adds some helper function dealing with Security Header
  so that later commit of CSL and setting security header in enhanced
  ACK would be easier.
2020-04-16 23:11:45 -07:00
Jonathan Hui c34f3ef817 [samr21] fix build when logging is enabled (#4846)
- include "board.h" before its defines are used
2020-04-16 18:40:46 -07:00
Jonathan Hui 32e308833c [random] use crypto RNG in places were non-trival random is required (#4840) 2020-04-16 13:50:38 -07:00
Abtin Keshavarzian 69c3e2eed6 [ip6-address] helper methods to set Link-Local and RLOC/ALOC addresses (#4841)
This commit adds and uses a new method `SetToLinkLocalAddress()` in
`Ip6::Address` class which sets the address to a Link-Local IPv6
address with a given Interface Identifier (either given directly or
generated from a MAC Extended Address).

It also adds methods to set the address to a Routing/Anycast Locator
and updates methods checking RLOC/ALOC addresses. It adds a common
`IsIidLocator()` to check if the IID matches the `0000:00ff:fe00:xxxx`
pattern. More specific checks for RLOC or ALOC can be done by
`IsIidRoutingLocator()` or `IsIidAnycastLocator()`. The `Mle` and
other modules are updated to use the new/updated methods.
2020-04-16 10:39:35 -07:00
Rongli Sun b1ec563a81 [key-manager] add helper method (#4838) 2020-04-15 20:34:56 -07:00
Rongli Sun ec61d7e6fc [ip6] add check before adding or removing the unsecure port (#4839) 2020-04-15 19:59:48 -07:00
Markus Becker 8e932e8c77 [cmake] disable -pedantic-errors together with -Werror (#4775)
This allows to work-around a compile error that is happening in Zephyr
<https://github.com/zephyrproject-rtos/openthread/pull/9>.

Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-04-15 17:41:22 -07:00
Jonathan Hui 9e3e8e0980 [cmake] add pedantic-errors flag (#4808) 2020-04-15 15:32:26 -07:00
Jonathan Hui f9470ed187 [posix] avoid use of flexible array members in netif.cpp (#4808) 2020-04-15 15:32:26 -07:00
Jonathan Hui a4592234f8 [code-utils] avoid use of zero variadic macro arguments (#4808) 2020-04-15 15:32:26 -07:00
Jonathan Hui b669914963 [logging] avoid use of GNU extension ##__VA_ARGS__ (#4808) 2020-04-15 15:32:26 -07:00
Abtin Keshavarzian 14991d96d0 [ip6-address] methods to set address to common multicast addresses (#4832)
This commit adds methods to set an `Ip6::Address` to common multicast
addresses, link-local all-nodes/all-routers, realm-local all-nodes/
all-routers, or realm-local all MPL forwarders. The implementation
uses the constant addresses defined in `Netif` class.
2020-04-15 10:24:34 -07:00
Abtin Keshavarzian 7baefe62ed [network-data] define and use a common Iterate method for all entry types (#4830)
This commit adds a common private `Iterate()` method which is used by
other methods iterating over different types of entries:
`GetNextOnMeshPrefix()`, `GetNextExternalRoute()`, `GetNextService()`,
and `GetNextServer()`. It also adds methods to help advancing the
iterator to next TLV or sub-TLV or entry index.
2020-04-15 10:22:10 -07:00
Abtin Keshavarzian fc848485e0 [toranj] add test-case verifying Network Data update (#4817)
This commit adds a new test-case to `toranj` which verifies Network
Data update and version changes (stable only vs. full version).

The test creates a simple network of a leader with 3 children where
one of the children is SED and is configured to request only stable
Network Data. The test covers the following:
- Adding/removing prefixes (stable or temporary) on the first child.
- Verifying that Network Data is updated on all nodes accordingly.
- Ensuring correct update to Network Data version and stable version.

The above steps are then repeated over many different situations:
- Where the same prefixes are also added by other nodes.
- Or the same prefixes are added as off-mesh routes by other nodes.
2020-04-15 10:19:42 -07:00
Abtin Keshavarzian 4c7ec29e6d [network-data] enhance/simplify updating of network data on leader (#4817)
This commit changes the model for updating Network Data on a leader.

It adds `ChangedFlags` type which is used to track whether full or
stable version of Network Data gets changed as TLVs/sub-TLVs are being
added or removed. This is then used to update version and stable
version accordingly.

When registering new received Network Data on the leader, the new
model updates the Network Data in place. First, newly added
`Validate()` method is called to verify that the received Network Data
contains well-formed TLVs and sub-TLVs (e.g., no duplicate
Prefix/Service TLVs) and all sub-TLVs/entries match the sender's
RLOC16. Then, all entries in the current Network Data associated with
the sender's RLOC16 which are not present in the newly received data
are removed. Afterwards, any new entry in the received Network Data is
added. This approach helps simplify the code and ensures existing
TLVs/sub-TLVs remain as before (e.g., no need to keep a copy of
previous data to ensure same Service IDs are used when adding/removing
Service TLVs).

This commit also adds `UpdatePrefix()` and `UpdateService()` methods
which ensure a Prefix or Service TLV is marked correctly as stable or
not depending on its sub-TLVs (e.g., if all stable sub-TLVs are
removed the enclosing TLV is marked as not stable).
2020-04-15 10:19:42 -07:00
Rongli Sun bfef9c6a03 [logging] add bbr region (#4819) 2020-04-14 23:54:57 -07:00
Rongli Sun b37528645a [bbr] (Un)Subscribe AllDomainBBRs multicast address (#4795)
This commit includes:
- cache domain prefix in the Thread Network
- subscribe/unsubscribe AllDomainBBRs Multicast address
- update test to cover AllNetworkBBRs and AllDomainBBRs subscription
2020-04-14 19:36:14 -07:00
Jing Ma 911010a9bf [cmake] add support for kw41z (#4692) 2020-04-14 18:14:36 -07:00
Rongli Sun c2930f841f [meshcop] avoid unnecessary RemoveUnsecurePort (#4821) 2020-04-14 16:56:54 -07:00
Abtin Keshavarzian 9c45b68759 [qpg6095] fix license header typo in settings.cpp (#4831) 2020-04-14 13:16:16 -07:00
Rongli Sun 854a2309bd [domain] add domain name (#4815) 2020-04-14 09:08:42 -07:00
Jiacheng Guo c024fac54c [ip6] fix remove unsecure port behavior (#4822)
When removing unsecure port, we should not add aFromNcpHost filter since
the packet comes from the child.
2020-04-14 08:58:15 -07:00
Rongli Sun 06cc9bce51 [notifier] add string for flags newly introduced (#4820)
- OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE
- OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL
- OT_CHANGED_JOINER_STATE
2020-04-13 22:19:00 -07:00
Simon Lin 0aa880e73c [address-resolver] use RLOC dest when send a/ae to child (#4811) 2020-04-12 23:01:21 -07:00
Yakun Xu 0cd682f048 [logging] dynamic level enhancements (#4809)
* Add cli command to get/set log level
* Add cmake option to enable dynamic log level
* Aggregate logfilename as sub-command of `log` command
* Add log level test
* Update readme
2020-04-11 22:11:38 -07:00
Rongli Sun 52777fb459 [bbr] support domain prefix addition and removal (#4793) 2020-04-11 22:05:04 -07:00
Jiacheng Guo a47ea011b1 [ip6] disable security for link-local packets from unsecure ports (#4782)
If this feature is enabled, OpenThread will automatically disable
link-level security for packets sent with unsecure source ports. Once
a secure packet is received on the unsecure port, this port will be
removed from the unsecure port list.
2020-04-10 12:26:53 -07:00
Abtin Keshavarzian 03f4a4317e [network-data] simplify ServiceTlv (#4806)
This commit updates the `ServiceTlv` implementation and its use.

- Set the `ServiceTlv` fields through a new `Init()`
- Use union for managing presence of Enterprise Number fields
- Add static helper `GetSize()` to get the size of a Service TLV
  with a given Enterprise number and Service Data length.
- Add `ServiceTlv::kThreadEnterpriseNumber` constant replacing the
  `THREAD_ENTERPRISE_NUMBER` definition.
2020-04-10 12:23:38 -07:00
Duda, Lukasz 2f618bd4a7 [joiner] align error logs with other modules (#4788) 2020-04-09 15:01:58 -07:00
Duda, Lukasz 881c7eb784 [border-agent] remove the OT_CHANGED_BORDER_AGENT_STATE enumeration (#4788) 2020-04-09 15:01:58 -07:00
Duda, Lukasz 58e771cbad [commissioner] ensure synchronization with Border Agent (#4788)
This commit fixes situation when Commissioner can't be turned on or off,
due to incorrect state of the Border Agent.

In order to fix it:
 - a new COMMISSIONER state in the notifier module has been introduced
 - Border Agent API is not colled from the commissioner_api.cpp file
2020-04-09 15:01:58 -07:00
Duda, Lukasz 92796224b8 [border-agent] use Notifier to update the state (#4788) 2020-04-09 15:01:58 -07:00
Jing Ma a6adf0322a [cmake] add support for cc2652 (#4691) 2020-04-09 13:11:13 -07:00
Jonathan Hui fe736641b2 [icmp] do not generate errors in response to errors (#4800) 2020-04-09 09:52:47 -07:00
Jonathan Hui adc62ecfe5 [icmp] pass full error-causing message when sending error (#4800) 2020-04-09 09:52:47 -07:00
Jonathan Hui 1f3e4552d6 [mesh-forwarder] move frame-to-message conversion to separate method (#4800) 2020-04-09 09:52:47 -07:00
Jonathan Hui 130e5b6a88 [mesh-forwarder] move ICMPv6 Dst Unreach call to mesh-forwarder (#4800) 2020-04-09 09:52:47 -07:00
Abtin Keshavarzian 737f7e349d [network-data] adopt const for methods, parameters, and local vars (#4802)
This commit declares methods, input parameters, and local variables as
`const` whenever possible in `NetworkData` modules. `const` versions
of methods (returning `const` pointer) are also added, e.g.,
`NetworkDataTlv::GetNext()`, `HasRouteTlv::GetFirstEntry()`,
`NetworkData::FindTlv()`, etc. For simpler (inline) methods, the
`const` version is directly implemented but for more complex methods,
the const version is the main implementation (defined in `cpp` file)
and non-`const` version is implemented using `const_cast` conversions
from the `const` method.

This commit also declares methods not using any member variable/info
as 'static' (e.g. `FindHasRoute()` or `FindContext()`). It also
declares `RemoveTemporaryData()` flavors removing internal sub-TLVs as
`private` (instead of `protected`) and fixes the logging in
`RemoveTemporaryData()` using input `aTlvs` now instead of `mTlvs`.
2020-04-09 08:26:04 -07:00
Jonathan Hui e16fca40c9 [mbedtls] leverage cmake provided by mbedtls (#4803) 2020-04-09 08:21:31 -07:00
Piotr Koziar dc21576f58 [network-data-notifier] fix flag for child removed notification (#4805) 2020-04-09 08:21:05 -07:00
Jing Ma 8d5fc20eda [harness-automation] fix case selection issue when using Chrome 80 (#4648)
elem.txt might be null when the required reference devices could not
be met (either due to the quantity or the type) for specific test.
perform() will throw exceptions if elem.text is null since Chrome and
chromedriver 80. If elem is not shown in current case list window,
move_to_element() will not work either.
2020-04-08 11:34:41 -07:00
Abtin Keshavarzian 91111c6237 [mle] add DeviceRole type, and IsChild, IsRouter, etc method (#4794)
This commit defines a new enum type `Mle::DeviceRole` mirroring the
public `otDeviceRole` enumeration. The enumerator in the new type
follow `kRole{Value}` style and intended for use in the core modules.
It also adds helper method in `Mle`, `IsChild()`, `IsRouter()`,
`IsLeader()`, etc to check the current device role.
2020-04-06 23:56:31 -07:00
Jiacheng Guo c265aebe9e [android] export CFLAGS and include directories (#4797)
This allows libraries depending on ot-core not to specify OpenThread
path and share the OpenThread configs.
2020-04-06 22:58:04 -07:00
Abtin Keshavarzian 79831b1443 [network-data] use GetLocator() when registering network data (#4798) 2020-04-06 21:28:33 -07:00
Jonathan Hui c64d296c94 [network-data] implement network data notifier (#4783)
This commit centralizes the timing logic for transmitting SVR_DATA.ntf
messages that are used to update network data at the leader.

This component helps ensure the following:

- At most one SVR_DATA.ntf message is outstanding at any given time.

- A timer to rety sending SVR_DATA.ntf messages if sending fails due
  to lack of memory buffers.

- A timer to rate limit SVR_DATA.ntf messages that are acknowledged
  but no corresponding change in the Thread Network Data was observed.

- Utilizes ot::Notifier to trigger logic on role, child state, and
  network data changes.
2020-04-06 21:27:51 -07:00
Jonathan Hui c6a258e3a5 [github-actions] include fuzz checks (#4792) 2020-04-04 14:39:59 -07:00
Abtin Keshavarzian 1e4f641115 [toranj] update test-039 to stagger initial address queries (#4791)
This commit changes the `test-039` to add delay between the initial
message tx to stagger the address query send times. This helps verify
the query timeout behavior.
2020-04-04 14:39:37 -07:00
Jonathan Hui 335305101f [coap] avoid div-by-0 error invalidating coap params (#4787) 2020-04-04 13:22:55 -07:00
Piotr Koziar d62e550ffa [nrf528xx] add defines needed for compilation with IAR in nrf_security (#4790) 2020-04-04 13:22:32 -07:00
Abtin Keshavarzian f9ce416f62 [address-resolver] ensure prev pointer stays valid on entry removal (#4789)
This commit simplifies the model for iterating through a linked
list by using a `prev` pointer as the iterator variable. This helps
fix an issue with the `prev` pointer not staying  valid when entry
is removed from the list during iteration.
2020-04-04 13:15:24 -07:00
Abtin Keshavarzian 6f95f43b6f [network-data] simplify code, user helper methods (#4780)
This commit contains the following changes in `NetworkData::Leader`:

- Simplify methods (`RemoveContext()`, `UpdateContextsAfterReset(),
 `FindServiceById()`, `RemoveRloc()`, etc) to use `FindTlv` when
  searching for TLVs of a given type.
- Removes redundant checks in `RlocLookup()`.
- Uses pointer to iterate through `BoderRouterTlv` or `HasRouteTlv`
  entries.
- Move simple getter/setter methods to header file (to be inline).
- Move variable decelerations into inner scopes when possible.
2020-04-03 23:15:58 -07:00
Jonathan Hui 159dc8877c [mesh-forwarder] fix bug in evicting from address resolver queue (#4786)
The existing MeshForwarder::RemoveMessage() implementation is specific
to evicting messages from mSendQueue. This commit generalizes the
method by retrieving the queue from the message itself.
2020-04-03 13:35:48 -07:00
Jonathan Hui f59641e484 [jn5189] remove unused files 2020-04-03 08:20:37 -07:00
Piotr Koziar dd02c9faa4 [nrf528xx] update nrf security (#4773)
- enabled new functionalities in nrf_security module
- updated mbedtls config file for nrf52833 and nrf52840
2020-04-03 07:59:58 -07:00
Abtin Keshavarzian 74ff650cf1 [network-data] add IncrementVersionAndStableVersion() (#4781)
This commit replaces `IncrementStableVersion()` with a new method
`IncrementVersionAndStableVersion()` which increments both version and
stable version. It helps simplify its use by other modules and also
ensures stable version is not updated without version. This commit
also adds a common private `IncrementVersions()` used by other methods
in `NetworkData::Leader`.
2020-04-03 07:32:25 -07:00
Yakun Xu 03aba30cd5 [meshcop] generate PSKc from passphrase (#4766) 2020-04-03 07:17:02 -07:00
Rongli Sun 787d6d3763 [core] use the common RouterIdSet class (#4756)
Currently there are four similar copies regarding Router Id set
separately in 1) RouteTlv in mle_tlvs.hpp; 2) ThreadRouterMaskTlv in
thread_tlvs.hpp; 3) RouterIdSet in router_table.hpp; 4) RouteTlv in
network_diagnostic_tlvs.hpp.

This commit extracts the common RouterIdSet class and apply it in the
four components, meanwhile keep one copy for RouteTlv and
ThreadRouterMaskTlv process in route_table.
2020-04-02 17:16:54 -07:00
Jonathan Hui 5902ce9222 [network-data] periodically check for stale child ids (#4779)
A parent is responsible for removing stale child entries from the
network data. The existing implementation only triggered a
SVR_DATA.ntf message when new network data is received. In some cases,
the SVR_DATA.ntf message may not be sent due to rate limiting or lack
of message buffers.

This commit turns this process into a periodic check to ensure that
stale child entires are removed even if a failure in sending the
SVR_DATA.ntf occurs.
2020-04-02 09:41:16 -07:00
Jonathan Hui 00f8567e88 [mesh-forwarder] include address resolving queue in message eviction (#4776)
The existing implementation only considered the forwarding queue when
looking for a message to evict. This ignores message buffers that may
be buffered in other message queues.

This commit adds the ability to evict messages in the address resolver
queue. The lowest priority message from either the forwarding or
address resolver queue is selected for eviction.
2020-04-02 08:35:16 -07:00
garyButt 5ef14ccc9c [efr32] add nvm3 support (#4521)
silabs nvm3 support is selected by setting following macro in
    openthread-core-efr32-config.h :-
    #define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 0
2020-04-02 08:33:33 -07:00
Jing Ma 64e03b8347 [cmake] add support for cc1352 (#4690) 2020-04-01 23:53:34 -07:00
Abtin Keshavarzian 602d975596 [toranj] add new test-case for cache table snoop (#4600) 2020-04-01 18:15:29 -07:00
Yakun Xu bac6d8c85d [mac] remove disable CSMA-CA on the last transmit (#4765) 2020-04-01 18:09:22 -07:00
Abtin Keshavarzian ff5a3e0737 [toranj] update test-602-channel-select to add extra wait (#4777)
This commit changes the `test-602-channel-manager-channel-select` to
wait for sample count to reach a limit (within a wait interval). This
should help make the test more robust (e.g., in RCP/POSIX mode) when
the simulation processing time may require more time (note that this
test is run with very high speed-up).
2020-04-01 12:19:41 -07:00
Thomas 7fd9902c38 [gp712] align with the new otPlatFlash API (#4774) 2020-04-01 10:24:24 -07:00
Abtin Keshavarzian 3579a68b93 [network-data] fix FindTlv() to return NULL when TLV sequence is malformed (#4771) 2020-04-01 10:23:11 -07:00
Simon Lin 8423ed3042 [simulation] enhance simulation for OTNS (#4268)
This commit is to support OTNS by:
- raising the max number of simulating nodes to 999 if OTNS=1
- implementing the status-push mechanism

To build:

$ make -f examples/Makefile-simulation OTNS=1

This commit should have no change of OpenThread behaviors on platforms
except simulation.
2020-04-01 10:19:36 -07:00
Jonathan Hui daa626b504 [github-actions] add apt update to each build (#4772) 2020-03-31 23:09:08 -07:00
Abtin Keshavarzian bb86ae4c76 [toranj] remove unused age property when parsing cache table (#4599) 2020-03-31 12:11:24 -07:00
Abtin Keshavarzian ee0dc4f9bb [spinel/ncp] update address cache table property to include additional info (#4599)
This commit expands the `SPINEL_PROP_THREAD_ADDRESS_CACHE_TABLE`
property format to include more info about address cache table. This
change keeps the definition backward compatible by not changing
existing format and only adding new (optional) fields.
2020-03-31 12:11:24 -07:00
Abtin Keshavarzian 451a72f750 [address-resolver] update public OT API for getting cache table (#4599)
This commit updates the public OpenThread APIs to get the address
cache table. The new APIs allows to iterate through all entries
(including in query or retry mode) and provides more info about the
entries, e.g., current timeout, retry delay (if entry is in
query/retry state), or the mesh-local EID, last transaction time (if
entry is in cached state).
2020-03-31 12:11:24 -07:00
Abtin Keshavarzian ee4bc9cb12 [address-resolver] update how the cache table changes are logged (#4599)
This commit adds a new helper method `LogCacheEntryChange()` which
logs any change (entry added/removed/updated) and its reason in
address cache table.
2020-03-31 12:11:24 -07:00
Abtin Keshavarzian 17617a2ee4 [address-resolver] use linked-list and enable snooped entry timeout (#4599)
This commit contains multiple enhancements in `AddressResolver`:

Cache entries are stored in different lists: Cached list (entries in
use), query list (entries actively querying and waiting for address
notification response), query-retry list (entries in delay wait mode
due to prior query failing to get a response), and snooped list
(entries discovered through received message inspection aka snoop
optimization). Singly linked list is used which helps keep the entries
sorted based on the order of use (whenever a cache entry is used to
resolve an address, it is moved to the head of the list). This
replaces and simplifies the aging model.

This commit updates the cache entry class definition to use `union`
for member variables (like timeout or transaction time) that are tied
to entry being in different lists. This help reduce the memory
requirement for cache table.

This commit also adds a new mechanism to manage snooped entries. When
a new snooped entry is added, we do not allow it to be evicted for a
short timeout. This allows some delay for a response message to use
the entry (if entry is used it will be moved to the cached list). If a
snooped entry is not used after the timeout, we allow it to be
evicted. To ensure snooped entries do not overwrite other cached
entries, we limit the number of snooped entries that are in timeout
mode and cannot be evicted by a (build-time configurable) threshold.
2020-03-31 12:11:24 -07:00
Abtin Keshavarzian 8a5f538e6f [linked-list] change PopAfter() parameter to be a pointer (#4599)
This commit changes `LinkedList::PopAfter()` method to accept a
pointer to a previous entry as a parameter. If the previous entry
pointer is NULL the entry at the head of the list is popped.
2020-03-31 12:11:24 -07:00
Jonathan Hui 3560ed06f7 [docs] add lgtm.com status badge (#4762) 2020-03-31 08:01:32 -07:00
Rongli Sun 999b29dcc2 [ip6-address] add SetMulticastNetworkPrefix() for Prefix-Based Multicast Address (#4757)
This commit also replaces the relevant magic numbers with the
constants `MeshLocalPrefix::kLength` and `MeshLocalPrefix::kSize`
2020-03-31 08:01:17 -07:00
Jiacheng Guo 4597d5e03f [posix] fix mld process invalid arguments (#4764) 2020-03-31 07:59:54 -07:00
Rongli Sun 77ea86302e [cli] add childip max command (#4759)
Thread 1.2 test harness requires the ability to set the number of IP
address the parent could store per child to test the reaction of the
Child DUT. The value intentionally may not conform to the Conformance
Specification. Since it is only used for reference device, this commit
wraps relevant APIs in the OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
macro.
2020-03-31 07:58:51 -07:00
Piotr Koziar d85c0007a1 [network-diagnostic] replace anonymous structs in netdiag.h (#4760) 2020-03-30 19:01:59 -07:00
Jiacheng Guo e2be5c475c [posix] add support for multicast group join (#4687)
Listen for mld reports sent by kernel to capture user multicast group
join and forward the addresses to OpenThread interface.

See openthread/wpantund#444 for more background.
2020-03-30 14:14:55 -07:00
Abtin Keshavarzian 8328aff1d9 [toranj] change start.sh to remove variable check to retry failed test (#4761)
This commit changes the `start.sh` script to remove the check for the
environment variable (which is specific to travis) before allowing
retry of failed tests. This should help with robustness of the tests
on GitHub Actions.
2020-03-30 13:32:39 -07:00
Abtin Keshavarzian eb5b3a41a9 [network-data] adding helper methods, simplify code (#4743)
This commit contains the following changes in `NetworkData` modules:

- Add helper `FindTlv()` and template version `FindTlv<TlvType>()` 
  methods to search within a sequence of TLVs to find a TLV with a 
  given type (and/or stable  status).
- Add methods to help with iterating over Network Data content 
  (`FindTlv`, `IterateToNextTlv()`, etc).
- Add `AppendTlv()` and `RemoveTlv()` helper methods to simplify 
  adding and removing of entire TLV from Network Data.
- Change `PrefixMatch()` to use `Ip6::Address` method.
- Simplify and fix `RemoveTemporaryData()` (use cast to get the 
  sub-TLV during iteration).
- Simplify `GetNextServer()` implementation to use other methods to 
  iterate over all on-mesh prefix, external route, and service 
  entries in Network Data. 
- Simplify the `Local::UpdateRloc()` implementation.  
- Add `Local::AddPrefix()` and `Local::RemovePrefix()` methods to 
  share common code for adding on-mesh or external route entries.
- Add helper `GetTlvsStart()`/`GetTlvsEnd()` to get the start/end 
  of Network Data TLV sequence.
2020-03-30 12:21:20 -07:00
Jonathan Hui f8de062657 [mesh-forwarder] do not remove router on link failures (#4753)
A router coming out of reset sends a Link Request to re-establish its
router role and links to neighboring routers. The existing
implementation only responds to such Link Requests when a valid
neighbor entry is found. This check is too strict and can cause
partitions to remain for a couple minutes. The Thread Specification
only requires a router to check that the Router ID is currently
allocated.

This commit updates the implementation to be conformant with the
Thread Specification and allows routers coming out of reset to
resynchronize even when a neighboring router has detect a link
failure.
2020-03-30 11:47:37 -07:00
Piotr Koziar ec9968e1d1 [meshcop] rename leader.cpp to meshcop_leader.cpp (#4754) 2020-03-30 09:14:16 -07:00
Rongli Sun 132df25505 [bbr] (Un)Subscribe AllNetworkBBRs Multicast address (#4755) 2020-03-29 23:13:43 -07:00
Rongli Sun 3535176535 [core] remove useless code for the old mLinkLocal16 (removed in #913) (#4750) 2020-03-28 09:07:19 -07:00
Jonathan Hui ba19a298a1 [script] add build option to check-posix-pty (#4748) 2020-03-27 23:16:51 -07:00
Jonathan Hui 5790e31ea4 [docs] add GitHub Action status badges (#4747) 2020-03-27 16:21:34 -07:00
Jonathan Hui dc0ae98927 [github-actions] migrate more checks from Travis (#4746)
- gn-build
- distcheck
- posix-spi
- posix-ncp-rcp migrate
- time sync
2020-03-27 14:32:59 -07:00
Piotr Koziar e4dd1da67d [nrf528xx] fix Keil compilation error in nrf_ficr.h (#4744) 2020-03-27 08:57:03 -07:00
Jonathan Hui d7fcb38386 [travis] disable simulation checks that exist in GitHub actions (#4737) 2020-03-26 21:32:26 -07:00
Jonathan Hui 275c38a5d2 [meshcop] reduce maximum number types in MGMT_GET.req (#4740) 2020-03-26 21:32:16 -07:00
Jonathan Hui bd5549b1bb [lowpan] avoid comparison of narrow type with wide type in loop (#4739) 2020-03-26 21:32:06 -07:00
Łukasz Duda f58319f82a [nrf528xx] align flash driver to the new otPlatFlash* API (#4742) 2020-03-26 15:29:22 -07:00
kangping e28608cd0b [network-diagnostic] improve usability of Network Diagnostic API (#4619)
This commit improves usability of Network Diagnostic API by:

- Define native structures to represent various Network Diagnostic TLV
  values.

- Add facility function otThreadGetNextDiagnosticTlv to parse plain
  otMessage into structured data.

- Dump parsed DIAG_GET.ans/.rsp message in readable format for
  networkdiagnostic CLI command.
2020-03-26 13:43:40 -07:00
Rongli Sun 315a27bf08 [bbr] add backbone router service (#4430)
- Introduce BACKBONE_ROUTER option for Backbone Router function.
- Implement Backbone Router service registration.
  - Add basic Backbone Router service.
  - Primary Backbone Router restores its Dataset when reattached after
    short reset, increases sequence number and re-register to Leader.
  - Add configurable jitter for Backbone Router service registration.
- Add Backbone Router service test.
2020-03-26 08:54:23 -07:00
Yakun Xu 6606f2befe [posix] rename namespace to posix (#4736)
This commit simply renames namespace of PosixApp to Posix.
2020-03-25 23:19:27 -07:00
Abtin Keshavarzian 234c263be0 [posix] move core config options from cmake file to the header file (#4713)
This commit moves the OpenThread core config definitions (like
`OPENTHREAD_CONFIG_LOG_OUTPUT`) from the `CMakeLists.txt` file into
the `openthread-core-posix-config.h`. This help allow a project/user
specific config header file to override the default config definition
(e.g., toranj config for posix).
2020-03-25 22:38:51 -07:00
Jonathan Hui c15664bccd [github-actions] add simulation checks (#4735) 2020-03-25 19:52:22 -07:00
Jonathan Hui 2de22eb079 [travis] disable build checks that exist in GitHub actions (#4731) 2020-03-25 19:29:31 -07:00
Diego Ismirlian b64d148b97 [flash] improve power failure robustness (#4717)
This commit improves the flash implementation robustness to power
failure. The idea is the following:

The Init method now checks if a record has been partially written by
seeing if the kFlagAddBegin flag is set, but the kFlagComplete flag is
not. In this case, Init stops incrementing mSwapUsed. The new
SanitizeFreeSpace method checks the (supposedly) free space, to see if
it is writeable. If it isn't, it triggers a Swap, which sanitizes the
flash area.
2020-03-25 17:18:21 -07:00
Simon Lin 2ef2fb1717 [meshcop] fix commissioner's invalid call to SetState (#4494)
Commissioner should not call SetState(OT_COMMISSIONER_STATE_DISABLED)
directly, rather it should call Stop() so that joiners and resources
are cleaned up.

This commit:

- Fixes the above issue.

- Adds argument name /* aResign */ to Stop() calls.

- Ignores petition/keep-alive response if commissioner is not in
  PETITION/ACTIVE state.

- Calls CoapSecure::Stop when Start fails (suggested by @bukepo).

- Responds to Leader Petition Response (accept) by sending
  KeepAlive(reject) if commissioner is in disabled state.
2020-03-25 14:42:44 -07:00
Jonathan Hui db22529c27 [mle] combine FTD/MTD header files into one (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui 365ea0d2a8 [mac] remove rx-only neighbors from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui 9c69ad077d [network-diagnostic] remove Max Child Timeout TLV from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui 543dba995c [network-diagnostic] remove Connectivity TLV from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui 1850152029 [ip6] remove IPv6 multicast forwarding to sleepys from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui d44f75112a [child-table] remove from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui fbd27e3cb5 [src-match-controller] remove from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui d00f9f7228 [router-table] remove from MTD build (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui efa085e43f [mle] avoid unnecessary method calls on MTD (#4730) 2020-03-25 07:54:57 -07:00
Jonathan Hui 4cb09ec637 [continuous-integration] initial migration to GitHub actions (#4728) 2020-03-24 20:45:19 -07:00
Jonathan Hui 35bb0027d0 [network-data] avoid comparison of narrow type with wide type in loop (#4724) 2020-03-24 11:09:20 -07:00
Jonathan Hui c136ac2029 [coap] avoid comparison of narrow type with wide type in loop (#4724) 2020-03-24 11:09:20 -07:00
Jonathan Hui 2b11826fbe [lowpan] do not try to compress large extension headers (#4724) 2020-03-24 11:09:20 -07:00
Yakun Xu cb55c530bd [cmake] clean up cmake options (#4727)
* enable optional features
* remove OT_NCP
* remove OT_NCP_RADIO_ONLY
* sort options
2020-03-24 07:29:48 -07:00
Jonathan Hui 322359fd88 [lowpan] avoid backward goto statement in Compress() (#4725) 2020-03-24 07:25:53 -07:00
Jiacheng Guo c03edff16b [posix] add platformNetifDeinit (#4726)
Close netif file descriptors to re-open after reset.
2020-03-23 23:28:54 -07:00
Jonathan Hui c87665f0d5 [mesh-forwarder] avoid unnecessary comparisons on ALOC (#4723) 2020-03-23 21:00:40 -07:00
Jonathan Hui 72a2725ecd [meshcop] add explicit length check in MGMT_GET.req (#4721) 2020-03-23 21:00:20 -07:00
Jonathan Hui 756824b5fa [mpl] make MplSeedEntry private to Mpl (#4715) 2020-03-23 20:59:41 -07:00
Jonathan Hui 2738b05af7 [mpl] make MplBufferedMessageMetadata private to Mpl (#4715) 2020-03-23 20:59:41 -07:00
Jonathan Hui 6c365287e7 [mpl] remove retransmission logic from MTD build (#4715) 2020-03-23 20:59:41 -07:00
Jonathan Hui 8eeb1e83eb [cli] change aArgsLength type from int to uint8_t (#4718) 2020-03-23 00:12:09 -07:00
Jonathan Hui a6a93d688d [cli] change 'argc' -> 'aArgsLength', 'argv' -> 'aArgs' (#4718) 2020-03-23 00:12:09 -07:00
Jonathan Hui ecf90d281e [network-data] use explicit signed int for bit field (#4720) 2020-03-23 00:10:31 -07:00
Jonathan Hui 2f63f74693 [thci] remove unused assignments (#4719) 2020-03-23 00:09:13 -07:00
Jiacheng Guo 5a82d90e4d [netif] enhance return value of adding external addresses (#4693)
This commit changes the return value of subscribing a pre-defined
address when it's already subscribed. Now returns OT_ERROR_ALREADY
instead of OT_ERROR_INVALID_ARGS.
2020-03-21 15:40:14 -07:00
Rongli Sun f60a5295fc [ip6-address] add GetLocator() and SetLocator() (#4707) 2020-03-21 10:08:16 -07:00
Piotr Koziar b403fb9f9c [nrf528xx] update README.md (#4716) 2020-03-20 15:05:37 -07:00
Jonathan Hui c6adc8ce45 [cc1352,cc26xx] include -pedantic-errors in platform code (#4714)
- Also fix a pointer arithmetic issue that was flagged.
2020-03-20 08:42:09 -07:00
Abtin Keshavarzian 91b654ba6e [travis] add build checks for cmake with toranj configs (for simul/posix platforms) (#4712) 2020-03-20 08:41:38 -07:00
Abtin Keshavarzian 61b4c5a2af [toranj] define platform specific config headers (#4712)
This commit adds platform specific config header for simulation
and posix platforms for toranj. The common configuration definition
stay in the `openthread-core-toranj-config.h` and are shared for all
platforms. The `build.sh` script is also updated to pick the correct
platform-specific config header for both cmake or autoconf builds.
2020-03-20 08:41:38 -07:00
Diego Ismirlian 8e31a6ad79 [efr32] flash: fixes for new otPlatFlash* abstraction (#4711)
- Fully erase the swap region (not only the first page in swap).

- Remove waiting loop after MSC_ErasePage. The SDK MSC functions
  already wait for the operation to finish.

- Avoid unlocking the flash before the actual write/erase
  operation. The SDK MSC functions already do the unlock/re-lock when
  needed.
2020-03-20 08:40:05 -07:00
Abtin Keshavarzian 6290f577b5 [coap-message] add Coap::MessageQueue class (#4701)
This commit adds `Coap::MessageQueue` class as a subclass of generic
`ot::MessageQueue` as a queue of `Coap::Message` only. This type is
used in `coap.cpp` helping simplify the code (by removing the type
casting).
2020-03-20 00:00:17 -07:00
Rongli Sun 736cb27d3a [script] let alias to take effect (#4708) 2020-03-19 22:24:03 -07:00
kangping 133ec09b80 [cli] return OT_ERROR_INVALID_ARGS for invalid arguments (#4639)
- Remove argument parsing failure from semantic of OT_ERROR_PARSE.

- Add OT_ERROR_INVALID_COMMAND to indicate invalid CLI command error.

- return OT_ERROR_INVALID_ARGS for invalid CLI arguments.
2020-03-19 10:51:42 -07:00
kangping db765d9370 [build] fix typo in CMake files (#4704) 2020-03-19 09:27:12 -07:00
Jonathan Hui baca06f06b [utils] remove example flash implementation (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 77a9ec594a [cc2650] enable RAM settings by default (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 26737a89a2 [samr21] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui f33b47e151 [kw41z] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui f86438e740 [efr32mg21] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui df5f08b135 [efr32mg13] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 64ac0ff38d [efr32mg12] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 2dcbd3926c [cc2652] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 46d790c442 [cc1352] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 7d323b30bf [nrf528xx] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui d52b3a3032 [cc2538] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 8921feff4c [posix] implement otPlatFlash APIs (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 8220981b6e [flash] integrate flash driver with build option (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui b3d05af6ff [flash] implement flash storage driver for settings (#4552) 2020-03-18 20:51:41 -07:00
Jonathan Hui 4ee8010558 [script] update make-pretty to bash (#4698)
- Also update CONTRIBUTING.md and STYLE_GUIDE.md.
2020-03-18 19:04:10 -07:00
Piotr Koziar ccf4eb9a51 [nrf528xx] fix IAR undefined order of volatile accesses error (#4702)
Fixes IAR compiler warning: "warning[Pa082]: undefined behavior: the
order of volatile accesses is undefined in this statement"
2020-03-18 19:03:50 -07:00
Abtin Keshavarzian 7456be9e80 [coap] use Coap::Message helper methods checking CoAP type (#4700)
This commit change code to use `IsConfirmable()`,
`IsNonConfirmable()`, `IsAck()` helper methods.
2020-03-18 12:18:09 -07:00
Piotr Koziar ab9c0a4091 [nrf528xx] move transport config to a separate file (#4695) 2020-03-17 16:11:39 -07:00
Piotr Koziar a144ff653e [nrf528xx] changed deprecated flash write call (#4699) 2020-03-17 15:47:06 -07:00
Rafał Kuźnia 661d2b4f5f [mac] add capability to transition from Sleep to Transmit during data request (#4697) 2020-03-17 13:02:15 -07:00
Jiacheng Guo cecf203388 [nrf528xx] add volatile mark to nrf uart read/write buffers (#4652)
These buffers are touched in volatile and should be marked as volatile.
2020-03-17 10:06:30 -07:00
Robert Lubos 0c34c42043 [cmake] fix build with external mbedTLS (#4696)
`mbedcrypto` target is only available when `OT_BUILTIN_MBEDTLS` is set,
therefore linking it unconditionally when external mbed TLS instance is
used results in a linking error.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2020-03-17 10:03:06 -07:00
Abtin Keshavarzian bf1cf97b0f [coap] ensure correct dequeue time for entries in response queue (#4686)
This commit changes the handling of timer for CoAP response queue to
ensure that correct dequeue time is used. The existing code assumed
that entries in the queue would be in order of their dequeue time (due
to exchange lifetime being fixed). With the addition of configurable
CoAP tx parameters feature, this is no longer valid. This commit
changes the code to restart the timer with the earliest dequeue time.
Also when evicting a message from the queue (due to the number of
entries reaching the max limit of `kMaxCachedResponses`) we now search
and find the message with earliest dequeue time to remove (instead of
removing the entry at the head of queue).
2020-03-16 09:08:43 -07:00
Abtin Keshavarzian 1d463868d9 [coap] directly initalize metadata before appending to message (#4686) 2020-03-16 09:08:43 -07:00
Jonathan Hui 6a277399e1 [dhcp6] use Ip6::Address::SetPrefix() (#4685) 2020-03-16 08:56:17 -07:00
Abtin Keshavarzian 2bb72299d3 [mle] define ResponseHeaderMetadata as inner type of Mle class (#4683)
This commit also simplifies `Header` class methods and moves its `enum`
definitions to the top of class.
2020-03-14 09:26:03 -07:00
kangping a495dea4ac [tests] initialize _initialized (#4662)
This commit initializes _initialized of Node before doing
initialization. Otherwise, we will have an AttributeError in
desctructor when initialization fails.
2020-03-13 22:16:32 -07:00
Abtin Keshavarzian ab81a256e4 [mle-types] add MeshLocalPrefix class (#4679) 2020-03-13 22:06:04 -07:00
Abtin Keshavarzian 052047a15f [mle] adding LeaderData class (#4679)
This commit adds `LeaderData` (subclass of `otLeaderData`) to store
the info from Leader Data TLV. It also adds `ReadLeaderData()` to
read Leader Data TLV from a message.
2020-03-13 22:06:04 -07:00
Abtin Keshavarzian 54e884569b [mle-types] adding new files mle_types.hpp/cpp (#4679)
The newly added `mle_types.hpp/cpp` files include MLE specific types
(e.g. `DeviceMode`) and constants.
2020-03-13 22:06:04 -07:00
Abtin Keshavarzian 9e1020c52f [meshcop-tlvs] remove "using ot::Encoding::Reverse32" (#4682) 2020-03-13 22:00:58 -07:00
doru91 63c4dbbc2b [examples] add NXP JN5189 platform (#4642)
This commit contains all the new files required by the JN5189 platform as well as
the implementation of the platform files required by OpenThread.

Signed-off-by: Doru Gucea <doru-cristian.gucea@nxp.com>
2020-03-13 12:03:18 -07:00
Abtin Keshavarzian 9a7d831cb1 [ip6-address] adding SetPrefix() to set the IPv6 address prefix (#4677)
This commit adds a new method `SetPrefix()` in `Ip6::Address` class to
 allow the prefix in an IPv6 address to be updated. Unit test
`test_ip6_address` is updated to verify behavior of new method. The
`Mle` and `Lowpan` classes are updated to use the new `SetPrefix()`
method.
2020-03-13 08:07:07 -07:00
Piotr Koziar 3884f05739 [nrf528xx] separate transport from platform (#4673)
Transport-related functions for nrf528xx platform are moved to separated library.
2020-03-13 07:39:20 -07:00
Abtin Keshavarzian e56621118f [network-data] fix/update comments on prefix length being in bits (#4678) 2020-03-12 21:21:05 -07:00
Li Cao 3b15b67886 [tests] fix logic error in net_crypto.py (#4675) 2020-03-12 08:41:50 -07:00
Abtin Keshavarzian dc2f9edcb7 [key-manager] add Kek class (#4674)
This commit adds a class `Kek` to store Key Encryption Key
2020-03-12 08:41:00 -07:00
Yakun Xu 08c7113336 [test] build with cmake instead of automake (#4653)
- Use cmake to build.
- Use rcp instead of transceiver simplicity.
- Add virtual time options for cmake.
- Enable readline support for posix apps.
- Use ninja instead of make.
2020-03-12 08:40:23 -07:00
Abtin Keshavarzian 5903117da5 [debug] adding OT_ASSERT() macro (#4665)
This commit adds a new OpenThread specific `OT_ASSERT()` macro along
with a new config OPENTHREAD_CONFIG_ASSERT_ENABLE option which allows
the assert to be enabled or disabled. This allows a release build to
consider disabling the assert reducing code size. This commit also
adds a new travis (simulation platform) build with asserts disabled.
2020-03-11 17:30:41 -07:00
Abtin Keshavarzian 587cb7fb30 [mle] use operator when comparing Extended PAN IDs (#4669) 2020-03-11 15:03:41 -07:00
Jonathan Hui c77342e5cc [energy-scan] avoid buffer overrun when receiving energy results (#4672) 2020-03-11 11:52:36 -07:00
Jonathan Hui 3530fc5907 [fuzz] implement radio state transitions (#4671) 2020-03-11 11:43:43 -07:00
Jonathan Hui 415c42da57 [coap] avoid div-by-0 error in validating coap params (#4670) 2020-03-11 11:43:28 -07:00
Yakun Xu 653745911f [build] rename posix-app to posix (#4661) 2020-03-11 11:42:30 -07:00
Yakun Xu 34b83ae6c5 [script] simplify pretty (#4660)
* No need to bootstrap and configure for make pretty
* Use parallel to speed up make pretty
2020-03-10 22:15:07 -07:00
Abtin Keshavarzian e81562f182 [joiner-router] prepare Joiner Entrust msg after the delay (#4657)
This commit simplifies the `JoinerRouter` implementation. It moves
`JoinerEntrustMetadata` as a private inner type of `JoinerRouter`. It
also changes how the tx of Joiner Entrust is delayed. Instead of
preparing the message (and appending metadata to it) and enqueuing it
to be sent later after a delay, only the metadata is saved and the
Joiner Entrust message is prepared after the delay (when it is being
sent).
2020-03-10 19:15:35 -07:00
Zhanglong Xia 27ec1a7648 [posix-host] use MultiFrameBuffer as SPI receive buffer (#4577)
This commit improves MultiFrameBuffer so that MultiFrameBuffer can
reserve a space in front of the frame. SPI interface uses
MultiFrameBuffer to store received frame directly, which avoids
copying data from receive buffer to MultiFrameBuffer.
2020-03-10 19:13:23 -07:00
Pratik Raj 2e09531745 [script] optimization debian package manager tweaks (#4656)
By default, Ubuntu or Debian based "apt" or "apt-get" system installs
recommended but not required packages.

By passing "--no-install-recommends" option, the user lets apt-get
know not to consider recommended packages as a dependency to install.

This results in smaller downloads and installation of packages.

Signed-off-by: Pratik Raj <rajpratik71@gmail.com>
2020-03-10 15:34:22 -07:00
Simon Lin b5b97ae43b [ncp] notify wpantund when RLOC changes (#4659)
* notify wpantund when RLOC changes

* change not matched flag ex to OT_CHANGED_SECURITY_POLICY
2020-03-10 08:55:25 -07:00
Abtin Keshavarzian c7bcdb9360 [toranj] make test-13-off-mesh-route more robust (#4658)
This commit changes the test to wait till network data is updated
on `r1`, `r2`, and `sed2` nodes and they all see all the added
off-mesh routes (instead of waiting for fixed 0.5 seconds).
2020-03-10 08:54:41 -07:00
Rongli Sun 5d12c6247f [cli] add preferrouterid command (#4647) 2020-03-09 18:33:55 -07:00
Abtin Keshavarzian e41fec73cb [meshcop-tlvs] simplify processing of simple MeshCoP TLVs (#4635)
This commit changes the processing of the following TLVs: PAN ID,
Extended PAN ID, PSKc, Network Master Key, Network Key Sequence, Mesh
Local Prefix, Border Agent Locator, Commissioner Session ID,
Commissioner UDP Port, State, Joiner UDP Port, Joiner IID, Joiner
Router Locator, Joiner Router KEK, Delay Timer, Count, Period, Scan
Duration, and IP6 Address.
2020-03-09 11:39:09 -07:00
Abtin Keshavarzian 39b796fa52 [thread-tlvs] simplify processing of simple Thread TLVs (#4635)
This commit changes the processing of the following TLVs: RLOC16,
Thread Status, Thread Last Transaction Time, Thread Extended MAC
Address, Thread Target, and Mesh Local EID.
2020-03-09 11:39:09 -07:00
Abtin Keshavarzian 15d5644b7d [mle-tlvs] simplify processing of simple MLE Tlvs (#4635)
This commit changes the processing of the following MLE TLVs:
SourceAddess, Mode, Timeout, LinkFrameCounter, MleFrameCounter,
Address16, LinkMargin, Status, Version, PanId, XtalAccuracy, ScanMask,
NetworkData, Challenge, Response, and TlvRequest.
2020-03-09 11:39:09 -07:00
Abtin Keshavarzian 19ed02842c [tlv] add helper read/append methods for TLVs with simple types (#4635)
This commit adds helper static methods in `Tlv` class to directly read
the value of simple TLVs from a `Message`, or append a simple TLV to a
message. The simple TLVs are the ones with single unsigned integer
value (e.g., MLE Frame Counter TLV, MeshCop Scan Duration TLV, etc),
or a value that can be treated as an array of bytes (e.g., MeshCop
PSKc TLV, etc).
2020-03-09 11:39:09 -07:00
kangping c54238fdd6 [network-diagnostic] fix sed capacity when skipped in Connectivity Tlv (#4654) 2020-03-09 09:19:17 -07:00
rob-the-dude dcfc0bca13 [posix] NetBSD is also missing util.h (#4651) 2020-03-09 09:15:37 -07:00
Yakun Xu 56d0e7212b [mac] add enhanced frame pending (#4334)
This commit adds enhanced frame pending feature of Thread 1.2. This
requires the platform radio driver to correctly set frame pending bit
for Data frames and MAC Data Request frames.
2020-03-09 09:08:46 -07:00
Rongli Sun fdcb8553b1 [network-data] fix stable version update issue for service (#4645) 2020-03-07 19:36:40 -08:00
Rongli Sun 9e4f9933be [network-data] fix to ensure resubmit delay (#4644)
Fix bug introduced in 5ebc583 when changing from VerifyOrExit to if.
2020-03-06 20:09:18 -08:00
Yakun Xu 9c6df6e541 [tests] remove unused self in map_pp (#4643) 2020-03-06 20:07:48 -08:00
Piotr Koziar b99f8293f9 [coap] enum type conversion to int in otCoapBlockSizeFromExponent (#4631)
This commit fixes an "enumerated type mixed with another enumerated
type" error during IAR compilation.
2020-03-06 20:06:09 -08:00
Li Cao f9ad60600e [android] add switch to use SPI in Android.mk (#4626) 2020-03-06 20:04:58 -08:00
Yakun Xu d77292ccc4 [posix] log version on start (#4620) 2020-03-06 20:04:10 -08:00
Jonathan Hui a75b412ecf [settings] fix bootloop when more than 255 ChildInfo entries are stored (#4640)
In MleRouter::RestoreChildren() there is an iteration over all
ChildInfo items. This iterator uses mIndex which is uint8_t and in our
case its value wraps causing infinite loop. Changing mIndex to
uint16_t fixes this issue.
2020-03-05 14:13:37 -08:00
Jonathan Hui 225f9b58eb [cmake] allow configuration of NCP defines (#4633)
Signed-off-by: Markus Becker <markus.becker@tridonic.com>
2020-03-05 11:07:10 -08:00
Jonathan Hui f88588e4b0 [tests] enhance matching pattern (#4629)
This commit enhances the way to match patterns during tests, so that
it can also support with readline enabled.
2020-03-05 09:59:17 -08:00
Jonathan Hui b19d2cc8ce [meshcop] simplify Timestamp TLV Get/Set 48-bit seconds value (#4638) 2020-03-05 09:55:03 -08:00
Abtin Keshavarzian 6e992e1f3e [toranj] update build script to add option for posix host using cmake (#4637) 2020-03-05 09:18:57 -08:00
Abtin Keshavarzian 62e781d63a [cmake] update posix-host cmake to allow OT_CONFIG option to be specified (#4637)
This commit changes the `CMakeLists.txt` for posix host platform to
allow the OpenThread config header file to be specified through the
`OT_CONFIG` option. Similar to other platforms, if no config header is
provided the platform can choose to provide a default one (in the
posix host case we use "openthread-core-posix-config.h" as the
default).
2020-03-05 09:18:57 -08:00
Jonathan Hui b2866e26a1 [travis] enable most build features in cmake build check (#4636) 2020-03-05 09:17:36 -08:00
Jonathan Hui 708aea8c8c [cmake] add OT_PRIVATE_DEFINES to platform lib build (#4636) 2020-03-05 09:17:36 -08:00
Jonathan Hui 36e51132c8 [tests] fix 1.2 test env and travis (#4614) 2020-03-04 20:17:56 -08:00
Jonathan Hui bc60ff5e96 [spinel] change spinel.h output dir include/spinel (#4634) 2020-03-04 10:38:45 -08:00
Jonathan Hui 2b828c164b [script] make pretty python or clang (#4632)
Reformating cpp

```bash
./script/make-pretty clang
```

Reformating python

```bash
./script/make-pretty python
```
2020-03-04 10:23:00 -08:00
Jonathan Hui afe57bf36d [fuzz] implement transmit radio callbacks (#4625)
- otPlatRadioTxStarted
- otPlatRadioTxDone
2020-03-04 10:20:10 -08:00
Jonathan Hui 50a06f80a1 [fuzz] transition fuzz_platform to cpp (#4625) 2020-03-04 10:20:10 -08:00
Yakun Xu 6614d14c34 [coap] reduce code size by avoiding using 64bit division (#4612)
- Removed OpenThread's default CoAP configuration macro, because they
  are fixed values by Thread spec.

- Use 32bit multiple only to detect overflow of application CoAP
  transmission parameters.

- Added documentation describing conditions of valid CoAP transmission
  parameters.
2020-03-03 22:59:56 -08:00
Tobías Lifschitz a802bfb0f3 [coap] change CoAP option data type to uint16_t in C/C++ API (#4621) 2020-03-03 10:12:07 -08:00
Ciaran Woodward e29e14b4fd [docs] fix outdated priority comment in message.hpp (#4627)
Since the priority levels were inverted in #3132, this comment was incorrect.
2020-03-03 09:05:55 -08:00
Jing Ma 6b8a77502d [travis] delete null OT_NCP_PATH in check-posix-app-pty (#4628) 2020-03-03 09:04:05 -08:00
Simon Lin 150aa9b6db [network-data] add source address of SVR_DATA.ntf check (#4602) 2020-03-02 22:39:34 -08:00
Abtin Keshavarzian fc6ca182d3 [cmake] fix RCP cmake build to not include FTD/MTD source files (#4624) 2020-03-02 22:00:31 -08:00
Zhanglong Xia 7f25092938 [git] ignore temporary swap files created by editor (#4618) 2020-03-02 17:58:07 -08:00
Jeff Bumgardner 688ae774aa [docs] update Doxygen for otMacCounters (#4622) 2020-03-02 14:52:59 -08:00
Eduardo Montoya 15f6808206 [cli] allow to escape separators (#4608) 2020-03-02 08:48:31 -08:00
Yakun Xu f4775fe13a [build] enhancements for OpenThread border router (#4604)
This commit makes a few small changes so that the cmake build files
can be used by project depending on this project.
2020-02-28 22:08:02 -08:00
Jonathan Hui 5b622e690e [typos] fix typos (#4613) 2020-02-28 21:45:04 -08:00
kangping 8ab37df1a7 [mle] improve readability of RouteTlv (#4610)
This commit increases readability of RouteTlv APIs, such as uint8_t
GetRouteCost(...). The argument of GetRouteCost is the index of route
in mRouteData, but not the Router ID.

This commit contains no logic changes.
2020-02-28 08:39:35 -08:00
Diego Ismirlian 8c34040d74 [efr32] Radio: don't abort current operation on switching to idle (#4586) 2020-02-28 08:31:36 -08:00
Yakun Xu c36fa453f1 [travis] move package check into lint stage (#4603)
This commit moves the package check into the first stage so that if
there are some build errors jobs in stage 2 will be skipped.
2020-02-27 21:55:30 -08:00
Stuart Longland 98f930c793 [coap] add support for RFC7641 (#4396)
* [coap] Add option scanning functions

In a few places in the OpenThread code-base, the following construct is
seen:

```
    otCoapOptionIterator iterator;
    otCoapOptionIteratorInit(&iterator, message);

    for (const otCoapOption *opt = otCoapOptionIteratorGetFirstOption(&iterator);
                             opt != NULL;
                             opt = otCoapOptionIteratorGetNextOption(&iterator))
    {
        if (opt->mNumber == OT_COAP_OPTION_DESIREDOPTION)
        {
            doSomethingWith(opt);
            break;
        }
    }
```

or its equivalent.  In cases where multiple options are sought, the
above is still the better approach (using a `switch` statement), but
otherwise this seems repetitive.

`otCoapOptionIteratorGetFirstOptionMatching` basically implements the
above loop, returning the first option that matches.  This same code can
also be used for testing for presence too by comparing the resultant
pointer to the `NULL` singleton.

For completeness in cases where a software developer may want to
*resume* looking for further matching options,
`otCoapOptionIteratorGetNextOptionMatching` is also provided.

* [coap] Add function for decoding Uint options

To properly implement features such as RFC7641 and RFC7959, one must be
able to decode unsigned integer options.  It seems silly to have an
encoder but not a decoder, so here is the missing piece.

Future considerations may be a `uint32_t` version since the majority of
use cases do not call for a `uint64_t`; the type was chosen since it was
the most general case.

* [coap] Reference the RFC for the Observe option.

For the sake of completeness, reference the relevant RFC in the
documentation so that developers can read up more on how it should work.

* [coap] Add mObserve flag to metadata.

When we're implementing observations, a few exceptions to the usual CoAP
conventions apply, notably:

- when we receive the initial reply, the request is _not_ finished, we
  will receive subsequent requests until we tell the server to stop.
- when we send a confirmable notification, the observing client will
  reply with an `ACK` with no further traffic: we need to differentiate
  this from an empty `ACK` to a request meaning we should expect a reply
  later.

While we could just repeatedly scan for the `Observe` option on the
request, that is wasteful in terms of processing time.  This allows us
to scan the request just once, and set a single-bit flag to save
processing later.

* [coap] Don't expect traffic after ACK to notification

If the client sends an empty `ACK` in reply to a confirmable RFC7641
notification, we will _NOT_ see further replies with additional
information.  Consider the notification as acknowledged and pass the
details back to the application.

* [coap] Pass through notifications to handler

Ensure that all notifications sent by the CoAP server are passed back to
the application's CoAP request handler.  When we receive the first one,
the request continues -- it does not finish until the server drops the
`Observe` flag or we tell the server to stop.

* [coap] Disable expiry timer once subscribed

If a request carries `Observe=0` and we receive the first reply, ignore
future time-out events as the transaction will finish only when
explicitly terminated.

* [coap] Support eager subscription cancellation

A CoAP client may signal its intention to unsubscribe from a resource by
sending a `GET` request with a token matching that of the original
request and setting the `Observe` option to the value 1.

In the event the application does this, we should pick this up and
cancel the pending transaction locally.  The handler will be notified of
this by a final call where `aError=OT_ERROR_NONE` and no message given.

* [cli] Add RFC7641 support to CLI example

As an aide to those developing code that uses RFC7641, implement an
example client and server that supports this feature.
2020-02-27 21:46:43 -08:00
Matteo Paris 904719079d [dtls] fix allocation and deallocation of ssl cookies (#4564) 2020-02-27 20:19:40 -08:00
Yakun Xu a613ff0ee4 [posix] fix handling SPI interrupts (#4607)
When SPI is already interrupted before select(), the wait timeout will
be set to 0, and select() will return 0 immediately if there are no
new events. As a result, cause an incorrect OT_ERROR_RESPONSE_TIMEOUT
error.

This commit fixes this issue by check if data is ready before checking
the select() result.
2020-02-27 17:56:08 -08:00
Yakun Xu a551133493 [build] rename example platform POSIX to simulation (#4555)
Having examples/posix and src/core/posix is confusing. This commit
renames the examples posix platform to simulation.
2020-02-27 12:55:56 -08:00
Yakun Xu fb16fd44d7 [build] move hdlc to lib/hdlc (#4590)
This commit moves hdlc from src/ncp to src/lib/hdlc, src/spinel is also
moved to src/lib/spinel.
2020-02-27 08:49:01 -08:00
kangping acc24cef18 [network-diagnostic] declare ExtMacAddressTlv as packed (#4606) 2020-02-27 08:31:21 -08:00
Yakun Xu 03dc380ef5 [posix-host] include inttypes.h in spi_interface.cpp (#4605)
On some platforms, inttypes.h is not included by other headers.
2020-02-27 08:29:47 -08:00
Yakun Xu e13c06e192 [mac] fix macro typo (#4601) 2020-02-26 20:49:44 -08:00
Yakun Xu 91b0dba2a0 [posix-host] fix warnings caused by SPI arguments (#4596)
* signed/unsigned conversion error
* undefined behavior of embedding macros in string literal
2020-02-26 09:49:46 -08:00
Yakun Xu a90246b760 [build] make OpenThread POSIX deb packages (#4592)
This commit enables building OpenThread deb packages:

* openthread-simulation: simulation of OpenThread
* openthread-daemon: daemon of OpenThread Host
* openthread-standalone: standalone binaries of OpenThread Host
2020-02-25 18:20:14 -08:00
Rongli Sun b339a8946b [travis] test parent selection rules (#4423)
This commit has five scenarios to test the four Mesh Impacting
Criteria and one Child Impacting Criterion (version).
2020-02-25 14:34:53 -08:00
Rongli Sun 835d9e2505 [mle] update parent selection rulesi (#4423)
This commit updates parent selection rules according to Thread 1.2
Specification section 4.5.2.1, which supplements serveral Child Impacting
rules to existing rules defined in Thread 1.1 Specification.

These additional rules are not wrapped by `OT_THREAD_VERSION_1_2'
macro as Thread 1.1 has no restrictions regarding introducing extra rules.
2020-02-25 14:34:53 -08:00
Abtin Keshavarzian c32a0ee561 [coap] misc enhancements and simplifications (#4554)
This commits contains the following changes:
- Declare `Metadata` as a private inner class of `CoapBase`. Also
  replace constructors with `Init()` method and removes the default
  empty constructor (since it is not needed).
- Add `ResponseMetadata` as private inner struct in `ResposeQueue`.
- Simplify `ResponsesQueue::FindMatchedResponse()`.
- Declare `CoapBase::Sender` as a protected type.
- Use initializer list in `CoapBase` constructor.
- Use `for` loop for iterating over messages in a message queue.
- Define `ResponseHandler` and `RequestHandler` types.
- Update `TxParameters` class. Add helper method for common
  calculation of span window, and remove unused constant definitions.
- Move more complex method implementation from header file into
  `cpp` file (helps reduce code size).
- Update comments and documentations.
2020-02-25 11:59:10 -08:00
Jonathan Hui fe6a7e1493 [cli] adjust arg length checking to 'coap parameters' (#4595) 2020-02-25 06:39:02 -08:00
Jiacheng Guo 9a4098fdb5 [posix-host] enable platform udp/netif by default in daemon mode (#4568) 2020-02-24 22:16:48 -08:00
Yakun Xu b01754cabf [mle] add enhanced keep-alive (#4325)
This commit introduces the first Thread 1.2 feature - enhanced keep
alive.

This commit also introduces the build config
OPENTHREAD_CONFIG_THREAD_VERSION to include/exclude Thread 1.2 code.
2020-02-24 21:03:19 -08:00
Yakun Xu ff3033f24f [posix-host] die on RCP timeout (#4591)
When RCP fails to respond in time, it usually means RCP is stuck or in
some bad situations that can only recover by hardware resetting. This
commit changes the behavior on RCP timeout so that RCP can be reset
during the host daemon restarting.
2020-02-24 20:58:34 -08:00
Yakun Xu 24a24f1f9e [build] move openthread-system.h under openthread (#4593)
This commit moves openthread-system.h to a directory named openthread
so that projects depends on OpenThread can use it without installing
OpenThread project.
2020-02-24 13:16:03 -08:00
Rongli Sun 87126b2b59 [router-table] exit earlier when GetRouter() for invalid router id (#4485) 2020-02-24 13:13:01 -08:00
Rongli Sun d20db6eb40 [service] fix the minimum cost server selection (#4485) 2020-02-24 13:13:01 -08:00
Rongli Sun 8d9655a282 [network-data] deregister stale network data when receiving packet destined to ALOC (#4485)
This commit assists the previous commit to help to remove invalid
server entry in some extreme scenario, for example if child server
switches parent in a Thread Network with packet loss, and
  a) SRV_DATA.ntf from the old parent to deregister fails
  b) the first attempt of SRV_DATA.ntf from the child fails
When the child tries to resend SRV_DATA.ntf due to network data inconsistence,
there will be no old rloc16, that is, the network data may have invalid server entry.

Though previous commit introduces the invalid child server detection when there is
new network data, however if the deregister there fails and there is no new
network data further, there is chance there invalid server entry would
stick there.
Here provides one invalid child server detection and recover mechanism
according to the ALOC destined traffic.
2020-02-24 13:13:01 -08:00
Rongli Sun b2a845947e [network-data] deregister for invalid child on new network data (#4485) 2020-02-24 13:13:01 -08:00
Rongli Sun 2bc32a36d1 [network-data] introduce 5s delay between SRV_DATA.ntf when deregister for child (#4485) 2020-02-24 13:13:01 -08:00
Rongli Sun b2024b8153 [network-data] ensure DATA_RESUBMIT_DELAY between SRV_DATA.ntf (#4485) 2020-02-24 13:13:01 -08:00
Rongli Sun 4bf95c6c7b [network-data] remove ClearResubmitDelayTimer() in UpdateRloc() (#4485)
`UpdateRloc()`, which happens before checking network data consistence,
should not `ClearResubmitDelayTimer()` to guarantee the DATA_RESUBMIT_DELAY
before resending when there is inconsistence.
2020-02-24 13:13:01 -08:00
Rongli Sun 530631fee9 [network-data] reuse mLastAttempt for the function of mLastAttemptWait (#4485)
This enhancement is based on that `mLastAttempt` with value `0` is
equivalent to `mLastAttemptWait` with value `false`
2020-02-24 13:13:01 -08:00
Rongli Sun ea29b88f78 [coap] clear cached coap requests with rloc source when rloc changes (#4485)
This commit helps to reduce unnecessary CoAP retransmission when rloc
changes. When comes to SRV_DATA.ntf, it also helps to avoid invalid
network data registration. Take the issue reported in #4472 as example,
in a Thread Network with packet loss, the child server may switch parents
frequently, there might be cached SRV_DATA.ntf including old rloc16,
both the cached one and new one might be sent after switched, causing
Leader improperly contain two server entries in the Network Data.
2020-02-24 13:13:01 -08:00
Thomas 206da76b26 [gp712] fix build error due to conditional include of cfmakeraw (#4594) 2020-02-24 09:45:01 -08:00
Jonathan Hui 2dec88fc41 [coap] validate token length on received messages (#4584)
Per RFC 7252:

- Treat invalid token length as a message format error.

- Rejecting a Confirmable message is effected by sending a matching
  Reset message and otherwise ignoring it.
2020-02-24 09:19:22 -08:00
Diego Ismirlian 67f33091f0 [coap] make transmission parameters dynamically configurable (#4481) 2020-02-21 16:07:48 -08:00
Jonathan Hui 167d616bc2 [network-data] avoid buffer overflow in HandleCommissioningSet() (#4583)
Reject Commissioner Dataset TLVs with extended TLV length.
2020-02-21 11:17:05 -08:00
Jonathan Hui ea09b6e064 [fuzz] fix fuzzer platform build (#4583) 2020-02-21 11:17:05 -08:00
Yakun Xu cec297475f [build] fix command t not found (#4588)
There may be some bug in automake when computing dependencies,
causing output error messages as following when installing:

```bash
/bin/bash: t: command not found
```

This issue is introduced in #4558.
2020-02-21 09:25:46 -08:00
Marven Gilhespie f81384f785 [efr32] added suffixes to BSP CLK constants hal-config.h to match SDK (#4585) 2020-02-21 09:21:21 -08:00
Diego Ismirlian f8b8b24b6f [posix-host] ot-cli: handle write() return values (#4580) 2020-02-21 09:18:59 -08:00
Li Cao 8fcdcf6fd3 [test] fix check error, cast non-trivial class pointer to void * (#4579) 2020-02-20 09:38:43 -08:00
Abtin Keshavarzian 5cddf90389 [link-quality] remove aNoiseFloor param from LinkQualityInfo methods (#4569) 2020-02-20 09:36:34 -08:00
Abtin Keshavarzian 2437a75a6b [link-quality] have LinkQualityInfo inherit from IntsanceLocatorInit (#4569) 2020-02-20 09:36:34 -08:00
Abtin Keshavarzian 0f5edc4c89 [child] remove instance parameter from Ip6Address related methods (#4569)
Remove the now unnecessary `aInstance` parameter in `Child` methods
(since `Child` is now itself an `InstanceLocator`).
2020-02-20 09:36:34 -08:00
Abtin Keshavarzian fb65c77c1a [topology] have Neighbor/Child/Router inherit from InstanceLocatorInit (#4569)
This commit changes the `Neighbor` class (and therefore its sub-classes
`Child` and `Router`) to inherit from `InstanceLoatorInit`. It adds
`Init()` method to them as well and ensures that they are initialized
before use from `ChildTable`, `RouterTable` and `Mle` classes.
2020-02-20 09:36:34 -08:00
Abtin Keshavarzian 67c5081d14 [locator] adding InstanceLocatorInit (#4569)
This commits adds a new class `InstanceLocatorInit` which is
similar to `InstanceLoator` but provides a default constructor
(instead of a parameterized one) and allows an inheriting class to
initialize the object (set the OpenThread Instance) post constructor
call using the `Init()` method. This class is intended for types that
require a default constructor and cannot use a parameterized one. An
example of such a class is one that is used as type of a C array
element (e.g., `Neighbor`/`Child`/`Router` classes which are used as
array in `ChildTable`/`RouterTable`).
2020-02-20 09:36:34 -08:00
Jonathan Hui 0823114dff [mle] mark former parent as valid after becoming router (#4582)
Commit a8638d7 added logic to invalidate the parent upon a role
change. However, when upgrading from child to router, the existing
implementation updates the role before copying the parent into into
the router table. As a result, a router	may not	have any connectivity
with the rest of the partition until after additional MLE exchanges.

This commit marks the newly created router entry as valid so that the
router retains connectivity.
2020-02-19 22:20:01 -08:00
Yakun Xu 4d1f60d82e [build] do not export openthread/config.h (#4561)
openthread/config.h is just used when building OpenThread, and does
not contain OpenThread APIs.
2020-02-19 13:25:07 -08:00
Yakun Xu cc3e5ba6f4 [posix-host] set network interface name (#4573)
When platform netif is enabled, the TUN device's name should be able to
set from command. This PR use the existing `-I` to allow user provide a
wanted name.
2020-02-19 11:47:55 -08:00
Yakun Xu abf108a9b1 [android] build ot-ctl on Android.mk (#4567) 2020-02-19 11:46:23 -08:00
Yakun Xu 8546bceeab [build] move spinel into src/utils (#4558)
Move spinel from src/ncp into src/utils and remove dependency on
OpenThread's core configurations.
2020-02-19 11:45:35 -08:00
Yakun Xu aa62fd8f65 [cli] always output command result (#4556)
Always output command result, i.e. "Done" on success, error message
otherwise.

Factory commands also follow the same pattern. Their existing error
messages are not removed for backward compatibility consideration.
2020-02-19 11:44:42 -08:00
Simon Lin c8dff09d3a [python] remove unnecessary calls to dict.keys() (#4576) 2020-02-18 10:16:06 -08:00
Diego Ismirlian ef0cabafb1 [posix-host] explicitly ignore return value on write (#4574) 2020-02-18 10:10:52 -08:00
Yakun Xu a8638d7ff8 [mle] invalidate parent if not child (#4572)
Current Thread certification needs Parent information even after the
node already become a router or leader. This commit sets parent state
to invalid to indicate information in mParent should not be used in
normal cases.
2020-02-18 10:04:07 -08:00
Abtin Keshavarzian 9de99a8efa [toranj] fix the check for router entry "is link established" (#4566) 2020-02-18 09:53:05 -08:00
Diego Ismirlian cc115790da [efr32] remove -Wundef for SDK sources (#4565)
Restore the lines accidentally removed by commit 609665d.
2020-02-18 09:52:25 -08:00
Jonathan Hui d52f893b35 [network-data] remove redudnant code from RegisterNetworkData() (#4562) 2020-02-18 09:50:57 -08:00
Jonathan Hui 8079570ccf [network-data] resolve uninitialized output from RlocLookup (#4562) 2020-02-18 09:50:57 -08:00
Yakun Xu 1f2bed8e7d [posix-host] use c++ for all platform code (#4547)
- Switched to C++ for all drivers.
- Removed C utilities.
- Renamed sim.c to virtual_time.cpp.
- Changed platformSim prefix to virtualTime.
2020-02-13 06:15:47 -08:00
Kuznia, Rafal b4c5bd5044 [nrf528xx] add JLink subdirectory per individual chip basis (#4511) 2020-02-12 07:47:51 -08:00
Duda, Lukasz b6c534ecf0 [nrf528xx] adapt generic sdk_config.h file from nRF5 SDK (#4511) 2020-02-12 07:47:51 -08:00
Jay Logue 27128db8ee [build] support building platform code without examples (#4511)
- [build] Added --with-platform configure option to enable building
the platform libraries without building the example applications or
any supporting libraries used solely by the examples.

- [nrf528xx] Modified the nrf528xx-specific makefiles such that Nordic
SDK code located in third_party/NordicSemiconductor is only
built/referenced when building the example applications.  When
building just the platform libraries, the caller of configure is
expected to provide the correct arguments to use an external copy of
the Nordic nRF5 SDK.  An exception to this is the 802.15.4 radio
driver, which is always built using the sources in
third_party/NordicSemiconductor/drivers/radio.

- [nrf528xx] Made various minor edits to #include statements in the
nrf528xx platform code.  This was necessary because of the difference
in directory structure between the code in
third_party/NordicSemiconductor and that in the formally published
Nordic nRF5 SDK.
2020-02-12 07:47:51 -08:00
Yakun Xu a70007dbdf [build] auto detect big endian (#4551) 2020-02-12 07:42:50 -08:00
Neal Jackson 1145d32cb0 [coap] fix comparison with block size validity check (#4553) 2020-02-12 07:15:40 -08:00
Yakun Xu 954a9f284e [android] move OPENTHREAD_POSIX_RCP_UART_ENABLE (#4549)
The macro OPENTHREAD_POSIX_RCP_UART_ENABLE should be defined for all
builds, not only for CI tests.

This commit also sorts the definitions removed duplicate definitions.
2020-02-11 14:40:31 -08:00
ludu f7136eba3e [address-resolver] add log on new cache entry creation (#4540) 2020-02-11 14:18:08 -08:00
Duda, Lukasz d3bca730aa [address-resolver] introduce MoveAt functionality (#4540) 2020-02-11 14:18:08 -08:00
Duda, Lukasz c85a1c3c71 [address-resolver] dequeue message from resolving queue before invalidate the entry (#4540) 2020-02-11 14:18:08 -08:00
Duda, Lukasz 61b18cbde5 [address-resolver] fix last transaction time of entry created by packet inspection (#4540) 2020-02-11 14:18:08 -08:00
Duda, Lukasz 17f779fa62 [address-resolver] accept multicast Address Error Notification (#4540) 2020-02-11 14:18:08 -08:00
Yakun Xu 3d029d27fc [spinel] fix when strnlen is not a macro (#4548)
If strnlen is a normal function, the current code will result in
duplicate definition error.
2020-02-11 12:01:29 -08:00
Jonathan Hui 0a730cd2d0 [docs] correct dataset activetimestamp example (#4545) 2020-02-11 07:33:05 -08:00
Jonathan Hui 2c66141c17 [network-data] add check for invalid router IDs (#4544)
It is posisble for a leader to receive SVR_DATA.ntf messages
attempting to register with a router ID that is not valid on the
leader.

This commit does not allow registering network data with invalid
router IDs to avoid having stale network data that persists.
2020-02-11 07:32:43 -08:00
Neal Jackson b81813fa4e [coap] add helper functions to encode coap block options (#4513)
This small feature addition is two helper functions to encode the
Block1 and Block2 uint options described in RFC7959.
2020-02-11 07:29:05 -08:00
Jonathan Hui e83b8c77c0 [settings] allow value to have smaller than expected length (#4499)
Newer versions may add additional fields to the end of the settings
structure. However, there may be situations where an older version may
nead to read the structure.

This commit allows the stored settings value size to be smaller than
expected.
2020-02-11 07:12:51 -08:00
Jonathan Hui e9261b6842 [settings] initialize structure before reading from storage (#4499)
This commit initializes	the settings structures	before reading.	This
helps prepare for a following commit that allows reading stored	values
that are shorter than expected.

This commit also renames the Clear() methods to Init().
2020-02-11 07:12:51 -08:00
Yakun Xu a84fea58e1 [build] add DISABLE_TOOLS flag (#4543) 2020-02-10 08:38:18 -08:00
Łukasz Duda 1edde90d91 [sub-mac] fix incorrect timer configuration for energy scanning (#4538)
This fixes the implementation of Energy Scanning in case the platform
does not support it, but uses timer with microsecond resolution. This
is not the case with nRF528xx but found it during code inspection.

I've verified that after removing OT_RADIO_CAPS_ENERGY_SCAN
capability, the Energy Scan now works correctly.
2020-02-09 17:12:17 -08:00
Łukasz Duda b5b607cc1d [nrf528xx] fix synchronous GetRssi functionality (#4537)
This commit aligns otPlatRadioGetRssi implementation with the latest
changes to radio driver.

Without this change, for example, Channel Monitor and Energy Scanning
with duration of 0 (energy scan 0 command) does not work.
2020-02-09 17:11:07 -08:00
Łukasz Duda b62d42f0ef [mle] unify stopping of the advertising timer (#4539) 2020-02-09 15:17:02 -08:00
Abtin Keshavarzian 253e99ba17 [cli] use ICMPv6 Echo Request ID to match Responses (#4534)
This commit updates/enhances the CLI `ping` command. It adds the
feature to track and match the ICMPv6 echo requests and responses
using an identifier. Each `ping` command will use a new value as the
identifier. A received ICMPv6 echo response not matching the current
identifier is ignored. This commit also makes the following (smaller)
changes:
- renames the ping related member variables as `mPing{Name}`,
- defines  constants for default ping parameters,
- changes `ping` to use public OT APIs/definition (instead of core
  methods).
2020-02-09 15:13:59 -08:00
Jonathan Hui aa78b2688e [unit-test] fix implicit conversion in test_lowpan.cpp (#4533) 2020-02-07 22:51:48 -08:00
Jonathan Hui 28dd4475b7 [unit-test] fix 'va_start" undefiend behavior in test_linked_list.cpp (#4533)
Fixes passing an object of reference type to 'va_start' has undefined
behavior.
2020-02-07 22:51:48 -08:00
Jonathan Hui 647539632b [settings] encode non-volatile structs as little endian (#4527) 2020-02-07 22:51:21 -08:00
Jonathan Hui b2227703d7 [settings] declare non-volatile structures as packed (#4527) 2020-02-07 22:51:21 -08:00
Piotr Koziar c4940b3605 [nrf528xx] update nrf_security to 0.9.2 (#4529)
* Update nrf_security to 0.9.2

* Added MBEDTLS_PK_WRITE_C to nrf52840-mbedtls-config.h

* Enabled pk write in mbedtls Makefile. Added MBEDTLS_PK_WRITE_C to nrf52833 config
2020-02-07 08:31:22 -08:00
Jiacheng Guo c0313240d2 [android] build CLI and NCP libraries (#4528)
This enables other repositories to link against these libraries.
2020-02-07 08:28:52 -08:00
Abtin Keshavarzian 3d30955a3b [posix-app] add error if no RCP interface (SPI/UART) is enabled (#4510) 2020-02-07 08:27:15 -08:00
Abtin Keshavarzian 26d6e7faf0 [hdlc] add missing <string.h> include (for memmove()) (#4510) 2020-02-07 08:27:15 -08:00
Abtin Keshavarzian 95f700dd7e [toranj] move posix-app config defs into header file from build script (#4510) 2020-02-07 08:27:15 -08:00
Abtin Keshavarzian d052f36af8 [posix-app-config] add UART/SPI config macros and their default value (#4510)
This addresses undefined macro warnings when building posix-app.
2020-02-07 08:27:15 -08:00
Abtin Keshavarzian 53b711e4f4 [posix-app] add posix config header file (#4510)
This commit updates how posix-app source files include the config
header file to follow a similar policy as for core modules. All header
files and `cpp` files that do not have a corresponding `hpp` file
should include "openthread-posix-config.h" first (which itself will
include the core config header). The "cpp" files which have a related
"hpp" should include the related hpp file first. This way we ensure
all config macro definitions are correctly included in all modules.
2020-02-07 08:27:15 -08:00
Jonathan Hui 50e094865b [cmake] add additional compiler options (#4500) 2020-02-07 08:26:10 -08:00
Abtin Keshavarzian de7083094e [ip6] fix conversion of enum value to uint8_t (#4522)
This commit updates how the `otMessagePriority` enumeration variable
is updated in `otMessageSettings` structure. This addresses an issue
where the enum variable was being treated as an `uint8_t` which may
not necessarily be correct (since complier can choose any integral
type which covers all the enumerator values as the underlying storage
for an unscoped enumeration type).
2020-02-04 10:37:56 -08:00
Yakun Xu 33808ebfba [style] apply google python style guide (#4501)
This commit applies and enforces Google's python style for tests.
2020-02-04 10:27:50 -08:00
Jeff Bumgardner 8368d440dd [docs] update list of supporters (#4526) 2020-02-04 09:35:44 -08:00
Abtin Keshavarzian 3a25f3a020 [mle] simplify how parent candidate is cleared (#4525)
This commit inlines and removes `ResetParentCandidate()` method.
2020-02-03 22:14:31 -08:00
Diego Ismirlian 0d9f5cb58a [posix-host] add hardware flow control capability to hdlc interface (#4518) 2020-02-03 22:13:03 -08:00
Jeff Bumgardner f1dc2d882b [docs] move Doxygen group structure to the docs directory (#4476) 2020-02-03 09:17:40 -08:00
Abtin Keshavarzian 2f075974b5 [netif] simplify adding external unicast/multicast addresses (#4520) 2020-02-03 09:13:27 -08:00
Abtin Keshavarzian 8729bc4dac [netif] add helper methods to identify in-use netif address entries (#4520) 2020-02-03 09:13:27 -08:00
Abtin Keshavarzian c52ef80f4e [netif] fix typos in comments (#4520) 2020-02-03 09:13:27 -08:00
Abtin Keshavarzian 9be3de3b1d [netif] remove unused mNext pointer (#4520) 2020-02-03 09:13:27 -08:00
Abtin Keshavarzian 45d5afb10e [ip6-address] inline very simple methods (#4519)
This commit inlines the very simple methods (containing a single
basic operation) in `Ip6::Address` class.
2020-02-03 09:11:35 -08:00
Abtin Keshavarzian a5862a6de1 [ip6-address] remove undefined/unused method declaration (#4519) 2020-02-03 09:11:35 -08:00
Abtin Keshavarzian 0f274641f1 [ip6-address] simplify IsAnycastServiceLocator() (#4519)
This change ensures we avoid comparing values with host-swapped
constants.
2020-02-03 09:11:35 -08:00
Abtin Keshavarzian 16b6c8df89 [ip6-address] use larger data fields when checking against constants (#4519)
This commit changes methods in `Ip6::Address` class to use larger
fields (`m16` or `m32`) for comparing portions of address sequence
against constant values when possible.
2020-02-03 09:11:35 -08:00
Abtin Keshavarzian cd0ef26c02 [toranj] update test-012-multi-hop-traffic (#4516)
This commit updates tornaj `test-012-multi-hop-traffic` to make it
more robust by waiting for entire chain topology to be discovered
(router table to be fully updated) before starting message exchange.

This should help with rare failures of this test, which happen when an
address query response is received before the "next hop" for the
destination router is discovered (through Link Advertisement
exchanges) on the first router `r1`.
2020-01-29 22:28:47 -08:00
Neal Jackson 45d78d7871 [build] change macOS bootstrapped GCC to official ARM brew tap (#4514)
Change to using ARM's official toolchain tap.
2020-01-29 22:14:17 -08:00
Abtin Keshavarzian bc02c6c05c [mac-frame] add missing OT_TOOL_PACKED_BEGIN to Beacon class (#4509) 2020-01-27 22:21:36 -08:00
Diego Ismirlian 83c75333ec [efr32] Radio: correct PA supply selection for BRD4166A (#4506) 2020-01-27 22:21:12 -08:00
garyButt 609665d017 [efr32] add support for EFR32MG13 (#4488) 2020-01-27 22:19:17 -08:00
Abtin Keshavarzian a5f2a41cb3 [mac] simplify scan handlers (#4503)
This commit changes the energy and active scan callback handlers in
`Mac` class to make them follow the model used by external OpenThread
scan APIs. This in turn simplifies their use, allowing us to remove
the code that saved energy/active scan callbacks and contexts in the
`Instance` object. This commit also adds some missing `const` methods
to Beacon class which allows us to declare the received beacon frame
(from scan operation) as a `const`.
2020-01-23 19:48:02 -08:00
Yakun Xu 8d22fdd09c [toranj] improve code coverage by using absolute path (#4491)
Gcov sometimes cannot correctly find source files when the code is
configured with relative path. This commit enables using absolute path
to run toranj tests.
2020-01-23 19:45:51 -08:00
Jonathan Hui b0a89c4083 [nlbuild-autotools] update to 1.6.16 (#4507)
Allow absolute paths in PRETTY_FILES.
2020-01-23 19:44:18 -08:00
Jonathan Hui 69723afcb1 [mbedtls] update to 'https://github.com/nestlabs/nlbuild-autotools.git' tag '1.6.16'. 2020-01-23 19:48:38 +00:00
Jonathan Hui ba22751658 Squashed 'third_party/nlbuild-autotools/repo/' changes from b1b93c9d..4cbe14a4
4cbe14a4 Update version to 1.6.16.
7adbffbc Merge pull request #30 from bukepo/pretty/support-abs
2ac7f5da Add absolute path support for pretty

git-subtree-dir: third_party/nlbuild-autotools/repo
git-subtree-split: 4cbe14a4adb8702d81a63fd663bf046407908def
2020-01-23 19:48:38 +00:00
Yakun Xu e2800ed10d [posix-host] add otPlatRadioGetState() (#4504)
This commit implements otPlatRadioGetState() on POSIX platforms,
including simulation and posix-host app.

This is for debugging purpose.
2020-01-23 10:45:15 -08:00
Yakun Xu e5d4b971fe [nrf528xx] support pretty out of source directory (#4505)
This commit enhances the Makefile.am of nrf528xx to support make
pretty out of the source directory.
2020-01-23 10:21:30 -08:00
Simon Lin ff5b209fe4 [build] fix wrong macro name (#4498) 2020-01-23 10:18:33 -08:00
Yakun Xu 0e051b1a27 [cli] emit SIGINT on ctrl-c (#4502)
This commit emits SIGINT on ctrl-c so that gdb can work as expected.
2020-01-23 08:42:22 -08:00
amosolgo-lutron 1f9118834a [mbedtls] split builtin mbedtls management option from mbedtls build option (#4473)
Add a new OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT flag to
configure builtin mbedtls buffer/debug management separately from the
existing flag which configures the inclusion of the builtin mbedtls
library in the build.
2020-01-23 08:41:07 -08:00
Abtin Keshavarzian a5369eaa98 [address-resolver] rename static method to InvalidationReasonToString (#4486) 2020-01-22 20:52:09 -08:00
Abtin Keshavarzian 24b84cc762 [mle] rename static methods converting between service ALOC and Id (#4486) 2020-01-22 20:52:09 -08:00
Abtin Keshavarzian c9ce2d42e9 [mle] rename static method to ChildIdFromRloc16() from GetChildId() (#4486) 2020-01-22 20:52:09 -08:00
Abtin Keshavarzian b7a56cdfd7 [mesh-forwarder] use Mle::RouterIdMatch() helper method (#4486) 2020-01-22 20:52:09 -08:00
Abtin Keshavarzian e2403f6066 [mle] rename static method to RouterIdFromRloc16() from GetRouterId() (#4486) 2020-01-22 20:52:09 -08:00
Abtin Keshavarzian 05747e7670 [mle] rename static method to Rloc16FromRouterId() from GetRloc16() (#4486)
This commit renames the static `Mle` method which derives RLOC16
from a given Router ID to `Rloc16FromRouterId()` from `GetRloc16()`.
This helps distinguish this method from other `GetRloc16()` methods.
2020-01-22 20:52:09 -08:00
Abtin Keshavarzian 5ba6ede53a [mle-router] use routerId as variable name (#4486) 2020-01-22 20:52:09 -08:00
Abtin Keshavarzian 515e3bde8c [mle] update route table log message (#4486)
This commit updates the route table log message to include if link
is established with router or not (router is a neighbor). Also the
`0xffff` is printed as next hop if it is invalid and we indicate
if the entry is for the device itself.
2020-01-22 20:52:09 -08:00
Abtin Keshavarzian 583873c133 [mle] log rloc16 changes (#4486) 2020-01-22 20:52:09 -08:00
Diego Ismirlian f816635465 [efr32] Radio: use RAIL_CopyRxPacket (#4484) 2020-01-22 14:53:14 -08:00
Diego Ismirlian 59b3c51184 [efr32] Radio: correctly set mAckedWithFramePending (#4484) 2020-01-22 14:53:14 -08:00
Jonathan Hui f6738b78e9 [configure] remove _BSD_SOURCE _DEFAULT_SOURCE (#4483) 2020-01-22 13:39:25 -08:00
Jonathan Hui 5b22b4d7c7 [utils] remove wrap_string.h (#4483) 2020-01-22 13:39:25 -08:00
Jonathan Hui 71a7e47c81 [utils] remove strnlen (#4483) 2020-01-22 13:39:25 -08:00
Jonathan Hui 708c250fe5 [utils] remove strlcpy (#4483) 2020-01-22 13:39:25 -08:00
Jonathan Hui 5c9b60b855 [utils] remove strlcat (#4483) 2020-01-22 13:39:25 -08:00
Yakun Xu 26694bee5c [ncp] simplify unimplemented commands (#4490) 2020-01-22 10:18:54 -08:00
kangping 51bb4be6c4 [meshcop] fix premature free of finalize message (#4487)
This commit fixes a bug that the finalize message will be prematurely
freed if the joiner is started at the second time without waiting for
the finish of the first initiation.
2020-01-22 10:05:22 -08:00
Zhanglong Xia f0c063f8e9 [posix-host] add SPI interface support (#4431) 2020-01-21 19:24:42 -08:00
Rongli Sun ef4530a187 [commissioner] remove duplicate CoapSecure::Stop() call (#4495) 2020-01-21 14:18:47 -08:00
Yakun Xu 59b49de355 [codecov] ignore third_party code (#4489) 2020-01-21 14:08:48 -08:00
Jiacheng Guo 59fc287024 [travis] correct error message output (#4477) 2020-01-21 13:59:46 -08:00
Diego Ismirlian c4f32fd907 [efr32] Radio: Use assert to detect issues when interacting with RAIL (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian f947eefa51 [efr32] Radio: honor mMaxCsmaBackoffs and implement get/set CcaEnergyDetectThreshold (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian 0c48c06061 [efr32] Radio: implement Rx timestamping (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian 312dad2578 [efr32] Radio: handle promiscuous mode for ACK packets (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian 002f9dbe38 [efr32] Radio: signal event pending when failed to start tx (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian 0ef278af6b [efr32] Radio: change core configurations (#4482)
- Set OPENTHREAD_CONFIG_SOFTWARE_CSMA_BACKOFF_ENABLE=0 and
  OPENTHREAD_CONFIG_SOFTWARE_ENERGY_SCAN_ENABLE=0 according to the implemented
  hardware capabilities.

- Undefine RADIO_CONFIG_SRC_MATCH_*_ENTRY_NUM to let the soft source match table
  implementation define them as OPENTHREAD_CONFIG_MLE_MAX_CHILDREN
2020-01-17 10:59:34 -08:00
Diego Ismirlian 46b7d09f14 [efr32] Radio: remove duplicate calls (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian c47bded0ae [efr32] Radio: correct macAckWaitDuration (#4482) 2020-01-17 10:59:34 -08:00
Diego Ismirlian 9b86de8260 [posix-host] explicitly ignore return value on write (#4480)
Build failed because write was declared with attribute warn_unused_result.
2020-01-17 08:24:47 -08:00
Jonathan Hui 73ff9439e6 [ncp] remove dead code in SPINEL_PROP_STREAM_NET set handler (#4475) 2020-01-14 22:10:38 -08:00
Jiacheng Guo 7d92134da2 [posix-host] add command mode for ot-ctl (#4457)
ot-ctl will now send the command line arguments to ot-daemon and print
the reply.
2020-01-14 22:07:36 -08:00
kangping 05ba4c29f4 [script] add ppa without user input (#4474) 2020-01-14 12:58:25 -08:00
konradderda 1ab8661d80 [ncp] add timestamp to log metadata fields (#4439)
This change adds an information about the timestamp to the log
metadata that is calculated with the formula: <timestamp_base> +
<time_from_start_in_ms>. The <timestamp_base> value is set to 0 by
default and can be changed with a new SPINEL property:
SPINEL_PROP_DEBUG_LOG_TIMESTAMP_BASE formatted as X (uint64_t).
2020-01-14 12:57:35 -08:00
Diego Ismirlian 51485d4ecd [mac] correct default OPENTHREAD_CONFIG_MAC_MAX_CSMA_BACKOFFS_DIRECT (#4432) 2020-01-13 15:24:48 -08:00
Abtin Keshavarzian 78156bbdcd [unit-test] add unit test for Mesh/Fragment Header (#4453) 2020-01-13 10:57:42 -08:00
Abtin Keshavarzian b99f434a88 [lowpan] update BufferWriter to use end pointer instead of length (#4453)
This commit also updates some of `Lowpan` (decompression) methods to
use an end pointer instead of tracking remaining length.
2020-01-13 10:57:42 -08:00
Abtin Keshavarzian 17168e9ba1 [lowpan] simplify FragmentHeader and its use in MeshForwarder (#4453)
This commit updates the `Lowpan::FragmentHeader` class to provide
methods to parse/write the Fragment Header from/to a given frame or
message.
2020-01-13 10:57:42 -08:00
Abtin Keshavarzian 2ec0d2f8d4 [mesh-forwarder] skip mesh header immediately after parsing it (#4453)
This commit updates `HandleMesh()` method to skip the mesh header in
the frame immediately after parsing it. This in turn removes the need
for other methods (`CheckReachability` or `UpdateRoutes()` calling
through `GetIp6Header()` to `DecompressIp6Header()`) to redo the
parsing to skip the mesh header. With this change we can also remove
the now unused `SkipMeshHeader()`.
2020-01-13 10:57:42 -08:00
Abtin Keshavarzian 086753c08d [lowpan] simplify MeshHeader and its use in MeshForwarder (#4453)
This commit updates the `Lowpan::MeshHeader` class to provide methods
to parse/write the Mesh Header from/to a given frame or message. The
`MeshHeader` no longer provides a direct representation of the header
(instead, it contains all fields required to generate the header).
This is mainly due to fact the header format itself may vary depending
on the "hops left" value. This change also removes the need for the
`MeshHeader` to be a packed `OT_TOOL_PACKED` structure.
2020-01-13 10:57:42 -08:00
Abtin Keshavarzian 85ddb11add [mesh-forwarder] use pointer to iterate through mFragmentEntries (#4453) 2020-01-13 10:57:42 -08:00
Abtin Keshavarzian 5eba7f1cb4 [mesh-forwarder] simplify GetForwardFramePriority() and remove GetMeshHeader() (#4453)
Before passing the frame to `GetForwardFramePriority()` the mesh
header is skipped (to avoid re-reading the mesh header). Also the
src/dest parameters are renamed to indicate they are mesh source and
mesh destination (also the order of parameters changed to start with
source and then dest). With this change we can remove
`GetMeshHeader()` (since no longer used/needed).
2020-01-13 10:57:42 -08:00
Abtin Keshavarzian 1a96fef16d [mesh-forwarder] use SuccessOrExit, update comments (#4453) 2020-01-13 10:57:42 -08:00
Jonathan Hui 40a84bb18f [cli] add mSntpQueryingInProgress to initializer list (#4464) 2020-01-13 06:44:34 -08:00
Jonathan Hui fd808f72c1 [mac] add mPromiscuous to initializer list (#4464) 2020-01-13 06:44:34 -08:00
Jonathan Hui 1801e6c601 [dataset] add mSaved to initializer list (#4464) 2020-01-13 06:44:34 -08:00
Abtin Keshavarzian bfa82fbb3b [build] define OPENTHREAD_FTD/MTD/RADIO in posix-app and unit test makefiles (#4469)
This helps address undefined config macro warnings.
2020-01-12 22:15:24 -08:00
Marven Gilhespie 4695b74771 [efr32] remove SDKVERSION in makefiles to fix SDK v2.7 build (#4466) 2020-01-12 22:13:06 -08:00
Jonathan Hui 1a5c687810 [mle] remove redundant call to RouterTable::GetRouter (#4465) 2020-01-12 22:09:22 -08:00
Jonathan Hui 4b0822fa8e [ncp] remove dead code in SPINEL_PROP_STREAM_NET_INSECURE set handler (#4463) 2020-01-12 22:09:01 -08:00
Jonathan Hui 3ea4c91b75 [nlbuild-autotools] update to 1.6.15 (#4468) 2020-01-12 22:08:16 -08:00
Robert Szewczyk 0dbae78d4c [nlbuild-autotools] update to 'https://github.com:nestlabs/nlbuild-autotools' tag '1.6.15'. 2020-01-10 17:09:06 -08:00
Robert Szewczyk 8e95e5e34c Squashed 'third_party/nlbuild-autotools/repo/' changes from 6b6a11dc9..b1b93c9de
b1b93c9de Merge pull request #29 from robszewczyk/bug/redundant-libtool-libraries
92cda4133 Remove inconsistent libtool libraries and automake-distributed files
9e610e1e0 Merge pull request #27 from nestlabs/feature/github-issue-26
17b0d3033 Attempt to use HTTP rather than FTP to address random Travis CI fetch failures.
83c3fbd6e Ensure that package retrievals have at least four (4) retries.
330ea5628 Update the manifest to ensure 'make dist' works.
10c35016c Add a Travis CI build status badge.
8e08dc7e6 Initial revision.
e05a00c3b Merge pull request #25 from robszewczyk/bug/update-coreutils
e0c75cf3e Update coreutils s.t. the tools can be built on newer Linux systems
4db93dd94 Merge pull request #24 from robszewczyk/feature/header-depend-on-built-sources
244f42204 Bookkeeping: default version and changelogs
6dd233313 install-headers target should depend on BUILT_SOURCES
650b05690 Merge pull request #23 from nestlabs/bug/address-bootstrap-bashism

git-subtree-dir: third_party/nlbuild-autotools/repo
git-subtree-split: b1b93c9de7121dcd6099fb3b651b8a6ed5b42d22
2020-01-10 17:06:37 -08:00
Stuart Longland 033cf4c4b1 [coap] add otCoapOptionIterator and related API functions (#4452)
This commit adds a otCoapOptionIterator structure which the user can
use to iterate over the CoAP options of a ot::Coap::Message object
without influencing any of the properties of that object.

Multiple otCoapOptionIterator structures may operate on the same
ot::Coap::Message object without interference.
2020-01-10 08:46:53 -08:00
周瑞祺 bfa84c26b0 [harness-sniffer] add OT sniffer support in Thread Test Harness (#4233)
Run Test Harness with OT sniffer.
2020-01-10 08:43:37 -08:00
Jintao Lin 8788cf5a97 [posix-host] add posix parameter to get dataset from NCP and save to file (#4446)
There are cases when NCP platform was used at first. Then need to
change to use RCP platform later. The PAN active and pending dataset
needs to be retrieved from NCP firmware to avoid repairing again.

This change,
1. Add one parameter to posix host (--ncp-dataset).
2. Avoid some radio spinel command and check so that posix app can start
otInstance and talk to NCP firmware.
3. Utilize spinel property SPINEL_PROP_THREAD_ACTIVE_DATASET and
SPINEL_PROP_THREAD_PENDING_DATASET to retrieve dataset from NCP.
2020-01-09 18:15:23 -08:00
Jonathan Hui f520ea9a76 [announce-sender] fix bug in computing announce period (#4460) 2020-01-09 14:02:11 -08:00
Jonathan Hui c46c9f4374 [examples-posix] fix undefined config macro warnings (#4458) 2020-01-09 11:45:39 -08:00
Abtin Keshavarzian 4b6ba537df [ncp] fix undefined config macro warnings (#4458) 2020-01-09 11:45:39 -08:00
Abtin Keshavarzian b853231920 [posix-app] fix undefined config macro warnings (#4458) 2020-01-09 11:45:39 -08:00
Abtin Keshavarzian cf809bd16a [ncp/cli/posix-app] disable coverage test when macro not defined (#4458)
This change help suppress the undefined macro warnings.
2020-01-09 11:45:39 -08:00
Abtin Keshavarzian da6c00bd29 [utils-settings] add a header file for settings config definitions (#4458)
This commit adds a header file `settings.h` to include all the
default configuration definitions related to `settings` platform
utility. It also adds `OPENTHREAD_SETTINGS_RAM` to this file.
This helps address the undefined macro warnings.
2020-01-09 11:45:39 -08:00
Abtin Keshavarzian 812e108103 [example-posix] add missing config definitions (#4458)
This commit updates `platform-config.h` to add default value for
config definitions. This helps suppress the undefined macro
warnings.
2020-01-09 11:45:39 -08:00
Abtin Keshavarzian 3cb411ca22 [toranj] fix undefined config macro warnings (#4458) 2020-01-09 11:45:39 -08:00
Abtin Keshavarzian ebc8684307 [wrap-strings] fix undefined config macro warnings (#4458) 2020-01-09 11:45:39 -08:00
Abtin Keshavarzian 0215527358 [spi-hdlc-adapter] fix undefined config macro warnings (#4458) 2020-01-09 11:45:39 -08:00
Marven Gilhespie 73e30d1d7b [efr32] update to Silicon Labs SDK v2.7 (#4447)
Updated makefiles for v2.7 SDK
Replaced RAIL timers with sleeptimers.
2020-01-08 10:14:12 -08:00
Abtin Keshavarzian b87545f0c8 [mesh-forwarder] fix incorrect cast to uint8_t when setting frame length (#4456) 2020-01-08 08:41:59 -08:00
Rongli Sun f976db5c4c [mle] link sync enhancement (#4427)
There is chance for below scenario:
1) Device newly becomes router and sends multicast Link Request
   (challenge1),
2) Device receives MLE advertisement from one neighbor, and sends
   unicast Link Request (challenge2),
3) The neighbor ignores the unicast link Request in 2) and sends
   out Link Accept and Request message as response for 1)
4) Device would drop the Link Accept adn Request message
   in 3) as it compares the Response TLV value with challenge2, which
   in fact matches challenge1.

The link between Device and the neighbor could not be established until
Device receives next MLE advertisement from the neighbor.

This commit suppresses unicast Link Request in 2) if there is multicast
Link Request ongoing. Thus the three-handshakes link sync could go well.
2020-01-08 08:39:10 -08:00
Diego Ismirlian e44461151f [build] detect undefined macros to avoid misconfigurations (#4300) 2020-01-08 08:37:46 -08:00
Diego Ismirlian 4fec70b67d [network-data] fix compile error when building service without border router (#4443) 2020-01-07 12:48:33 -08:00
konradderda 77ae260c77 [mle] allow setting router eligible attr to false for MTD (#4450) 2020-01-06 10:45:28 -08:00
Łukasz Duda aa9a45d212 [nrf528xx] return the TX power which was actually set in the register (#4451)
This commit ensures that TX Power returned via
otPlatRadioGetTransmitPower is one that is actually set in the
register. E.g. even if TX power is set to 100 via
otPlatRadioSetTransmitPower, the maximum power is 8 for nRF52840.
2020-01-06 10:05:09 -08:00
Abtin Keshavarzian 568fab148b [ncp-base] use macros to simplify the handler arrays definitions (#4448) 2020-01-06 08:32:06 -08:00
Abtin Keshavarzian 597e112259 [ncp-base] use array and binary search for insert/remove prop handlers (#4448) 2020-01-06 08:32:06 -08:00
Abtin Keshavarzian d7e9e5db31 [ip6] fix the fragmentation header check (#4445) 2020-01-06 08:28:50 -08:00
Yakun Xu 809e7e641c [tlv] add AppendTo to resolve mutual dependency (#4438)
This commit adds AppendTo(Message) to Tlv, so that Message doesn't
depend on Tlv any more. This allows a concrete Tlv overriding its
serialization.
2020-01-06 08:23:15 -08:00
Diego Ismirlian 53e4bcbfee [platform/utils] RTT: remove non-functional config of Up Buffer's size (#4436)
And document how to configure it if needed.
2020-01-06 08:19:22 -08:00
Jiacheng Guo 90eda6ef6b [mle] fix build error caused by GetParent return type change (#4437)
The GetParent return type was updated in 1996d42.
2020-01-06 08:16:58 -08:00
Jonathan Hui 5b0af03afb [dataset] check if dataset is present in otDatasetIsCommissioned (#4426)
otDatasetIsCommissioned API first reads out the Active Dataset from
settings (i.e. non-volatile storage). However, the existing
implementation does not check if the Active Dataset is actually
present, as indicated by OT_ERROR_NOT_FOUND.

This commit adds a necessary check and returns false if the Active
Dataset is not present.
2019-12-23 10:25:39 -08:00
Jonathan Hui 4fe0e718d5 [network-data] support registration on child devices (#4425)
A device's request to register network data information is triggered
by a call to NetworkData::Local::SendServerDataNotification().
However, the call was only made by devices operating in the router
or leader roles.

This commit moves the call so that network data registration is
triggered in the child role, in addition to the router and leader
roles.
2019-12-23 09:54:59 -08:00
Abtin Keshavarzian 9398c591bf [child-table] move StateFilter definition to Neighbor (#4419) 2019-12-19 13:27:15 -08:00
Abtin Keshavarzian 5fd1083d14 [topology] move IsStateValidOrAttaching to Neighbor (#4419) 2019-12-19 13:27:15 -08:00
Abtin Keshavarzian 636352431f [data-poll-sender] add GetParent() (#4419)
This commit changes the `Mle::GetParentCandidate()` to return a
reference to the parent candidate and moves the selection logic
between parent or parent candidate when sending data polls to
`DataPollSender` from the newly added `GetParent()` method.
2019-12-19 13:27:15 -08:00
Abtin Keshavarzian 1996d42d9d [mle] update Mle::GetParent() to return reference (#4419) 2019-12-19 13:27:15 -08:00
Abtin Keshavarzian bf4c7370bf [mle] add Mle::IsAttaching() method (#4419) 2019-12-19 13:27:15 -08:00
Paweł Wańczyk 194ea70abb [mac] add retry flag support for direct messages (#4421) 2019-12-19 11:17:41 -08:00
Li Cao aec3e66e54 [network-diagnostic] remove useless include (#4422) 2019-12-19 09:55:39 -08:00
Jonathan Hui c740a053fd [travis] add build check with all features enabled (#4418) 2019-12-18 15:43:44 -08:00
Jonathan Hui 2f18984017 [ncp] only support MLE_STEERING_DATA_SET_OOB_ENABLE in FTD (#4418) 2019-12-18 15:43:44 -08:00
Jonathan Hui 7695a2e0e4 [config] rename INITIAL_LOG_LEVEL to LOG_LEVEL_INIT (#4418) 2019-12-18 15:43:44 -08:00
Jonathan Hui 37d136d0fb [config] rename ENABLE_DYNAMIC_LOG_LEVEL to LOG_LEVEL_DYNAMIC_ENABLE (#4418) 2019-12-18 15:43:44 -08:00
Jonathan Hui 2beb6778b7 [config] remove duplicate definitions (#4418)
- OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
- OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE
2019-12-18 15:43:44 -08:00
Jonathan Hui 2a9f1c76d1 [link-quality] remove ENABLE_TX_ERROR_RATE_TRACKING feature flag (#4417)
OPENTHREAD_CONFIG_ENABLE_TX_ERROR_RATE_TRACKING defaults to 1 and
there have not been any	known users setting the	feature flag to 0.
2019-12-18 10:24:13 -08:00
Paweł Wańczyk c646e6f57a [mac] TxRetry histogram and maximal TxRetry expiry counter added (#4382) 2019-12-18 10:23:43 -08:00
Zhanglong Xia ed34a53829 [posix-host] add spinel_interface to extend transport layers (#4385)
This commit abstracts the API between radio_spinel and hdlc_interface
into a common interface spinel_interface. Users can use this interface
to add new transport layers to send/receive spinel frames.
2019-12-17 22:44:14 -08:00
Yakun Xu 2327072563 [ncp] conform with c++11 constexpr and static_assert (#4416)
C++11 constexpr doesn't support local variables and loop. This commit
uses recursive way to assert handlers are sorted.

C++11 static_assert requires a message. This commit adds the missing
messages to static_assert calls.
2019-12-17 22:42:35 -08:00
kangping 420479d899 [script] fix linking clang-format-6.0 on Mac OS X (#4414) 2019-12-17 08:52:26 -08:00
Jing Ma e79bb5557e [thci] add configurable device connection type for OpenThread_WpanCtl (#4364) 2019-12-16 21:00:12 -08:00
Simon Lin b4f245b025 [logging] reduce otThreadErrorToString code size (#4412)
This commit reduces the code size of otThreadErrorToString by about
900 bytes.
2019-12-16 20:56:59 -08:00
Yakun Xu 47b4192503 [ncp] reduce size by searching property handlers (#4409)
The big `switch` generates a lot of code on some compilers. This
commit drops the switch way to find getters and setters, instead a
binary search is used to find property handlers. This requires all
handlers are defined in a sorted array.
2019-12-16 20:55:40 -08:00
Yakun Xu a9a7599130 [spinel] add missing name for radio caps (#4410) 2019-12-16 12:37:04 -08:00
Yakun Xu a1f7e43452 [posix-host] set logging level early (#4408)
This commit sets logging level just after parsing command line
arguments so that dying messages during initialization can be printed.
2019-12-16 12:35:55 -08:00
Jonathan Hui c3a3a0c424 [commissioner] use strnlen instead of strlen (#4404) 2019-12-16 09:04:09 -08:00
Jonathan Hui b8c3161281 [commissioner] add network name length check in GeneratePskc() (#4404) 2019-12-16 09:04:09 -08:00
Abtin Keshavarzian e8735f45f2 [spinel] remove unused type definition (spinel_cit_t) (#4402) 2019-12-16 09:03:48 -08:00
Abtin Keshavarzian b689510672 [spinel] relax spinel_mcu_power_state_to_cstr input to allow any uint8_t (#4402) 2019-12-16 09:03:48 -08:00
Abtin Keshavarzian bae83ddfbc [spinel] add spinel_command_t & spinel_capability_t types as uint32_t (#4402) 2019-12-16 09:03:48 -08:00
Abtin Keshavarzian 943715c464 [spinel] define spinel_prop_key_t and spinel_status_t as uint32_t (#4402)
This commit defines `spinel_prop_key_t` and `spinel_status_t` as
`uint32_t` instead of `enum` value. This allows these types to
take values not included in `enum` (e.g., vendor or experimental
values) and addresses "out-of-range enumeration value" compiler
warnings.
2019-12-16 09:03:48 -08:00
Jonathan Hui f0a753c0a9 [ip6] replace IpProto type with uint8_t (#4403)
To avoid operating on unspecified values.
2019-12-13 17:21:01 -08:00
Jonathan Hui 04bec267e4 [network-diagnostic] avoid reference binding to null pointer (#4401) 2019-12-13 17:20:31 -08:00
Jonathan Hui f49d8b7b1d [mle] set appropriate Response TLV length in SendChildUpdateResponse (#4400) 2019-12-13 17:20:01 -08:00
Jonathan Hui dff1694fe1 [dns-client] add const to address pointer (#4399)
- Also change CLI implementation to avoid reference binding to null pointer.
2019-12-13 17:19:34 -08:00
Jonathan Hui 1ea4ed3eab [mle] add error logs to message handlers (#4398) 2019-12-13 17:18:16 -08:00
Jonathan Hui 36aebfae2a [logging] remove otLogInfoCoapErr (#4398) 2019-12-13 17:18:16 -08:00
Jonathan Hui 88b2fa6fbb [logging] remove otLogWarnMleErr (#4398) 2019-12-13 17:18:16 -08:00
Jonathan Hui 235d440e5d [logging] remove unused otLog*Err macros (#4398) 2019-12-13 17:18:16 -08:00
Zhanglong Xia 57b0f533bb [posix-host] update the function IsSafeToHandleNow() to avoid re-entrant issue (#4407)
mWaitingKey != SPINEL_PROP_LAST_STATUS means the NCP is waiting for a
spinel response from RCP. When mWaitingKey is set to
SPINEL_PROP_LAST_STATUS and HdlcInterface receives a ChildIdResponse
message from RCP,HdlcInterface calls the function Decode() to decode
the received HDLC frame. Then the decoded spinel frame is sent to
RadioSpinel module. Because the function IsSafeToHandleNow() returns
true now, the RadioSpinel sends the received ChildIdResponse frame to
up layer immediately. Then the MLE layer calls the function
otPlatRadioSetShortAddress() to set short address. The function
otPlatRadioSetShortAddress() sends spinel frame MAC_15_4_SADDR to RCP
and waits for the spinel response. When the response frame is
received, the HdlcInterface calls the function Decode() again, the
function Decode() uses previous calculated FCS value to calculate the
current received HDLC frame. The wrong FCS value caused the parsing
error for the received response frame.
2019-12-13 12:05:52 -08:00
Abtin Keshavarzian ef7a230c31 [travis] check vendor ncp hook example build under posix (#4405) 2019-12-13 09:14:51 -08:00
Abtin Keshavarzian 71dc756286 [ncp-vendor-hook] update example to show how to subclass (#4405) 2019-12-13 09:14:51 -08:00
Abtin Keshavarzian 36ad76e53d [ncp-vendor-hook] fix example code to use new NcpBase method (#4405) 2019-12-13 09:14:51 -08:00
Łukasz Duda 295ce1125e [diag] add radio state command (#4394) 2019-12-13 08:53:46 -08:00
Zhanglong Xia 7f61a9ee15 [posix-host] parse all parameters to a structure (#4386)
This commit parses all parameters to a structure and puts all
parameters parsing code in the function ParseArg(). It makes us easier
to add new parameters to posix host.
2019-12-13 08:47:45 -08:00
Abtin Keshavarzian ab89f40385 [unit-test] add test covering netif multicast address methods (#4388) 2019-12-12 08:56:08 -08:00
Abtin Keshavarzian 9c69030ae4 [netif] allow addition of external multicast addresses in any state (#4388)
This commit updates the Netif's handling of multicast addresses to
allow user to subscribe to (or unsubscribe from) an external multicast
address in any state. This aligns the behavior of external multicast
addresses with how external unicast addresses are handled (user can
already add/remove unicast addresses in any state).

This commit also adds checks to ensure user cannot subscribe to fixed
multicast addresses (e.g., link-local all nodes, realm-local all
routers, etc.) using `SubscribeExternalMulticast()`.

This commit also updates the implementation of methods dealing with
fixed multicast addresses to use the newly added `LinkedList` methods.
2019-12-12 08:56:08 -08:00
Abtin Keshavarzian 802c9dfcbc [linked-list] add Find() and GetTail() methods (#4388)
The `LinkedList::Find()` method searches for a given entry in the
linked list and if found returns a pointer to the previous entry
behind it. The `LinkedList::GetTail()` returns the tail of the list
(last entry in the list). This commit also updates the unit test
`test_linked_list` to verify the behavior of newly added methods.
2019-12-12 08:56:08 -08:00
Abtin Keshavarzian db1f7d2eac [toranj] add cmake option to build script (#4374)
This commit adds a `cmake` option to the `build.sh` to configure and
build OpenThread NCP/CLI for FTD/MTD/RCP modes using cmake/ninja.
2019-12-11 09:26:32 -08:00
Abtin Keshavarzian c75533fd15 [cmake] add OT_CONFIG to specify project core config header file (#4374)
This commit adds new parameter `OT_CONFIG` to main `CMakeLists.txt`
file. This parameter allows users to specify a project-specific core
config header file (mapped to `OPENTHREAD_PROJECT_CORE_CONFIG_FILE`)
during build configuration.

The default value for this parameter is "none". When not specified
(value is "none"), a platform cmake file may choose to change
`OT_COFNIG` variable to provide its own core config header file. This
commit updates platform 'posix' and 'cc2548' cmake files to provide
platform specific header files when `OT_CONFIG` is not specified by
user.
2019-12-11 09:26:32 -08:00
Abtin Keshavarzian 6c159e7de2 [code-utils] update comments (#4367) 2019-12-11 09:16:48 -08:00
Abtin Keshavarzian cd1804fa38 [unit-test] allow project to specify platform log config in unit tests (#4367)
This commit removes the hard-coded `OPENTHREAD_CONFIG_LOG_PLATFORM=0`
configuration in the unit test makefile. This allows the project build
to specify whether the platform logging should be enabled in unit
tests or not (and removes the complier warning for possible re-definition
of this configuration option).
2019-12-11 09:16:48 -08:00
Abtin Keshavarzian eaf2e7b9f7 [unit-test] add a common function to dump buffer content (#4367)
This commit updates `test_utils.hpp/cpp` to include a common helper
function `DumpBuffer` to print the content of a buffer (as hex and char string)
to screen. It also removes unused helper functions and use of STL header
files and types.
2019-12-11 09:16:48 -08:00
Abtin Keshavarzian 91e8903699 [unit-test] use OT_STATIC_ASSERT in unit tests (#4367)
This commit removes `CompileTimeAssert` (which was an empty macro).
 Instead `OT_STATIC_ASSERT` is used in `test_toolchain.cpp`.
2019-12-11 09:16:48 -08:00
Abtin Keshavarzian 5be9084add [unit-test] remove Log() from test_utils.h (#4367) 2019-12-11 09:16:48 -08:00
Abtin Keshavarzian f10c6c36fd [unit-test] remove (unnecessary) ENABLE_TEST_MAIN definition (#4367) 2019-12-11 09:16:48 -08:00
Abtin Keshavarzian ab27fcd9e6 [unit-test] remove extra \n at end of error message (#4367)
This commit removes the extra `\n` at the end of error message strings
used in `VerifyOrQuit()` or `SuccessOrQuit()` macros in different unit
test modules. This help make the style (usage of macros) consistent
across all unit tests.
2019-12-11 09:16:48 -08:00
Abtin Keshavarzian 720e9130da [unit-test] update test_util SuccessOrQuit/VerifyOrQuit macros (#4367) 2019-12-11 09:16:48 -08:00
Jing Ma 554407d107 [harness-automation] support RF-shield test cases (#4231)
- RF-shield needed cases 6.3.2, 5.6.7, 9.2.9, 9.2.10 automation both
  on CV and IV testbed

- Added DUT2_DEVICE and SHIELD_GOLDEN_DEVICES in settings file which
  list the second DUT and golden devices in RF-box. The emulation of
  the required shielding/unshielding test environment is achieved by
  controlling the programmable RF-switch (example: Agilent 3499B + HP
  44476A microwave switch module) via scripts (configure
  SHIELD_CONTROLLER_TYPE and SHIELD_CONTROLLER_PARAMS in settings
  file) and final impacting the IN/OUT signal of the devices in the
  box.

- Added case_need_shield and device_order parameters in RF-shield
  needed case scripts for checking if test case needs to use RF-shield
  box and its device order on the Test Harness Testbed page.
2019-12-11 09:14:37 -08:00
Łukasz Duda 8a1992e2e4 [nrf52833] fix bootloader configuration (#4392) 2019-12-10 10:19:05 -08:00
Kamil Sroka 1d5497ef7f [nrf528xx] fix void * dereference (#4391) 2019-12-10 10:16:55 -08:00
Duda, Lukasz 232b73477a [nrf528xx] align SDK components to version 16.0 (#4390) 2019-12-10 10:16:46 -08:00
Duda, Lukasz a08a9ceee3 [nrf528xx] update nRF IEEE 802.15.4 Radio Driver to version 1.6.1 (#4390) 2019-12-10 10:16:33 -08:00
Abtin Keshavarzian a52d80e475 [mac] update/clean-up comments (#4384) 2019-12-10 09:03:57 -08:00
Abtin Keshavarzian ca16be06d5 [mac] simplify handling of Mac::Filter and fixed RSS (#4384) 2019-12-10 09:03:57 -08:00
Abtin Keshavarzian e67fd2c0bd [mac] use VerifyOrExit for simpler checks (#4384) 2019-12-10 09:03:57 -08:00
Abtin Keshavarzian 64f29fb29e [mac] simplify ProcessReceiveSecurity (#4384)
This method simplifies `Mac::ProcessReceiveSecurity()` method, by
initializing `error` as `OT_ERROR_SECURITY` and only setting it to
`OT_ERROR_NONE` after all checks are passed (allowing checks to use
`VerifyOrExit()` without updating of `error` variable).
2019-12-10 09:03:57 -08:00
Simon Lin 6275173bab [thci] fix wrong call to .lstrip('0x') (#4383)
Wpanctl THCI might return the wrong RLOC address when RLOC16 == 0 due
to incorrect call to .lstrip('0x').  We use .lstrip('0x') to strip
'0x' at the beginning of a hex string, however this is not correct
when the hex string is '0x0', because '0x0'.lstrip('0x') == ''

This commit fixes all incorrect calls to .lstrip('0x'). There are 3
different kinds of fix:

- s.lstrip('0x') replaced by self.__lstrip0x(s) (lstrip_0x is a
  correct implementation of stripping '0x' at the beginning of a
  string)

- hex(v).rstrip('L').lstrip('0x') replaced by '%x' % v

- hex(v).lstrip('0x').zfill(4) replaced by '%04x' % v
2019-12-10 08:56:52 -08:00
Rongli Sun eb2c2dfb26 [cli] extend ping to allow hoplimit configuration (#4370) 2019-12-10 08:51:26 -08:00
Rongli Sun b77c244290 [ip6] allow hoplimit 0 (#4370) 2019-12-10 08:51:26 -08:00
Piotr Szkotak 3244d7a644 [nrf528xx] change used FEM implementation from simple_gpio to three_pin_gpio (#4387) 2019-12-06 10:46:58 -08:00
Yakun Xu f7555a54f3 [posix-host] add cmake support (#4379) 2019-12-06 09:03:17 -08:00
Rongli Sun b4b0531433 [tests] replace get_addr_rloc() by get_rloc() (#4380) 2019-12-06 08:51:23 -08:00
Rongli Sun 76f847babc [tests] add ipv6 source selection test (#4380) 2019-12-06 08:51:23 -08:00
Abtin Keshavarzian bf4dae0c18 [settings] add Clear() method for all setting structures (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian b5846532fe [mac] use Mac::ResetCounters() (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 8297dd6634 [factory-diags] add Diags::Stats::Clear() method (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 4a9d80cef1 [coap-message] add HelpData::Clear() method (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 663b59eb57 [socket] add SockAddr::Clear() (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 57f5044c9a [key-manager] add Pskc::Clear() method (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 56d3a469b2 [mac-types] add Mac::ExtendedPanId::Clear() method (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 52a04dbed1 [mac-types] add Clear() and Fill() method to Mac::ExtAddress (#4315)
The `Clear()` method clears the address (set all bytes to zero),
where as the `Fill()` method fills all bytes with a given value.
2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 69d5e084e0 [ip6] use Ip6::Address::Clear() replacing memset to zero (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian f830a8b1ba [mle-tlvs] add LeaderDataTlv::Clear() (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian 173d545466 [netif] add Clear() to netif unicast/multicast address types (#4315) 2019-12-04 12:42:33 -08:00
Abtin Keshavarzian e17c82b0b9 [linked-list] adding LinkedList class (#4357)
This commit adds a linked list module which provides a template
implementation of a singly linked list. The new class is then used in
different core modules (netif (unicast/multicast addresses), UDP6
sockets/receiver, coap resources, etc). This commit also adds a
unit test `test_linked_list` for the linked list module.
2019-12-04 11:03:52 -08:00
Jonathan Hui 15e26f0e64 [examples] add stub for otPlatSettingsDeinit to settings_ram.c (#4378) 2019-12-04 08:54:13 -08:00
Jonathan Hui 4e73575703 [ip6] prefer RLOC source with RLOC dest in SelectSourceAddress() (#4377)
Prefer ML-EID for any mesh-local traffic that does not have RLOC
destination.

Credit to Rongli Sun <rongli@google.com> for identifying this issue.
2019-12-04 08:23:07 -08:00
Jonathan Hui b22f00aea9 [ip6] limit to source prefix length in SelectSourceAddress() (#4377)
RFC 6724 Section 2.2 states:

   We define the common prefix length CommonPrefixLen(S, D) of a source
   address S and a destination address D as the length of the longest
   prefix (looking at the most significant, or leftmost, bits) that the
   two addresses have in common, up to the length of S's prefix (i.e.,
   the portion of the address not including the interface ID).  For
   example, CommonPrefixLen(fe80::1, fe80::2) is 64.
2019-12-04 08:23:00 -08:00
Jonathan Hui d12246d2ee [ip6] reduce scope of local vars in SelectSourceAddress() (#4377) 2019-12-04 08:22:49 -08:00
Yakun Xu 0b49ea2b83 [posix-app] remove dependency on OPENTHREAD_TARGET_DEFINES (#4375) 2019-12-04 08:20:09 -08:00
Jonathan Hui 832944a94a [docs] update CLA text (#4373) 2019-12-04 03:57:41 +08:00
Rongli Sun 2b8586925d [mle] MTD prioritizes ML-EID registration (#4368)
This commit ensures that the important ML-EID would be the
first one in Address Registration TLV so that the parent
would always be able to store it.

(SPEC-899: A recipient MUST process address entries in an
Address Registration TLV sequentially from first entry to
last entry)
2019-12-04 02:50:55 +08:00
Zhanglong Xia 7fdd85b687 [posix-app] optimize the interface between radio_spinel and hdlc_interface (#4352)
This commit simplifies the API between RadioSpinel and HdlcInterface
to improve extensibility of the API so that we can easily add other
low layer interfaces to send/receive spinel frames later.

RadioSpinel is only responsible for encoding/decoding spinel
frames. Lower layer interface is only responsible for
sending/receiving spinel frames. Some lower layer interfaces can't
provide a file descriptor for RadioSpinel to wait for the file
descriptor to become writable, so this commit removes the
kStateTransmitPending state from RadioSpinel.c and directly calls the
function Request() to send frames in method RadioSpinel::Transmit().
2019-12-04 01:14:00 +08:00
Yakun Xu 4a4a1a349f [posix-app] add log level argument (#4336) 2019-12-04 00:54:27 +08:00
Jonathan Hui 2a94525196 [mle] change IsFullThreadDevice to IsRouterEligible where appropriate (#4363) 2019-12-03 09:28:35 +08:00
Jonathan Hui e2723f6c05 [mle] add return error to otThreadSetRouterEligible (#4363)
When trying to set router-eligible and the device is not capable of
becoming a router, return OT_ERROR_NOT_CAPABLE.
2019-12-03 09:28:35 +08:00
Jonathan Hui 27f5d9a06e [mle] rename RouterRoleEnabled to RouterEligible (#4363) 2019-12-03 09:28:35 +08:00
Jonathan Hui 7e6446b927 [mle] keep State Update Timer running on FTD (#4363)
The existing code did not keep the State Update timer running if the
device was not router-eligible. However, a Full End Device (FED) needs
to keep the State Update timer running to maintain its links to
neighboring routers.

This commit ensures that the State Update timer continues to run on
FTD devices, even if the device is operating as a FED. This commit
also removes some unncessary code to start the State Update timer if
the device switches from a FED to a REED.
2019-12-03 09:28:35 +08:00
Yakun Xu df5f46dfc0 [mac] fix typo in data poll sender (#4371) 2019-12-03 06:38:41 +08:00
Abtin Keshavarzian e4fe479baf [mac] scope timeIeOffset variable to block it is being used (#4369) 2019-12-03 06:38:02 +08:00
Abtin Keshavarzian bec7fb0563 [mac] remove unused method definition (#4369) 2019-12-03 06:38:02 +08:00
Kamil Sroka 2233ae150e [coap] fix response timeout for NON messages (#4372) 2019-12-03 00:58:18 +08:00
Piotr Koziar e5db31162d [nrf528xx] fix freertos mutex casting (#4366) 2019-12-03 00:44:50 +08:00
Kamil Sroka 045d4e05a3 [nrf528xx] remove unnecessary typedef from nrf-config.h (#4365) 2019-12-03 00:43:56 +08:00
Rongli Sun e860009914 [network-data] always support service registration at Leader (#4360)
A Leader should always be able to process service registration.

This commit:

- removes the OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE feature
  flag around code for handling service registrations by the leader.

- support service ALOC forwarding by all router-capable devices.

- adds ability for any device to read service information from the
  network data.
2019-12-03 00:42:46 +08:00
Jonathan Hui 2089716959 [mle] clean up MleRouter::HandleAdvertisement (#4338)
- Ensure there are no side effects if MLE frame counters have not yet
  been syncrhonzied.

- Do not remove stale neighbor until end of processing
  Advertisement. This allows for complete processing of	Advertisement
  if frame counters have already been established.
2019-12-03 00:34:51 +08:00
Jonathan Hui d28da9fad6 [mle] do not remove neighbors in MleRouter::HandleLinkRequest (#4338)
This allows the	device to retain the neighbor entry and	validate
incoming messages before a proper MLE Link Request/Accept exchange has
been completed.
2019-12-03 00:34:51 +08:00
Kamil Sroka 3161e9bac2 [nrf528xx] disable soft source match (#4354)
This causes source match implementation in both utils and platform
code, which may lead to erroneous behaviour if the wrong one is
included by the linker.
2019-11-28 02:07:25 +08:00
Jiacheng Guo 8158343004 [debug] override any existing assert definitions (#4329) 2019-11-27 10:26:20 +08:00
Yakun Xu af73358d3f [android] make Android.mk more extensible (#4359) 2019-11-27 08:18:49 +08:00
Piotr Koziar 3a1e5d145a [nrf528xx] fix unused sExtAddress when OPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT=0 (#4361) 2019-11-27 01:16:58 +08:00
Abtin Keshavarzian e04a999028 [radio] change SetCcaEnergyDetectThreshold() to pass by value (#4356) 2019-11-27 01:13:47 +08:00
Kamil Sroka 557c44dc6c [nrf52833] fix nrf52833-mbedtls-config.h location (#4355) 2019-11-27 01:12:26 +08:00
Abtin Keshavarzian 9c6b33b5f2 [code-utils] rename alignment macros to use "OT_" prefix (#4351) 2019-11-26 02:45:47 +08:00
Łukasz Duda f756953819 [nrf528xx] handle overrun error on high baudrates correctly (#4350) 2019-11-26 02:44:22 +08:00
Piotr Koziar 14e4538e5b [nrf528xx] add newline at the end of file (#4348) 2019-11-26 02:42:40 +08:00
Jonathan Hui f0bcd8a1ee [joiner] store network configuration using operational dataset (#4332)
This commit changes the Joiner::HandleJoinerEntrust implementation
to store Thread network configuration parameters in the Active
Operational Dataset. Using the operational dataset stores
configuration parameters in non-volatile memory.

This commit only utilizes Thread network parameters that are useful in
the Thread attach process. For example, parameters such as Extended
PAN ID, Mesh Local Prefix, and Active Timestamp are not useful during
the attach process.
2019-11-26 02:38:54 +08:00
Jonathan Hui 889584c42c [cmake] move generated header file to PROJECT_BINARY_DIR (#4112)
Credit to Robert Lubos for the suggestion.
2019-11-26 00:53:35 +08:00
Ciaran Woodward 11074f7829 [cmake] fix version code generation (#4112) 2019-11-26 00:53:35 +08:00
Ciaran Woodward 45ea461990 [cmake] fix map file generation for cc2538 (#4112) 2019-11-26 00:53:35 +08:00
Robert Lubos e745c94ca6 [cmake] fix external mbedTLS usage (#4112)
In order to use external mbedTLS correctly we need to translate CMake
OT_BUILTIN_MBEDTLS into OpenThread's
OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
2019-11-26 00:53:35 +08:00
Ciaran Woodward 96be52fd38 [cmake] add all important cflags in the toolchain file, remove platform.cmake (#4112)
This is important for allowing cmake to properly configure itself,
knowing what cflags will be passed. Also I removed all of the
public modifications of CMAKE_CXX_FLAGS, to better control where
the flags are actually applied.

The linker file is an exception to the toolchain file, as it
depends on symbols that are declared in the startup file
(startup-gcc.c for cc2538). Therefore it has been added as a
PUBLIC requirement for the cc2538 platform layer.
2019-11-26 00:53:35 +08:00
Ciaran Woodward ac903c3673 [cmake] add missing files (#4112) 2019-11-26 00:53:35 +08:00
Ciaran Woodward a51e501b6a [cmake] create functions.cmake file to abstract useful functions (#4112) 2019-11-26 00:53:35 +08:00
Ciaran Woodward 71b567c329 [cmake] remove unnecessary cmake step (#4112) 2019-11-26 00:53:35 +08:00
Ciaran Woodward e65880ecf3 [cmake] remove unnecessary cmake variable (#4112) 2019-11-26 00:53:35 +08:00
Ciaran Woodward 6a00ea0cdb [cmake] remove directory scoped add_definitions calls (#4112)
These won't work well if a parent project includes openthread as a
subproject, and aren't as well abstracted as the target-based
definitions.
2019-11-26 00:53:35 +08:00
Ciaran Woodward 6cfa2f9bec [cmake] replace dependance on env vars with CMake options (#4112)
Otherwise rebuilding will cause sporadic issues when the environment
variables don't match the initial values. CMake variables are
cached in the CMakeCache file in the build directory, and can be
modified using ccmake. Also this improves cross-platform behaviour
as windows doesn't handle environment variables in the same way
as a posix system does.
2019-11-26 00:53:35 +08:00
Ciaran Woodward 24bd599b45 [cmake] fix platform-utils for cmake (#4112)
platform-utils has a dependency on the core ot library, which was
causing the build to fail. I have resolved this by making
platform-utils an 'object library', which means the object files
will always be used by the linker, preventing the 'smart linker'
errors that occur with ld and cyclic dependencies.

I also provided a static (.a) implementation of the library in case
any non-cmake project wanted to consume the results (at which point
that project can deal with the dependency as it wishes).

So now it is up to the 'platform layer' to include the 'platform utils'
objects inside its own library if it requires them. I have implemented
this for the current cmake example platforms.
2019-11-26 00:53:35 +08:00
Jonathan Hui 3807daa68a [cmake] add initial travis checks (#4112) 2019-11-26 00:53:35 +08:00
Jonathan Hui b598fa337c [cmake] initial implementation (#4112) 2019-11-26 00:53:35 +08:00
Zhanglong Xia 501a190546 [posix-app] remove function "HdlcInterface::IsDecoding()" (#4340)
The function "RadioSpinel::IsSafeToHandleNow()" is finally called by the
function "HdlcInterface::Decode()". However, the variable "mIsDecoding"
is set to TRUE before calling "RadioSpinel::IsSafeToHandleNow()" in
function "HdlcInterface::Decode()". So the function "IsDecoding()"
always return TURE in function "RadioSpinel::IsSafeToHandleNow()". This
commit removes the function "IsDecoding()" to simplify the code.
2019-11-20 21:12:23 -08:00
paragdixit-g 1a501a1840 [build] add a gn based build and corresponding travis script (#4322)
The travis script ensures that build of an openthread-core build with gn
and ninja goes through.
2019-11-20 17:27:56 -08:00
Marven Gilhespie 1da4fdd703 [efr32] change to MG21 NVIC interrupt PRIGROUP_POSITION (#4345) 2019-11-20 10:53:40 -08:00
Abtin Keshavarzian 23e89196c0 [toolchain] remove unnecessary OT_TOOL_ALIGN (#4344) 2019-11-20 10:52:17 -08:00
Duda, Lukasz 4b422a33a0 [nrf528xx] ensure there is no radio pending events after diag is disabled (#4343) 2019-11-20 10:47:47 -08:00
Duda, Lukasz 205842d414 [diag] send frames only from the alarm handler in repeat mode (#4343) 2019-11-20 10:47:47 -08:00
Piotr Koziar 61088c7782 [cli] mac/mle counters reset (#4341)
* Add counters reset cli command
2019-11-19 18:35:06 -08:00
Abtin Keshavarzian ab3a1ef6d4 [logging] remove unused otPlatLogv (#4339) 2019-11-19 18:33:25 -08:00
Yakun Xu 9f2ff3bcbf [build] add flag to enable dynamic logging level (#4335) 2019-11-18 14:48:21 -08:00
Jonathan Hui 88ba64fd17 [travis] enable posix-app-ncp test (#4337) 2019-11-18 09:30:53 -08:00
Abtin Keshavarzian be28486fb7 [network-data] fix how the OnMeshPrefixConfig structs are compared (#4312)
This commit ensures the entire struct size is used when comparing
two `OnMeshPrefixConfig` (`otBorderRouterConfig`) instances from
`NetworkData::ContainsOnMeshPrefixes()` method.
2019-11-14 20:23:56 -08:00
Abtin Keshavarzian badae65876 [network-data] change iterator methods to use reference instead of pointer (#4312)
This commit contains t changes the methods in `NetworkData` class used
for iterating over on-mesh prefix, external router, etc (e.g.,
`GetNextOnMeshPrefix`()) to use reference input variables instead of
pointer type variables.
2019-11-14 20:23:56 -08:00
Rongli Sun b816319a28 [mle] fix unexpected data request (#4326)
This commit compares data version properly according to the device
mode (whether or not requiring full network data), thus avoiding
unexpected data request when receiving MLE advertisement.
2019-11-15 00:29:55 +01:00
Jonathan Hui 13d185bf01 [travis] add arm gcc 9 to build tests (#4323) 2019-11-15 00:29:06 +01:00
Jonathan Hui 9e9f506329 [examples] fix potential unaligned pointer value (#4323)
Fixes applied to cc1352, cc2650, and cc2652 platforms.
2019-11-15 00:29:06 +01:00
Duda, Lukasz 5af6b23e5f [nrf528xx] udpate SoftDevice version to 7.0.1 (#4324) 2019-11-14 20:31:00 +01:00
Duda, Lukasz ca7d0c1dec [nrf528xx] update nrf_802154_radio_driver to version 1.6.0 (#4324) 2019-11-14 20:31:00 +01:00
Duda, Lukasz e3737a915d [nrf528xx] update nrfx to version 1.8.0 (#4324) 2019-11-14 20:31:00 +01:00
Duda, Lukasz c97f545ded [nrf52833] add support for nRF52833 platform (#4324) 2019-11-14 20:31:00 +01:00
2063 changed files with 436242 additions and 59754 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
Standard: Cpp11
TabWidth: 4
UseTab: Never
...
+2 -1
View File
@@ -5,7 +5,8 @@ coverage:
ignore:
- "tests/*"
- "third_party/*"
- "third_party/**/*"
comment:
layout: "diff, flags, files"
after_n_builds: 16
+6 -11
View File
@@ -1,24 +1,19 @@
---
name: Bug report
about: Create a report to help us improve
---
**Describe the bug**
A clear and concise description of what the bug is.
**Describe the bug** A clear and concise description of what the bug is.
**To Reproduce** Information to reproduce the behavior, including:
**To Reproduce**
Information to reproduce the behavior, including:
1. Git commit id
2. IEEE 802.15.4 hardware platform
3. Build steps
4. Network topology
**Expected behavior**
A clear and concise description of what you expected to happen.
**Expected behavior** A clear and concise description of what you expected to happen.
**Console/log output**
If applicable, add console/log output to help explain your problem.
**Console/log output** If applicable, add console/log output to help explain your problem.
**Additional context**
Add any other context about the problem here.
**Additional context** Add any other context about the problem here.
+4 -9
View File
@@ -1,17 +1,12 @@
---
name: Feature request
about: Suggest an idea for this project
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is.
**Is your feature request related to a problem? Please describe.** A clear and concise description of what the problem is.
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe the solution you'd like** A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Describe alternatives you've considered** A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.
**Additional context** Add any other context or screenshots about the feature request here.
+267
View File
@@ -0,0 +1,267 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: Build
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
pretty:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
sudo apt-get autoremove
sudo apt-get --no-install-recommends install -y clang-tools clang-format-6.0 shellcheck
python3 -m pip install yapf==0.29.0
sudo snap install shfmt
- name: Check
run: |
script/make-pretty check
cmake-version:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo pip3 install --system -U cmake==3.10.3
cmake --version | grep 3.10.3
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
NODE_MODE=rcp ./script/test build
package:
name: package-${{ matrix.compiler }}
runs-on: ubuntu-18.04
strategy:
matrix:
include:
- compiler: gcc
compiler_c: gcc
compiler_cpp: g++
- compiler: clang
compiler_c: clang
compiler_cpp: clang++
env:
CC: ${{ matrix.compiler_c }}
CXX: ${{ matrix.compiler_cpp }}
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build libreadline-dev libncurses-dev
- name: Package
run: |
script/test package
scan-build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get remove -y clang-6.0 libclang-common-6.0-dev libclang1-6.0 libllvm6.0
sudo apt-get autoremove
sudo apt-get --no-install-recommends install -y clang-tools
- name: Run
run: |
script/check-scan-build
arm-gcc:
name: arm-gcc-${{ matrix.gcc_ver }}
runs-on: ubuntu-18.04
strategy:
matrix:
include:
- gcc_ver: 4
gcc_download_url: https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-4_9-2015q3
- gcc_ver: 5
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-5_4-2016q3
- gcc_ver: 6
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-6-2017-q2-update
- gcc_ver: 7
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-7-2018-q2-update
- gcc_ver: 9
gcc_download_url: https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
gcc_extract_dir: gcc-arm-none-eabi-9-2019-q4-major
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
cd /tmp
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y lib32z1 ninja-build
wget ${{ matrix.gcc_download_url }} -O gcc-arm.tar.bz2
tar xjf gcc-arm.tar.bz2
# required for jn5189 and k32w061
pip install pycryptodome
- name: Build
run: |
export PATH=/tmp/${{ matrix.gcc_extract_dir }}/bin:$PATH
script/check-arm-build
gcc:
name: gcc-${{ matrix.gcc_ver }}
runs-on: ubuntu-18.04
strategy:
matrix:
gcc_ver: [5, 6, 7, 8, 9]
env:
CC: gcc-${{ matrix.gcc_ver }}
CXX: g++-${{ matrix.gcc_ver }}
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y gcc-${{ matrix.gcc_ver }} g++-${{ matrix.gcc_ver }} ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
script/check-simulation-build
script/check-posix-build
clang:
name: clang-${{ matrix.clang_ver }}
runs-on: ubuntu-18.04
strategy:
matrix:
clang_ver: ["6.0", "7", "8", "9"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-${{ matrix.clang_ver }} clang++-${{ matrix.clang_ver }} ninja-build libreadline-dev libncurses-dev
- name: Build
run: |
script/check-simulation-build
script/check-posix-build
clang-m32:
name: clang-m32-${{ matrix.clang_ver }}
runs-on: ubuntu-18.04
strategy:
matrix:
clang_ver: ["6.0", "7", "8", "9"]
env:
CC: clang-${{ matrix.clang_ver }}
CXX: clang++-${{ matrix.clang_ver }}
CFLAGS: -m32 -Wconversion
CXXFLAGS: -m32 -Wconversion
LDFLAGS: -m32
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo dpkg --add-architecture i386
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-${{ matrix.clang_ver }} clang++-${{ matrix.clang_ver }} g++-multilib ninja-build
sudo apt-get --no-install-recommends install -y libreadline-dev:i386 libncurses-dev:i386
- name: Build
run: |
script/check-simulation-build
script/check-posix-build
gn:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y ninja-build
cd /tmp
wget -O gn.zip https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest
unzip -o gn.zip
chmod a+x gn && mkdir -p bin && mv -f gn bin/
- name: Build
run: |
export PATH=/tmp/bin:$PATH
script/check-gn-build
macos-clang:
runs-on: macos-10.15
env:
CC: clang
CXX: clang++
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
brew install automake ninja llvm
- name: Build
run: |
script/check-posix-build
script/check-simulation-build
macos-gcc:
runs-on: macos-10.15
env:
CC: gcc
CXX: g++
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
brew install automake ninja
- name: Build
run: |
script/check-posix-build
script/check-simulation-build
android:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Build
run: |
docker run --rm -v $PWD:/build/openthread openthread/android-trusty /build/openthread/script/check-android-build
+100
View File
@@ -0,0 +1,100 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: Docker
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
buildx:
name: buildx-${{ matrix.docker_name }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- docker_name: environment
- docker_name: codelab_otsim
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Docker Buildx
uses: crazy-max/ghaction-docker-buildx@v3
- name: Prepare
id: prepare
run: |
DOCKER_IMAGE=openthread/${{ matrix.docker_name }}
DOCKER_FILE=etc/docker/${{ matrix.docker_name }}/Dockerfile
DOCKER_PLATFORMS=linux/amd64
VERSION=latest
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
echo ::set-output name=docker_image::${DOCKER_IMAGE}
echo ::set-output name=version::${VERSION}
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
--build-arg VERSION=${VERSION} \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg VCS_REF=${GITHUB_SHA::8} \
${TAGS} --file ${DOCKER_FILE} .
- name: Docker Buildx (build)
run: |
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
- name: Docker Login
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin
- name: Docker Buildx (push)
if: success() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
run: |
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
- name: Docker Check Manifest
if: always() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
run: |
docker run --rm mplatform/mquery ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}
- name: Clear
if: always() && github.repository == 'openthread/openthread' && github.event_name != 'pull_request'
run: |
rm -f ${HOME}/.docker/config.json
+51
View File
@@ -0,0 +1,51 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: CIFuzz
on: [pull_request]
jobs:
Fuzzing:
runs-on: ubuntu-latest
steps:
- name: Build Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master
with:
oss-fuzz-project-name: 'openthread'
dry-run: false
- name: Run Fuzzers
uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
with:
oss-fuzz-project-name: 'openthread'
fuzz-seconds: 1800
dry-run: false
- name: Upload Crash
uses: actions/upload-artifact@v1
if: failure()
with:
name: artifacts
path: ./out/artifacts
+175
View File
@@ -0,0 +1,175 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: POSIX
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
posix-cli:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
PYTHONUNBUFFERED: 1
READLINE: readline
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
VIRTUAL_TIME_UART: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y libreadline6-dev python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
make -f src/posix/Makefile-posix
- name: Run
run: |
VERBOSE=1 OT_CLI_PATH="$(pwd)/$(ls output/posix/*/bin/ot-cli) -v" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-rcp)" make -f src/posix/Makefile-posix check
- name: Codecov
uses: codecov/codecov-action@v1
posix-ncp:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
NODE_TYPE: ncp-sim
PYTHONUNBUFFERED: 1
READLINE: readline
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
VIRTUAL_TIME_UART: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y libreadline6-dev python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
sudo python3 -m pip install git+https://github.com/openthread/pyspinel
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
make -f src/posix/Makefile-posix
- name: Run
run: |
VERBOSE=1 OT_NCP_PATH="$(pwd)/$(ls output/posix/*/bin/ot-ncp)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-rcp)" make -f src/posix/Makefile-posix check
- name: Codecov
uses: codecov/codecov-action@v1
posix-ncp-rcp-migrate:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y expect
- name: Build
run: |
./bootstrap
script/check-ncp-rcp-migrate build
- name: Run
run: |
script/check-ncp-rcp-migrate check
- name: Codecov
uses: codecov/codecov-action@v1
posix-pty:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y socat expect
cd /tmp
wget https://github.com/obgm/libcoap/archive/bsd-licensed.tar.gz
tar xvf bsd-licensed.tar.gz
cd libcoap-bsd-licensed
./autogen.sh
./configure --prefix= --exec-prefix=/usr --with-boost=internal --disable-tests --disable-documentation
make -j2
sudo make install
- name: Build
run: |
./bootstrap
script/check-posix-pty build
- name: Run
run: |
script/check-posix-pty check
- name: Codecov
uses: codecov/codecov-action@v1
posix-pty-daemon:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
DAEMON: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y socat expect
cd /tmp
wget https://github.com/obgm/libcoap/archive/bsd-licensed.tar.gz
tar xvf bsd-licensed.tar.gz
cd libcoap-bsd-licensed
./autogen.sh
./configure --prefix= --exec-prefix=/usr --with-boost=internal --disable-tests --disable-documentation
make -j2
sudo make install
- name: Build
run: |
./bootstrap
script/check-posix-pty build
- name: Run
run: |
script/check-posix-pty check
- name: Codecov
uses: codecov/codecov-action@v1
+91
View File
@@ -0,0 +1,91 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: Simulation 1.2
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
thread-1-2:
name: thread-1-2-${{ matrix.compiler.c }}-${{ matrix.arch }}
runs-on: ubuntu-18.04
env:
CFLAGS: -${{ matrix.arch }}
CXXFLAGS: -${{ matrix.arch }}
LDFLAGS: -${{ matrix.arch }}
COVERAGE: 1
THREAD_VERSION: 1.2
VIRTUAL_TIME: 1
CC: ${{ matrix.compiler.c }}
CXX: ${{ matrix.compiler.cxx }}
strategy:
matrix:
compiler: [{c: "gcc", cxx: "g++"}, { c: "clang", cxx: "clang++"}]
arch: ["m32", "m64"]
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib ninja-build python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
./script/test build
- name: Run
run: |
./script/test unit
./script/test cert_suite tests/scripts/thread-cert/v1_2_*
- name: Keep-1-2-only
run: |
./script/test tar 1.1
./script/test tar 1.2-bbr
- name: Codecov
uses: codecov/codecov-action@v1
- name: Keep-1-2-bbr-only
run: |
./script/test tar 1.2
./script/test untar 1.2-bbr
- name: Codecov
uses: codecov/codecov-action@v1
- name: Keep-1-1-only
run: |
./script/test tar 1.2-bbr
./script/test untar 1.1
- name: Codecov
uses: codecov/codecov-action@v1
+347
View File
@@ -0,0 +1,347 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: Simulation
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
distcheck:
runs-on: ubuntu-18.04
env:
CC: clang
CXX: clang++
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y llvm-runtime python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Run
run: |
export ASAN_SYMBOLIZER_PATH=`which llvm-symbolizer`
export ASAN_OPTIONS=symbolize=1
export DISTCHECK_CONFIGURE_FLAGS= CPPFLAGS=-DOPENTHREAD_SIMULATION_VIRTUAL_TIME=1
./bootstrap
make -f examples/Makefile-simulation distcheck
cli-ftd-otns:
runs-on: ubuntu-18.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: '1.13'
- name: Set up Python 3.6
uses: actions/setup-python@v1
with:
python-version: 3.6
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib
./bootstrap
- name: Run OTNS Tests
run: |
git clone https://github.com/openthread/ot-ns.git --depth 1 --branch master ~/otns
export OT_DIR=$PWD
cd ~/otns
./script/test py-unittests py-examples
- name: Codecov
uses: codecov/codecov-action@v1
packet-verification:
runs-on: ubuntu-18.04
env:
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
PACKET_VERIFICATION: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel ninja-build
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./script/test build
- name: Run
run: |
for i in {1..10}
do
./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py
done
- name: Codecov
uses: codecov/codecov-action@v1
cli-ftd:
runs-on: ubuntu-18.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- name: Codecov
uses: codecov/codecov-action@v1
cli-mtd:
runs-on: ubuntu-18.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
REFERENCE_DEVICE: 1
USE_MTD: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- name: Codecov
uses: codecov/codecov-action@v1
cli-time-sync:
runs-on: ubuntu-18.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
REFERENCE_DEVICE: 1
TIME_SYNC: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- name: Codecov
uses: codecov/codecov-action@v1
expects:
runs-on: ubuntu-18.04
env:
CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
OT_OPTIONS=-DOT_READLINE=OFF sudo apt-get --no-install-recommends install -y expect ninja-build
- name: Run
run: |
OT_OPTIONS=-DOT_TIME_SYNC=ON VIRTUAL_TIME=0 ./script/test build expect
- name: Codecov
uses: codecov/codecov-action@v1
- name: Run RCP Mode
run: |
OT_OPTIONS=-DOT_READLINE=OFF VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect
- name: Codecov
uses: codecov/codecov-action@v1
- name: Run TUN Mode
run: |
sudo apt-get install --no-install-recommends -y dnsmasq bind9-host ntp
sudo systemctl start dnsmasq ntp
host ipv6.google.com 127.0.0.1
echo 'listen-address=::1' | sudo tee /etc/dnsmasq.conf
echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6
sudo systemctl restart dnsmasq
host ipv6.google.com ::1
OT_OPTIONS=-DOT_READLINE=OFF OT_NATIVE_IP=1 VIRTUAL_TIME=0 NODE_MODE=rcp ./script/test clean build expect
- name: Codecov
uses: codecov/codecov-action@v1
external-commissioner:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/*
sudo apt-get install avahi-daemon avahi-utils -y
git clone https://github.com/openthread/ot-commissioner.git /tmp/ot-commissioner --depth 1 --branch master
- name: Build
run: |
cd /tmp/ot-commissioner
script/bootstrap.sh
cmake -GNinja \
-DCMAKE_CXX_STANDARD=11 \
-DCMAKE_CXX_STANDARD_REQUIRED=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DOT_COMM_COVERAGE=ON \
-DOT_COMM_CCM=OFF \
-S . -B build
cmake --build build
sudo cmake --install build
- name: Run
run: |
export OT_COMM_OPENTHREAD="$(pwd)"
cd /tmp/ot-commissioner/tests/integration
./bootstrap.sh
./run_tests.sh
- name: Codecov
uses: codecov/codecov-action@v1
multiple-instance:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
MULTIPLE_INSTANCE: 1
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- name: Codecov
uses: codecov/codecov-action@v1
ncp-gcc-m32:
runs-on: ubuntu-18.04
env:
CFLAGS: -m32
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
NODE_TYPE: ncp-sim
PYTHONUNBUFFERED: 1
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
sudo python3 -m pip install git+https://github.com/openthread/pyspinel
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- name: Codecov
uses: codecov/codecov-action@v1
ncp-clang:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
NODE_TYPE: ncp-sim
PYTHONUNBUFFERED: 1
REFERENCE_DEVICE: 1
VIRTUAL_TIME: 1
CC: clang
CXX: clang++
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
sudo python3 -m pip install git+https://github.com/openthread/pyspinel
- name: Build
run: |
./bootstrap
make -f examples/Makefile-simulation
- name: Run
run: |
VERBOSE=1 make -f examples/Makefile-simulation check
- name: Codecov
uses: codecov/codecov-action@v1
+58
View File
@@ -0,0 +1,58 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: Size
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
size-report:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Bootstrap
if: "github.event_name == 'push'"
run: |
python3 -m pip install --upgrade setuptools wheel
python3 -m pip install mdv
- name: Run
env:
OT_BASE_BRANCH: "${{ github.base_ref }}"
SIZE_REPORT_URL: "https://openthread-size-report.glitch.me/size-report/1354027"
run: |
export PATH=$PATH:$HOME/.local/bin
./script/check-size
+98
View File
@@ -0,0 +1,98 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: Toranj
on: [push, pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
toranj-ncp:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev
sudo apt-get --no-install-recommends install -y autoconf-archive
sudo apt-get --no-install-recommends install -y bsdtar
sudo apt-get --no-install-recommends install -y libtool
sudo apt-get --no-install-recommends install -y libglib2.0-dev
sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev
git clone --depth=1 --branch=master https://github.com/openthread/wpantund.git
cd wpantund
./bootstrap.sh
./configure
sudo make -j2
sudo make install
- name: Build & Run
run: |
top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh
- name: Codecov
uses: codecov/codecov-action@v1
toranj-rcp:
runs-on: ubuntu-18.04
env:
COVERAGE: 1
TORANJ_POSIX_RCP_MODEL: 1
steps:
- uses: actions/checkout@v2
- name: Bootstrap
run: |
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y dbus libdbus-1-dev
sudo apt-get --no-install-recommends install -y autoconf-archive
sudo apt-get --no-install-recommends install -y bsdtar
sudo apt-get --no-install-recommends install -y libtool
sudo apt-get --no-install-recommends install -y libglib2.0-dev
sudo apt-get --no-install-recommends install -y libboost-dev libboost-signals-dev
git clone --depth=1 --branch=master https://github.com/openthread/wpantund.git
cd wpantund
./bootstrap.sh
./configure
sudo make -j2
sudo make install
- name: Build & Run
run: |
top_builddir=$(pwd)/build/toranj ./tests/toranj/start.sh
- name: Codecov
uses: codecov/codecov-action@v1
+48
View File
@@ -0,0 +1,48 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
name: API Version
on: [pull_request]
jobs:
cancel-previous-runs:
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@master
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
if: "github.ref != 'refs/heads/master'"
api-version:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Check
run: |
script/check-api-version
+9 -2
View File
@@ -8,10 +8,14 @@
*.o
*.lo
*.la
*.ninja*
*.opendb
*.orig
*.pyc
*.suo
*.swn
*.swo
*.swp
*.trs
*.user
*.bak
@@ -25,13 +29,15 @@
aclocal.m4
autom4te.cache
build
CMakeCache.txt
CMakeFiles
cmake_install.cmake
configure
config.log
config.status
doc/Doxyfile
doc/html
etc/visual-studio/BundleArtifacts
etc/visual-studio/Generated Files
etc/cmake/openthread-config-generic.h
include/openthread-config.h
include/openthread-config.h.in
include/openthread-config-generic.h
@@ -51,3 +57,4 @@ third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltsugar.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/ltversion.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/m4/lt~obsolete.m4
third_party/nlbuild-autotools/repo/third_party/autoconf/missing
/tmp/
+3
View File
@@ -0,0 +1,3 @@
buildconfig = "//third_party/build_gn/BUILDCONFIG.gn"
check_system_includes = true
+7
View File
@@ -0,0 +1,7 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"proseWrap": "never"
}
-190
View File
@@ -1,190 +0,0 @@
#
# Copyright (c) 2016, The OpenThread Authors.
# 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.
#
language: python
python: "3.6"
sudo: required
dist: bionic
before_install:
- travis_retry .travis/before_install.sh
before_script:
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
fi
after_success:
- .travis/after_success.sh
stages:
- lint
- test
jobs:
include:
- env: BUILD_TARGET="posix-app-cli" VERBOSE=1 VIRTUAL_TIME=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="posix-app-pty" VERBOSE=1 COVERAGE=1
os: linux
compiler: clang
script: .travis/script.sh
- env: BUILD_TARGET="posix-app-pty" DAEMON=1 VERBOSE=1 COVERAGE=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="android-build" VERBOSE=1
os: linux
dist: trusty
python: "2.7" # The old Android build system only supports python2
script: .travis/script.sh
- env: BUILD_TARGET="posix-distcheck" VERBOSE=1 VIRTUAL_TIME=1
os: linux
compiler: clang
script: .travis/script.sh
- env: BUILD_TARGET="posix-32-bit" VERBOSE=1 VIRTUAL_TIME=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="posix-32-bit" VERBOSE=1 VIRTUAL_TIME=1 TIME_SYNC=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="posix-ncp" VERBOSE=1 VIRTUAL_TIME=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="posix-mtd" VERBOSE=1 VIRTUAL_TIME=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="scan-build"
os: linux
compiler: clang
script: .travis/script.sh
- env: BUILD_TARGET="arm-gcc-4"
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="arm-gcc-5"
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="arm-gcc-6"
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="arm-gcc-7"
os: linux
compiler: gcc
script: .travis/script.sh
# Disable Arm GCC 8 until slow compile bug is fixed:
# https://github.com/openthread/openthread/issues/4053
# - env: BUILD_TARGET="arm-gcc-8"
# os: linux
# compiler: gcc
# script: .travis/script.sh
- env: BUILD_TARGET="posix" CC="gcc-5" CXX="g++-5"
os: linux
compiler: gcc
addons:
apt:
packages:
- gcc-5
- g++-5
script: .travis/script.sh
- env: BUILD_TARGET="posix" CC="gcc-6" CXX="g++-6"
os: linux
compiler: gcc
addons:
apt:
packages:
- gcc-6
- g++-6
script: .travis/script.sh
- env: BUILD_TARGET="posix" CC="gcc-7" CXX="g++-7"
os: linux
compiler: gcc
addons:
apt:
packages:
- gcc-7
- g++-7
script: .travis/script.sh
- env: BUILD_TARGET="posix" CC="gcc-8" CXX="g++-8"
os: linux
compiler: gcc
addons:
apt:
packages:
- gcc-8
- g++-8
script: .travis/script.sh
- env: BUILD_TARGET="posix" CC="gcc-9" CXX="g++-9"
os: linux
compiler: gcc
addons:
apt:
sources:
- sourceline: "ppa:ubuntu-toolchain-r/test"
packages:
- gcc-9
- g++-9
script: .travis/script.sh
- env: BUILD_TARGET="posix-ncp-spi" VERBOSE=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="toranj-test-framework" VERBOSE=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="toranj-test-framework" VERBOSE=1 TORANJ_POSIX_APP_RCP_MODEL=1
os: linux
compiler: gcc
script: .travis/script.sh
- env: BUILD_TARGET="osx" VERBOSE=1
os: osx
language: generic
script: .travis/script.sh
- stage: lint
name: "Pretty Check"
os: linux
addons:
apt:
packages:
- clang-format-6.0
script: .travis/check-pretty
- env:
name: "Size Report"
os: linux
script: .travis/check-size
if: type = pull_request
-147
View File
@@ -1,147 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2016, The OpenThread Authors.
# 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.
#
[ -n "$BUILD_TARGET" ] || exit 0
die() {
echo " *** ERROR: " $*
exit 1
}
set -x
cd /tmp || die
[ $TRAVIS_OS_NAME != linux ] || {
(cd /etc/apt/sources.list.d && sudo rm -rf cassandra.list* couchdb.list* mongodb-3.4.list* rabbitmq_rabbitmq-server.list* chris-lea-redis-server.list* github_git-lfs.list* pgdg.list)
sudo apt-get update || die
[ $BUILD_TARGET != posix-distcheck -a $BUILD_TARGET != posix-32-bit -a $BUILD_TARGET != posix-app-cli -a $BUILD_TARGET != posix-mtd -a $BUILD_TARGET != posix-ncp -a $BUILD_TARGET != posix-app-ncp ] || {
pip install --upgrade pip || die
pip install -r $TRAVIS_BUILD_DIR/tests/scripts/thread-cert/requirements.txt || die
[ $BUILD_TARGET != posix-ncp -a $BUILD_TARGET != posix-app-ncp ] || {
# Packages used by ncp tools.
pip install git+https://github.com/openthread/pyspinel || die
}
}
[ $BUILD_TARGET != android-build ] || {
sudo apt-get install -y bison gcc-multilib g++-multilib
(
cd $HOME
wget https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip
unzip android-ndk-r17c-linux-x86_64.zip > /dev/null
mv android-ndk-r17c ndk-bundle
) || die
}
[ $BUILD_TARGET != posix-app-pty ] || {
sudo apt-get install socat expect || die
JOBS=$(getconf _NPROCESSORS_ONLN)
(
LIBCOAP_TMPDIR=/tmp/libcoap
mkdir $LIBCOAP_TMPDIR
cd $LIBCOAP_TMPDIR
wget https://github.com/obgm/libcoap/archive/bsd-licensed.tar.gz
tar xvf bsd-licensed.tar.gz
cd libcoap-bsd-licensed
./autogen.sh
./configure --prefix= --exec-prefix=/usr --with-boost=internal --disable-tests --disable-documentation
make -j $JOBS
sudo make install
) || die
}
[ $BUILD_TARGET != arm-gcc-4 ] || {
sudo apt-get install lib32z1 || die
wget https://launchpad.net/gcc-arm-embedded/4.9/4.9-2015-q3-update/+download/gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 || die
tar xjf gcc-arm-none-eabi-4_9-2015q3-20150921-linux.tar.bz2 || die
export PATH=/tmp/gcc-arm-none-eabi-4_9-2015q3/bin:$PATH || die
arm-none-eabi-gcc --version || die
}
[ $BUILD_TARGET != arm-gcc-5 ] || {
sudo apt-get install lib32z1 || die
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/5_4-2016q3/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 || die
tar xjf gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2 || die
export PATH=/tmp/gcc-arm-none-eabi-5_4-2016q3/bin:$PATH || die
arm-none-eabi-gcc --version || die
}
[ $BUILD_TARGET != arm-gcc-6 ] || {
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/6-2017q2/gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 || die
tar xjf gcc-arm-none-eabi-6-2017-q2-update-linux.tar.bz2 || die
export PATH=/tmp/gcc-arm-none-eabi-6-2017-q2-update/bin:$PATH || die
arm-none-eabi-gcc --version || die
}
[ $BUILD_TARGET != arm-gcc-7 ] || {
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2 || die
tar xjf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2 || die
export PATH=/tmp/gcc-arm-none-eabi-7-2018-q2-update/bin:$PATH || die
arm-none-eabi-gcc --version || die
}
[ $BUILD_TARGET != arm-gcc-8 ] || {
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/8-2018q4/gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2 || die
tar xjf gcc-arm-none-eabi-8-2018-q4-major-linux.tar.bz2 || die
export PATH=/tmp/gcc-arm-none-eabi-8-2018-q4-major/bin:$PATH || die
arm-none-eabi-gcc --version || die
}
[ $BUILD_TARGET != posix-32-bit -a $BUILD_TARGET != posix-mtd ] || {
sudo apt-get install g++-multilib || die
}
[ $BUILD_TARGET != posix-distcheck ] || {
sudo apt-get install llvm-runtime || die
}
[ $BUILD_TARGET != toranj-test-framework ] || {
# packages for wpantund
sudo apt-get install dbus || die
sudo apt-get install gcc g++ libdbus-1-dev || die
sudo apt-get install autoconf-archive || die
sudo apt-get install bsdtar || die
sudo apt-get install libtool || die
sudo apt-get install libglib2.0-dev || die
sudo apt-get install libboost-dev || die
sudo apt-get install libboost-signals-dev || die
# clone and build wpantund
git clone --depth=1 --branch=master https://github.com/openthread/wpantund.git
cd wpantund || die
./bootstrap.sh || die
./configure || die
sudo make -j 8 || die
sudo make install || die
cd .. || die
}
}
-109
View File
@@ -1,109 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2018, The OpenThread Authors.
# 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.
#
#
# Run this command on parent directory of openthread
#
set -e
set -x
#######################################
# Prepare android build system
# Globals:
# None
# Arguments:
# None
# Returns:
# None
#######################################
android_prepare_build_system()
{
# Android build system
(mkdir build && cd build && git init && git pull --depth 1 https://android.googlesource.com/platform/build 2db32730e79cafcf13e1f898a7bee7f82b0449d6)
ln -s build/core/main.mk Makefile
# Workarounds for java checking
export ANDROID_JAVA_HOME=/usr/lib/jvm/java-8-oracle
mkdir bin
cat > bin/java <<EOF
#!/bin/sh
echo java version \"1.6\"
EOF
cat > bin/javac <<EOF
echo javac \"1.6\"
EOF
chmod a+x bin/java bin/javac
export PATH=$(pwd)/bin:$PATH
# Files for building ndk
mkdir -p system/core/include/arch/linux-arm
touch system/core/include/arch/linux-arm/AndroidConfig.h
mkdir -p system/core/include/arch/linux-x86
touch system/core/include/arch/linux-x86/AndroidConfig.h
ANDROID_NDK_PATH=$HOME/ndk-bundle
mkdir -p bionic/libc/
cp -r $ANDROID_NDK_PATH/sysroot/usr/include bionic/libc/include
mv bionic/libc/include/arm-linux-androideabi/asm bionic/libc/include/asm
mkdir -p out/target/product/generic/obj/
cp -r $ANDROID_NDK_PATH/platforms/android-27/arch-arm/usr/lib out/target/product/generic/obj/
mkdir -p bionic/libstdc++
cp -r $ANDROID_NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/include bionic/libstdc++
cp -r $ANDROID_NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/* bionic/libstdc++/include
# The default libstdc++.so does not contain full stl implementation, see https://developer.android.com/ndk/guides/cpp-support
cp -r $ANDROID_NDK_PATH/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so out/target/product/generic/obj/lib/libstdc++.so
# Build spec
cat > buildspec.mk <<EOF
TARGET_PRODUCT := generic
TARGET_BUILD_VARIANT := eng
TARGET_BUILD_TYPE := release
TARGET_TOOLS_PREFIX := $ANDROID_NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-
EOF
}
main() {
android_prepare_build_system
make showcommands ot-core
make showcommands ot-cli
make showcommands ot-ncp
make showcommands spi-hdlc-adapter
test -x out/target/product/generic/system/bin/ot-cli
test -x out/target/product/generic/system/bin/ot-ncp
test -x out/target/product/generic/system/bin/spi-hdlc-adapter
}
main "$@"
-116
View File
@@ -1,116 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
set -e -x -o pipefail
setup_arm_gcc_7()
{
if arm-none-eabi-gcc --version | grep -q 'Arm Embedded Processors 7'; then
return 0
fi
(cd /tmp/
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/7-2018q2/gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2
tar xjf gcc-arm-none-eabi-7-2018-q2-update-linux.tar.bz2)
export PATH=/tmp/gcc-arm-none-eabi-7-2018-q2-update/bin:$PATH
arm-none-eabi-gcc --version
}
size_nrf52840()
{
[ ${TRAVIS_PULL_REQUEST} != false ]
mkdir ../output
export MERGE_BASE_SHA=$(git merge-base HEAD ${TRAVIS_BRANCH})
# pull request
OPENTHREAD_FLAGS="BORDER_AGENT=1 BORDER_ROUTER=1 CHANNEL_MANAGER=1 CHANNEL_MONITOR=1 CHILD_SUPERVISION=1 COAP=1 COAPS=1 COMMISSIONER=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DIAGNOSTIC=1 DISABLE_DOC=1 DNS_CLIENT=1 ECDSA=1 FULL_LOGS=1 JAM_DETECTION=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 SLAAC=1 SNTP_CLIENT=1 TIME_SYNC=1 UDP_FORWARD=1"
git checkout -- .
git clean -xfd
./bootstrap
make -f examples/Makefile-nrf52840 ${OPENTHREAD_FLAGS}
mv output/nrf52840 ../output/nrf52840-b
git checkout -f ${MERGE_BASE_SHA}
git submodule update --init
# base branch
git checkout -- .
git clean -xfd
./bootstrap
make -f examples/Makefile-nrf52840 ${OPENTHREAD_FLAGS}
mv output/nrf52840 ../output/nrf52840-a
curl -s "${SIZE_REPORT_URL}/bash" > size-report
chmod a+x size-report
./size-report init OpenThread
./size-report size ../output/nrf52840-a/bin/ot-cli-ftd ../output/nrf52840-b/bin/ot-cli-ftd
./size-report size ../output/nrf52840-a/bin/ot-cli-mtd ../output/nrf52840-b/bin/ot-cli-mtd
./size-report size ../output/nrf52840-a/bin/ot-ncp-ftd ../output/nrf52840-b/bin/ot-ncp-ftd
./size-report size ../output/nrf52840-a/bin/ot-ncp-mtd ../output/nrf52840-b/bin/ot-ncp-mtd
./size-report size ../output/nrf52840-a/bin/ot-rcp ../output/nrf52840-b/bin/ot-rcp
./size-report size ../output/nrf52840-a/lib/libopenthread-cli-ftd.a ../output/nrf52840-b/lib/libopenthread-cli-ftd.a
./size-report size ../output/nrf52840-a/lib/libopenthread-cli-mtd.a ../output/nrf52840-b/lib/libopenthread-cli-mtd.a
./size-report size ../output/nrf52840-a/lib/libopenthread-ftd.a ../output/nrf52840-b/lib/libopenthread-ftd.a
./size-report size ../output/nrf52840-a/lib/libopenthread-mtd.a ../output/nrf52840-b/lib/libopenthread-mtd.a
./size-report size ../output/nrf52840-a/lib/libopenthread-ncp-ftd.a ../output/nrf52840-b/lib/libopenthread-ncp-ftd.a
./size-report size ../output/nrf52840-a/lib/libopenthread-ncp-mtd.a ../output/nrf52840-b/lib/libopenthread-ncp-mtd.a
./size-report size ../output/nrf52840-a/lib/libopenthread-rcp.a ../output/nrf52840-b/lib/libopenthread-rcp.a
./size-report size ../output/nrf52840-a/lib/libopenthread-radio.a ../output/nrf52840-b/lib/libopenthread-radio.a
./size-report post
}
main()
{
case $1 in
setup)
setup_arm_gcc_7
;;
nrf52840)
size_nrf52840
;;
'')
setup_arm_gcc_7
size_nrf52840
;;
*)
echo "USAGE: $0 [setup|nrf52840]"
exit 1
;;
esac
}
main "$@"
-481
View File
@@ -1,481 +0,0 @@
#!/bin/sh
#
# Copyright (c) 2016, The OpenThread Authors.
# 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.
#
die() {
echo " *** ERROR: " $*
exit 1
}
set -x
python --version || die
[ $BUILD_TARGET != scan-build ] || {
./bootstrap || die
export CPPFLAGS="-DMBEDTLS_DEBUG_C"
export CPPFLAGS="${CPPFLAGS} -I${TRAVIS_BUILD_DIR}/third_party/mbedtls"
export CPPFLAGS="${CPPFLAGS} -I${TRAVIS_BUILD_DIR}/third_party/mbedtls/repo/include"
export CPPFLAGS="${CPPFLAGS} -DMBEDTLS_CONFIG_FILE=\\\"mbedtls-config.h\\\""
# UART transport
export CPPFLAGS="${CPPFLAGS} \
-DOPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1 \
-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1 \
-DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1 \
-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1 \
-DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1 \
-DOPENTHREAD_CONFIG_DIAG_ENABLE=1 \
-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_ECDSA_ENABLE=1 \
-DOPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1 \
-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1 \
-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1 \
-DOPENTHREAD_CONFIG_JOINER_ENABLE=1 \
-DOPENTHREAD_CONFIG_LINK_RAW_ENABLE=1 \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1 \
-DOPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1 \
-DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1 \
-DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1 \
-DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1"
scan-build ./configure \
--enable-builtin-mbedtls=no \
--enable-cli \
--enable-executable=no \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--with-examples=posix || die
scan-build --status-bugs -analyze-headers -v make -j2 || die
# SPI transport
scan-build ./configure \
--enable-builtin-mbedtls=no \
--enable-cli \
--enable-executable=no \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--with-examples=posix || die
scan-build --status-bugs -analyze-headers -v make -j2 || die
}
[ $BUILD_TARGET != android-build ] || {
(cd .. && ${TRAVIS_BUILD_DIR}/.travis/check-android-build) || die
}
build_cc1352() {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
COMMISSIONER=1 JOINER=1 SLAAC=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-cc1352 || die
arm-none-eabi-size output/cc1352/bin/ot-cli-ftd || die
arm-none-eabi-size output/cc1352/bin/ot-cli-mtd || die
arm-none-eabi-size output/cc1352/bin/ot-ncp-ftd || die
arm-none-eabi-size output/cc1352/bin/ot-ncp-mtd || die
}
build_cc2538() {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
COMMISSIONER=1 JOINER=1 SLAAC=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-cc2538 || die
arm-none-eabi-size output/cc2538/bin/ot-cli-ftd || die
arm-none-eabi-size output/cc2538/bin/ot-cli-mtd || die
arm-none-eabi-size output/cc2538/bin/ot-ncp-ftd || die
arm-none-eabi-size output/cc2538/bin/ot-ncp-mtd || die
}
build_cc2650() {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
make -f examples/Makefile-cc2650 || die
arm-none-eabi-size output/cc2650/bin/ot-cli-mtd || die
arm-none-eabi-size output/cc2650/bin/ot-ncp-mtd || die
}
build_cc2652() {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
COMMISSIONER=1 JOINER=1 SLAAC=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-cc2652 || die
arm-none-eabi-size output/cc2652/bin/ot-cli-ftd || die
arm-none-eabi-size output/cc2652/bin/ot-cli-mtd || die
arm-none-eabi-size output/cc2652/bin/ot-ncp-ftd || die
arm-none-eabi-size output/cc2652/bin/ot-ncp-mtd || die
}
build_kw41z() {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
COMMISSIONER=1 JOINER=1 SLAAC=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-kw41z || die
arm-none-eabi-size output/kw41z/bin/ot-cli-ftd || die
arm-none-eabi-size output/kw41z/bin/ot-cli-mtd || die
arm-none-eabi-size output/kw41z/bin/ot-ncp-ftd || die
arm-none-eabi-size output/kw41z/bin/ot-ncp-mtd || die
}
build_nrf52811() {
# Default OpenThread switches for nRF52811 platform
OPENTHREAD_FLAGS="BORDER_ROUTER=1 COAP=1 DNS_CLIENT=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1"
# UART transport
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
make -f examples/Makefile-nrf52811 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52811/bin/ot-cli-mtd || die
arm-none-eabi-size output/nrf52811/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52811/bin/ot-rcp || die
# SPI transport for NCP
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
NCP_SPI=1 make -f examples/Makefile-nrf52811 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52811/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52811/bin/ot-rcp || die
# Build without transport (no CLI or NCP applications)
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
DISABLE_TRANSPORTS=1 make -f examples/Makefile-nrf52811 || die
}
build_nrf52840() {
# Default OpenThread switches for nRF52840 platform
OPENTHREAD_FLAGS="BORDER_AGENT=1 BORDER_ROUTER=1 COAP=1 COAPS=1 COMMISSIONER=1 DEBUG=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 ECDSA=1 FULL_LOGS=1 IP6_FRAGM=1 JOINER=1 LINK_RAW=1 MAC_FILTER=1 MTD_NETDIAG=1 SERVICE=1 SLAAC=1 SNTP_CLIENT=1 UDP_FORWARD=1"
# UART transport
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
make -f examples/Makefile-nrf52840 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-rcp || die
# USB transport with bootloader e.g. to support PCA10059 dongle
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
USB=1 BOOTLOADER=1 make -f examples/Makefile-nrf52840 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-rcp || die
# SPI transport for NCP
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
NCP_SPI=1 make -f examples/Makefile-nrf52840 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-rcp || die
# Build without transport (no CLI or NCP applications)
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
DISABLE_TRANSPORTS=1 make -f examples/Makefile-nrf52840 $OPENTHREAD_FLAGS || die
# Software cryptography
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
DISABLE_BUILTIN_MBEDTLS=0 make -f examples/Makefile-nrf52840 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-rcp || die
# Software cryptography with threading support
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
DISABLE_BUILTIN_MBEDTLS=0 MBEDTLS_THREADING=1 make -f examples/Makefile-nrf52840 $OPENTHREAD_FLAGS || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-cli-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-ftd || die
arm-none-eabi-size output/nrf52840/bin/ot-ncp-mtd || die
arm-none-eabi-size output/nrf52840/bin/ot-rcp || die
}
build_qpg6095() {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
COMMISSIONER=1 JOINER=1 SLAAC=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-qpg6095 || die
arm-none-eabi-size output/qpg6095/bin/ot-cli-ftd || die
arm-none-eabi-size output/qpg6095/bin/ot-cli-mtd || die
arm-none-eabi-size output/qpg6095/bin/ot-ncp-ftd || die
arm-none-eabi-size output/qpg6095/bin/ot-ncp-mtd || die
}
build_samr21() {
git checkout -- . || die
git clean -xfd || die
wget http://ww1.microchip.com/downloads/en/DeviceDoc/asf-standalone-archive-3.45.0.85.zip || die
unzip -qq asf-standalone-archive-3.45.0.85.zip || die
mv xdk-asf-3.45.0 third_party/microchip/asf || die
./bootstrap || die
COMMISSIONER=1 JOINER=1 SLAAC=1 DHCP6_CLIENT=1 DHCP6_SERVER=1 DNS_CLIENT=1 make -f examples/Makefile-samr21 || die
arm-none-eabi-size output/samr21/bin/ot-cli-ftd || die
arm-none-eabi-size output/samr21/bin/ot-cli-mtd || die
arm-none-eabi-size output/samr21/bin/ot-ncp-ftd || die
arm-none-eabi-size output/samr21/bin/ot-ncp-mtd || die
}
[ $BUILD_TARGET != arm-gcc-4 ] || {
export PATH=/tmp/gcc-arm-none-eabi-4_9-2015q3/bin:$PATH || die
build_cc1352
build_cc2538
build_cc2650
build_cc2652
build_kw41z
build_nrf52811
build_nrf52840
build_qpg6095
build_samr21
}
[ $BUILD_TARGET != arm-gcc-5 ] || {
export PATH=/tmp/gcc-arm-none-eabi-5_4-2016q3/bin:$PATH || die
build_cc1352
build_cc2538
build_cc2650
build_cc2652
build_kw41z
build_nrf52811
build_nrf52840
build_qpg6095
build_samr21
}
[ $BUILD_TARGET != arm-gcc-6 ] || {
export PATH=/tmp/gcc-arm-none-eabi-6-2017-q2-update/bin:$PATH || die
build_cc1352
build_cc2538
build_cc2650
build_cc2652
build_kw41z
build_nrf52811
build_nrf52840
build_qpg6095
build_samr21
}
[ $BUILD_TARGET != arm-gcc-7 ] || {
export PATH=/tmp/gcc-arm-none-eabi-7-2018-q2-update/bin:$PATH || die
build_cc1352
build_cc2538
build_cc2650
build_cc2652
build_kw41z
build_nrf52811
build_nrf52840
build_qpg6095
build_samr21
}
[ $BUILD_TARGET != arm-gcc-8 ] || {
export PATH=/tmp/gcc-arm-none-eabi-8-2018-q4-major/bin:$PATH || die
build_cc1352
build_cc2538
build_cc2650
build_cc2652
build_kw41z
build_nrf52811
build_nrf52840
build_qpg6095
build_samr21
}
[ $BUILD_TARGET != posix ] || {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
CPPFLAGS=-DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_NONE make -f examples/Makefile-posix || die
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
CPPFLAGS=-DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG make -f examples/Makefile-posix || die
export CPPFLAGS=" \
-DOPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1 \
-DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1 \
-DOPENTHREAD_CONFIG_DIAG_ENABLE=1 \
-DOPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1 \
-DOPENTHREAD_CONFIG_LEGACY_ENABLE=1 \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1 \
-DOPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1"
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
CPPFLAGS=-DOPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1 make -f examples/Makefile-posix || die
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
./configure \
--enable-ncp \
--enable-ftd \
--enable-mtd \
--with-examples=posix \
--disable-docs \
--disable-tests \
--with-vendor-extension=./src/core/common/extension_example.cpp || die
make -j 8 || die
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
./configure \
--enable-cli \
--enable-mtd \
--with-examples=posix \
--disable-docs \
--disable-tests || die
make -j 8 || die
export CPPFLAGS=" \
-DOPENTHREAD_CONFIG_ANOUNCE_SENDER_ENABLE=1 \
-DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1 \
-DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
./configure \
--enable-cli \
--enable-ncp \
--enable-ftd \
--enable-mtd \
--enable-radio-only \
--with-examples=posix || die
make -j 8 || die
}
[ $BUILD_TARGET != posix-distcheck ] || {
export ASAN_SYMBOLIZER_PATH=`which llvm-symbolizer` || die
export ASAN_OPTIONS=symbolize=1 || die
export DISTCHECK_CONFIGURE_FLAGS= CPPFLAGS=-DOPENTHREAD_POSIX_VIRTUAL_TIME=1 || die
./bootstrap || die
REFERENCE_DEVICE=1 make -f examples/Makefile-posix distcheck || die
}
[ $BUILD_TARGET != posix-32-bit ] || {
./bootstrap || die
REFERENCE_DEVICE=1 COVERAGE=1 CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 make -f examples/Makefile-posix check || die
}
[ $BUILD_TARGET != posix-app-cli ] || {
./bootstrap || die
# enable code coverage for OpenThread transceiver only
COVERAGE=1 VIRTUAL_TIME_UART=1 make -f examples/Makefile-posix || die
# readline supports pipe, editline does not
REFERENCE_DEVICE=1 COVERAGE=1 READLINE=readline make -f src/posix/Makefile-posix || die
REFERENCE_DEVICE=1 COVERAGE=1 PYTHONUNBUFFERED=1 OT_CLI_PATH="$(pwd)/$(ls output/posix/*/bin/ot-cli) -v" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-rcp)" make -f src/posix/Makefile-posix check || die
}
[ $BUILD_TARGET != posix-app-pty ] || {
./bootstrap
.travis/check-posix-app-pty || die
}
[ $BUILD_TARGET != posix-mtd ] || {
./bootstrap || die
REFERENCE_DEVICE=1 COVERAGE=1 CFLAGS=-m32 CXXFLAGS=-m32 LDFLAGS=-m32 USE_MTD=1 make -f examples/Makefile-posix check || die
}
[ $BUILD_TARGET != posix-ncp-spi ] || {
CPPFLAGS="-DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1"
./bootstrap || die
make -f examples/Makefile-posix check configure_OPTIONS="--enable-ncp --enable-ftd --with-examples=posix" || die
}
[ $BUILD_TARGET != posix-app-ncp ] || {
./bootstrap || die
REFERENCE_DEVICE=1 COVERAGE=1 VIRTUAL_TIME_UART=1 make -f examples/Makefile-posix || die
# enable code coverage for OpenThread posix radio
REFERENCE_DEVICE=1 COVERAGE=1 READLINE=readline make -f src/posix/Makefile-posix || die
REFERENCE_DEVICE=1 COVERAGE=1 PYTHONUNBUFFERED=1 OT_NCP_PATH="$(pwd)/$(ls output/posix/*/bin/ot-ncp)" RADIO_DEVICE="$(pwd)/$(ls output/*/bin/ot-rcp)" NODE_TYPE=ncp-sim make -f src/posix/Makefile-posix check || die
}
[ $BUILD_TARGET != posix-ncp ] || {
./bootstrap || die
REFERENCE_DEVICE=1 COVERAGE=1 PYTHONUNBUFFERED=1 NODE_TYPE=ncp-sim make -f examples/Makefile-posix check || die
}
[ $BUILD_TARGET != toranj-test-framework ] || {
./tests/toranj/start.sh || die
}
[ $BUILD_TARGET != osx ] || {
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
make -f examples/Makefile-posix || die
git checkout -- . || die
git clean -xfd || die
./bootstrap || die
make -f src/posix/Makefile-posix || die
}
+217 -90
View File
@@ -30,31 +30,60 @@ LOCAL_PATH := $(call my-dir)
OPENTHREAD_DEFAULT_VERSION := $(shell cat $(LOCAL_PATH)/.default-version)
OPENTHREAD_SOURCE_VERSION := $(shell git -C $(LOCAL_PATH) describe --always --match "[0-9].*" 2> /dev/null)
OPENTHREAD_PROJECT_CFLAGS ?= -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\"
OPENTHREAD_COMMON_FLAGS := \
OPENTHREAD_PUBLIC_CFLAGS := \
-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1 \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
-DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1 \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DOPENTHREAD_POSIX_CONFIG_RCP_PTY_ENABLE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DOPENTHREAD_SPINEL_CONFIG_OPENTHREAD_MESSAGE_ENABLE=1 \
$(NULL)
OPENTHREAD_PRIVATE_CFLAGS := \
-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\" \
-DPACKAGE=\"openthread\" \
-DPACKAGE_BUGREPORT=\"openthread-devel@googlegroups.com\" \
-DPACKAGE_NAME=\"OPENTHREAD\" \
-DPACKAGE_STRING=\"OPENTHREAD\ $(OPENTHREAD_DEFAULT_VERSION)\" \
-DPACKAGE_VERSION=\"$(OPENTHREAD_SOURCE_VERSION)\" \
-DPACKAGE_TARNAME=\"openthread\" \
-DVERSION=\"$(OPENTHREAD_DEFAULT_VERSION)\" \
-DPACKAGE_URL=\"http://github.com/openthread/openthread\" \
-DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1 \
-DPACKAGE_VERSION=\"$(OPENTHREAD_SOURCE_VERSION)\" \
-DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \
-DVERSION=\"$(OPENTHREAD_DEFAULT_VERSION)\" \
$(NULL)
# Enable required features for on-device tests.
ifeq ($(TARGET_BUILD_VARIANT),eng)
OPENTHREAD_COMMON_FLAGS += \
OPENTHREAD_PUBLIC_CFLAGS += \
-DOPENTHREAD_CONFIG_DIAG_ENABLE=1 \
$(NULL)
endif
ifeq ($(USE_OTBR_DAEMON), 1)
OPENTHREAD_PUBLIC_CFLAGS += \
-DOPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1 \
-DOPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1 \
-DOPENTHREAD_CONFIG_UNSECURE_TRAFFIC_MANAGED_BY_STACK_ENABLE=1 \
-DOPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE=1 \
$(NULL)
else
OPENTHREAD_PUBLIC_CFLAGS += -DOPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1
endif
ifeq ($(USE_OT_RCP_BUS), spi)
OPENTHREAD_PUBLIC_CFLAGS += -DOPENTHREAD_POSIX_CONFIG_RCP_BUS=OT_POSIX_RCP_BUS_SPI
else
OPENTHREAD_PUBLIC_CFLAGS += -DOPENTHREAD_POSIX_CONFIG_RCP_BUS=OT_POSIX_RCP_BUS_UART
endif
# Enable all optional features for CI tests.
ifeq ($(TARGET_PRODUCT),generic)
OPENTHREAD_COMMON_FLAGS += \
OPENTHREAD_PUBLIC_CFLAGS += \
-DOPENTHREAD_CONFIG_COAP_API_ENABLE=1 \
-DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1 \
-DOPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1 \
-DOPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1 \
-DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1 \
@@ -77,32 +106,44 @@ LOCAL_MODULE := ot-core
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/cli \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/ncp \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\" \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
$(OPENTHREAD_COMMON_FLAGS) \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_EXPORT_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_EXPORT_C_INCLUDE_DIRS := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(NULL)
LOCAL_CPPFLAGS := \
-Wno-non-virtual-dtor \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_SRC_FILES := \
src/core/api/backbone_router_api.cpp \
src/core/api/backbone_router_ftd_api.cpp \
src/core/api/border_router_api.cpp \
src/core/api/channel_manager_api.cpp \
src/core/api/channel_monitor_api.cpp \
@@ -124,6 +165,7 @@ LOCAL_SRC_FILES := \
src/core/api/logging_api.cpp \
src/core/api/message_api.cpp \
src/core/api/netdata_api.cpp \
src/core/api/netdiag_api.cpp \
src/core/api/random_crypto_api.cpp \
src/core/api/random_noncrypto_api.cpp \
src/core/api/server_api.cpp \
@@ -131,6 +173,9 @@ LOCAL_SRC_FILES := \
src/core/api/thread_api.cpp \
src/core/api/thread_ftd_api.cpp \
src/core/api/udp_api.cpp \
src/core/backbone_router/bbr_leader.cpp \
src/core/backbone_router/bbr_local.cpp \
src/core/backbone_router/bbr_manager.cpp \
src/core/coap/coap.cpp \
src/core/coap/coap_message.cpp \
src/core/coap/coap_secure.cpp \
@@ -173,8 +218,8 @@ LOCAL_SRC_FILES := \
src/core/meshcop/energy_scan_client.cpp \
src/core/meshcop/joiner.cpp \
src/core/meshcop/joiner_router.cpp \
src/core/meshcop/leader.cpp \
src/core/meshcop/meshcop.cpp \
src/core/meshcop/meshcop_leader.cpp \
src/core/meshcop/meshcop_tlvs.cpp \
src/core/meshcop/panid_query_client.cpp \
src/core/meshcop/timestamp.cpp \
@@ -189,13 +234,15 @@ LOCAL_SRC_FILES := \
src/core/net/ip6_mpl.cpp \
src/core/net/netif.cpp \
src/core/net/udp6.cpp \
src/core/radio/radio.cpp \
src/core/radio/radio_callbacks.cpp \
src/core/radio/radio_platform.cpp \
src/core/thread/address_resolver.cpp \
src/core/thread/announce_begin_server.cpp \
src/core/thread/announce_sender.cpp \
src/core/thread/child_table.cpp \
src/core/thread/device_mode.cpp \
src/core/thread/discover_scanner.cpp \
src/core/thread/dua_manager.cpp \
src/core/thread/energy_scan_server.cpp \
src/core/thread/indirect_sender.cpp \
src/core/thread/key_manager.cpp \
@@ -206,10 +253,14 @@ LOCAL_SRC_FILES := \
src/core/thread/mesh_forwarder_mtd.cpp \
src/core/thread/mle.cpp \
src/core/thread/mle_router.cpp \
src/core/thread/mle_types.cpp \
src/core/thread/mlr_manager.cpp \
src/core/thread/neighbor_table.cpp \
src/core/thread/network_data.cpp \
src/core/thread/network_data_leader.cpp \
src/core/thread/network_data_leader_ftd.cpp \
src/core/thread/network_data_local.cpp \
src/core/thread/network_data_notifier.cpp \
src/core/thread/network_diagnostic.cpp \
src/core/thread/panid_query_server.cpp \
src/core/thread/router_table.cpp \
@@ -221,24 +272,27 @@ LOCAL_SRC_FILES := \
src/core/utils/child_supervision.cpp \
src/core/utils/heap.cpp \
src/core/utils/jam_detector.cpp \
src/core/utils/missing_strlcpy.c \
src/core/utils/missing_strlcat.c \
src/core/utils/missing_strnlen.c \
src/core/utils/parse_cmdline.cpp \
src/core/utils/slaac_address.cpp \
src/ncp/hdlc.cpp \
src/ncp/spinel.c \
src/ncp/spinel_decoder.cpp \
src/ncp/spinel_encoder.cpp \
src/posix/platform/alarm.c \
src/posix/platform/entropy.c \
src/lib/hdlc/hdlc.cpp \
src/lib/platform/exit_code.c \
src/lib/spinel/spinel.c \
src/lib/spinel/spinel_decoder.cpp \
src/lib/spinel/spinel_encoder.cpp \
src/lib/url/url.cpp \
src/posix/platform/alarm.cpp \
src/posix/platform/entropy.cpp \
src/posix/platform/hdlc_interface.cpp \
src/posix/platform/logging.c \
src/posix/platform/misc.c \
src/posix/platform/radio_spinel.cpp \
src/posix/platform/logging.cpp \
src/posix/platform/misc.cpp \
src/posix/platform/netif.cpp \
src/posix/platform/radio.cpp \
src/posix/platform/radio_url.cpp \
src/posix/platform/settings.cpp \
src/posix/platform/system.c \
src/posix/platform/uart.c \
src/posix/platform/spi_interface.cpp \
src/posix/platform/system.cpp \
src/posix/platform/uart.cpp \
src/posix/platform/udp.cpp \
third_party/mbedtls/repo/library/md.c \
third_party/mbedtls/repo/library/md_wrap.c \
third_party/mbedtls/repo/library/memory_buffer_alloc.c \
@@ -264,15 +318,51 @@ LOCAL_SRC_FILES := \
third_party/mbedtls/repo/library/ssl_tls.c \
third_party/mbedtls/repo/library/aes.c \
third_party/mbedtls/repo/library/ecp.c \
$(OPENTHREAD_PROJECT_SRC_FILES) \
$(NULL)
include $(OT_EXTRA_BUILD_CONFIG)
include $(BUILD_STATIC_LIBRARY)
ifeq ($(filter -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=%,$(LOCAL_CFLAGS)),)
LOCAL_CFLAGS += \
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \
include $(CLEAR_VARS)
LOCAL_MODULE := libopenthread-cli
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/cli \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
-DOPENTHREAD_CONFIG_UART_CLI_RAW=1 \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_CPPFLAGS := \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_SRC_FILES := \
src/cli/cli.cpp \
src/cli/cli_coap.cpp \
src/cli/cli_coap_secure.cpp \
src/cli/cli_commissioner.cpp \
src/cli/cli_console.cpp \
src/cli/cli_dataset.cpp \
src/cli/cli_joiner.cpp \
src/cli/cli_uart.cpp \
src/cli/cli_udp.cpp \
$(NULL)
endif
include $(BUILD_STATIC_LIBRARY)
@@ -282,109 +372,146 @@ LOCAL_MODULE := ot-cli
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/cli \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\" \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
$(OPENTHREAD_COMMON_FLAGS) \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1 \
-DOPENTHREAD_CONFIG_UART_CLI_RAW=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DOPENTHREAD_POSIX_APP_TYPE=2 \
-DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
-DOPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_CLI \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_CPPFLAGS := \
-Wno-non-virtual-dtor \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_LDLIBS := \
-lrt \
-lutil
LOCAL_SRC_FILES := \
src/cli/cli.cpp \
src/cli/cli_coap.cpp \
src/cli/cli_commissioner.cpp \
src/cli/cli_console.cpp \
src/cli/cli_dataset.cpp \
src/cli/cli_joiner.cpp \
src/cli/cli_server.cpp \
src/cli/cli_uart.cpp \
src/cli/cli_udp.cpp \
src/posix/main.c \
$(NULL)
include $(OT_EXTRA_BUILD_CONFIG)
ifeq ($(filter -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=%,$(LOCAL_CFLAGS)),)
LOCAL_CFLAGS += \
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \
$(NULL)
endif
LOCAL_STATIC_LIBRARIES = ot-core
LOCAL_STATIC_LIBRARIES = libopenthread-cli ot-core
include $(BUILD_EXECUTABLE)
include $(CLEAR_VARS)
LOCAL_MODULE := libopenthread-ncp
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/ncp \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_CPPFLAGS := \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_SRC_FILES := \
src/lib/spinel/spinel_buffer.cpp \
src/ncp/changed_props_set.cpp \
src/ncp/ncp_base.cpp \
src/ncp/ncp_base_mtd.cpp \
src/ncp/ncp_base_ftd.cpp \
src/ncp/ncp_base_dispatcher.cpp \
src/ncp/ncp_uart.cpp \
$(NULL)
include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := ot-ncp
LOCAL_MODULE_TAGS := eng
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/ncp \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(LOCAL_PATH)/third_party/mbedtls \
$(LOCAL_PATH)/third_party/mbedtls/repo/include \
$(NULL)
LOCAL_CFLAGS := \
-DMBEDTLS_CONFIG_FILE=\"mbedtls-config.h\" \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
$(OPENTHREAD_COMMON_FLAGS) \
-DOPENTHREAD_CONFIG_POSIX_APP_ENABLE_PTY_DEVICE=1 \
-DOPENTHREAD_FTD=1 \
-DOPENTHREAD_POSIX=1 \
-DOPENTHREAD_POSIX_APP_TYPE=1 \
-DSPINEL_PLATFORM_HEADER=\"spinel_platform.h\" \
$(OPENTHREAD_PUBLIC_CFLAGS) \
$(OPENTHREAD_PRIVATE_CFLAGS) \
-DOPENTHREAD_POSIX_APP_TYPE=OT_POSIX_APP_TYPE_NCP \
$(OPENTHREAD_PROJECT_CFLAGS) \
$(NULL)
LOCAL_CPPFLAGS := \
-Wno-non-virtual-dtor \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_LDLIBS := \
-lutil
LOCAL_SRC_FILES := \
src/ncp/changed_props_set.cpp \
src/ncp/ncp_base.cpp \
src/ncp/ncp_base_mtd.cpp \
src/ncp/ncp_base_ftd.cpp \
src/ncp/ncp_base_dispatcher.cpp \
src/ncp/ncp_buffer.cpp \
src/ncp/ncp_uart.cpp \
src/posix/main.c \
$(NULL)
include $(OT_EXTRA_BUILD_CONFIG)
LOCAL_LDLIBS := \
-lrt \
-lutil
ifeq ($(filter -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=%,$(LOCAL_CFLAGS)),)
LOCAL_CFLAGS += \
-DOPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"openthread-core-posix-config.h\" \
$(NULL)
endif
LOCAL_STATIC_LIBRARIES = libopenthread-ncp ot-core
LOCAL_STATIC_LIBRARIES = ot-core
include $(BUILD_EXECUTABLE)
ifeq ($(USE_OTBR_DAEMON), 1)
include $(CLEAR_VARS)
LOCAL_MODULE := ot-ctl
LOCAL_MODULE_TAGS := eng
LOCAL_CPPFLAGS := \
-std=c++11 \
-pedantic-errors \
$(NULL)
LOCAL_CFLAGS := \
-DOPENTHREAD_CONFIG_FILE=\<openthread-config-android.h\> \
$(NULL)
LOCAL_C_INCLUDES := \
$(OPENTHREAD_PROJECT_INCLUDES) \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/src/ \
$(LOCAL_PATH)/src/core \
$(LOCAL_PATH)/src/posix/platform \
$(LOCAL_PATH)/src/posix/platform/include \
$(NULL)
LOCAL_SRC_FILES := src/posix/client.cpp
include $(BUILD_EXECUTABLE)
endif # ($(USE_OTBR_DAEMON), 1)
+94
View File
@@ -0,0 +1,94 @@
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
import("etc/gn/openthread.gni")
config("openthread_config") {
if (openthread_config_file != "") {
defines += [ "OPENTHREAD_CONFIG_FILE=${openthread_config_file}" ]
}
include_dirs = openthread_project_include_dirs
include_dirs += [
"${root_gen_dir}/include",
"include",
]
}
config("openthread_ftd_config") {
defines = [ "OPENTHREAD_FTD=1" ]
}
config("openthread_mtd_config") {
defines = [ "OPENTHREAD_MTD=1" ]
}
config("openthread_radio_config") {
defines = [ "OPENTHREAD_RADIO=1" ]
}
group("libopenthread-ftd") {
public_deps = [ "include/openthread" ]
deps = [ "src/core:libopenthread-ftd" ]
}
group("libopenthread-mtd") {
public_deps = [ "include/openthread" ]
deps = [ "src/core:libopenthread-mtd" ]
}
group("libopenthread-radio") {
public_deps = [ "include/openthread" ]
deps = [ "src/core:libopenthread-radio" ]
}
group("libopenthread-cli-ftd") {
public_deps = [ "include/openthread" ]
deps = [ "src/cli:libopenthread-cli-ftd" ]
}
group("libopenthread-cli-mtd") {
public_deps = [ "include/openthread" ]
deps = [ "src/cli:libopenthread-cli-mtd" ]
}
group("libopenthread-spinel-ncp") {
public_deps = [ "src/lib/spinel:spinel-api" ]
deps = [ "src/lib/spinel:libopenthread-spinel-ncp" ]
}
group("libopenthread-spinel-rcp") {
public_deps = [ "src/lib/spinel:spinel-api" ]
deps = [ "src/lib/spinel:libopenthread-spinel-rcp" ]
}
if (current_os == "fuchsia") {
group("lib-ot-core") {
public_deps = [ ":libopenthread-ftd" ]
}
}
+171
View File
@@ -0,0 +1,171 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
cmake_policy(SET CMP0048 NEW)
cmake_minimum_required(VERSION 3.10.2)
file(READ .default-version OT_DEFAULT_VERSION)
string(STRIP ${OT_DEFAULT_VERSION} OT_DEFAULT_VERSION)
project(openthread VERSION ${OT_DEFAULT_VERSION})
option(OT_BUILD_EXECUTABLES "Build executables" ON)
option(OT_COVERAGE "enable coverage" OFF)
set(OT_EXTERNAL_MBEDTLS "" CACHE STRING "Specify external mbedtls library")
add_library(ot-config INTERFACE)
target_include_directories(ot-config INTERFACE
${PROJECT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/core
)
include(TestBigEndian)
TEST_BIG_ENDIAN(OT_BIG_ENDIAN)
if(OT_BIG_ENDIAN)
target_compile_definitions(ot-config INTERFACE "BYTE_ORDER_BIG_ENDIAN=1")
endif()
include("${PROJECT_SOURCE_DIR}/etc/cmake/checks.cmake")
include("${PROJECT_SOURCE_DIR}/etc/cmake/options.cmake")
include("${PROJECT_SOURCE_DIR}/etc/cmake/functions.cmake")
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "(Apple)?[Cc]lang")
option(OT_COMPILE_WARNING_AS_ERROR "whether to include -Werror -pedantic-errors with gcc-compatible compilers")
if (OT_COMPILE_WARNING_AS_ERROR)
set(OT_CFLAGS -Werror -pedantic-errors)
endif()
if(OT_COVERAGE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_ENABLE_COVERAGE=1")
target_compile_options(ot-config INTERFACE -g -O0 --coverage)
target_link_libraries(ot-config INTERFACE --coverage)
endif()
set(OT_CFLAGS
$<$<COMPILE_LANGUAGE:C>:${OT_CFLAGS} -Wall -Wextra -Wshadow>
$<$<COMPILE_LANGUAGE:CXX>:${OT_CFLAGS} -Wall -Wextra -Wshadow -Wno-c++14-compat -fno-exceptions>
)
endif()
execute_process(
COMMAND bash "-c" "third_party/nlbuild-autotools/repo/scripts/mkversion -b ${OT_DEFAULT_VERSION}"
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE OT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Version: ${OT_VERSION}")
target_compile_definitions(ot-config INTERFACE
"PACKAGE_NAME=\"OPENTHREAD\""
"PACKAGE_VERSION=\"${OT_VERSION}\""
)
set(OT_THREAD_VERSION "1.1" CACHE STRING "Thread version chosen by the user at configure time")
set_property(CACHE OT_THREAD_VERSION PROPERTY STRINGS "1.1" "1.2")
if(${OT_THREAD_VERSION} EQUAL "1.1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_1")
elseif(${OT_THREAD_VERSION} EQUAL "1.2")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_THREAD_VERSION=OT_THREAD_VERSION_1_2")
else()
message(FATAL_ERROR "Thread version unknown: ${OT_THREAD_VERSION}")
endif()
set(OT_PLATFORM "NO" CACHE STRING "Target platform chosen by the user at configure time")
ot_get_platforms(OT_PLATFORMS)
set_property(CACHE OT_PLATFORM PROPERTY STRINGS ${OT_PLATFORMS})
if(NOT OT_PLATFORM IN_LIST OT_PLATFORMS)
message(FATAL_ERROR "Platform unknown: ${OT_PLATFORM}")
endif()
set(OT_LOG_OUTPUT_VALUES
"APP"
"DEBUG_UART"
"NONE"
"PLATFORM_DEFINED"
)
if(OT_REFERENCE_DEVICE AND NOT OT_PLATFORM STREQUAL "posix")
set(OT_LOG_OUTPUT "APP" CACHE STRING "Set log output to application for reference device")
else()
set(OT_LOG_OUTPUT "" CACHE STRING "Where log output goes to")
endif()
set_property(CACHE OT_LOG_OUTPUT PROPERTY STRINGS ${OT_LOG_OUTPUT_VALUES})
if(OT_LOG_OUTPUT)
if(NOT OT_LOG_OUTPUT IN_LIST OT_LOG_OUTPUT_VALUES)
message(FATAL_ERROR "Log output unknown: ${OT_LOG_OUTPUT}")
endif()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_OUTPUT=OPENTHREAD_CONFIG_LOG_OUTPUT_${OT_LOG_OUTPUT}")
message(STATUS "Log output: ${OT_LOG_OUTPUT}")
endif()
# OT_CONFIG allows users to specify the path to OpenThread project core
# config header file. The default value of this parameter is empty string.
# When not specified by user (value is ""), a platform cmake file may
# choose to change this variable to provide its own core config header
# file instead.
set(OT_CONFIG "" CACHE STRING "OpenThread project-specific config header file chosen by user at configure time")
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_BINARY_DIR}/etc/cmake)
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/etc/cmake)
list(APPEND OT_PUBLIC_INCLUDES ${PROJECT_SOURCE_DIR}/include)
if(OT_PLATFORM STREQUAL "posix")
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/src/posix/platform)
add_subdirectory("${PROJECT_SOURCE_DIR}/src/posix/platform")
elseif(OT_PLATFORM)
target_include_directories(ot-config INTERFACE ${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM})
add_subdirectory("${PROJECT_SOURCE_DIR}/examples/platforms/${OT_PLATFORM}")
endif()
if(OT_CONFIG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
message(STATUS "Project core config: \"${OT_CONFIG}\"")
endif()
target_compile_definitions(ot-config INTERFACE ${OT_PLATFORM_DEFINES})
if(OT_PLATFORM STREQUAL "posix")
if(OT_BUILD_EXECUTABLES)
add_subdirectory(src/posix)
else()
add_subdirectory(src/posix EXCLUDE_FROM_ALL)
endif()
elseif(OT_PLATFORM)
add_subdirectory(examples)
endif()
add_subdirectory(src)
add_subdirectory(third_party EXCLUDE_FROM_ALL)
if(OT_PLATFORM STREQUAL "simulation")
enable_testing()
add_subdirectory(tests)
endif()
add_custom_target(print-ot-config ALL COMMAND echo -e "$<JOIN:$<TARGET_PROPERTY:ot-config,INTERFACE_COMPILE_DEFINITIONS>,\"\\n\">")
+18 -46
View File
@@ -2,73 +2,45 @@
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at openthread-conduct@google.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at openthread-conduct@google.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at [http://contributor-covenant.org/version/1/4][version]
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
+17 -29
View File
@@ -2,21 +2,21 @@
We would love for you to contribute to OpenThread and help make it even better than it is today! As a contributor, here are the guidelines we would like you to follow.
* [1 Code of Conduct](#code-of-conduct)
* [2 Bugs](#bugs)
* [3 New Features](#new-features)
* [4 Contributing Code](#contributing-code)
* [4.1 Initial Setup](#initial-setup)
* [4.2 Contributor License Agreement (CLA)](#contributor-license-agreement--cla-)
* [4.3 Submitting a Pull Request](#submitting-a-pull-request)
- [1 Code of Conduct](#code-of-conduct)
- [2 Bugs](#bugs)
- [3 New Features](#new-features)
- [4 Contributing Code](#contributing-code)
- [4.1 Initial Setup](#initial-setup)
- [4.2 Contributor License Agreement (CLA)](#contributor-license-agreement--cla-)
- [4.3 Submitting a Pull Request](#submitting-a-pull-request)
## Code of Conduct
Help us keep OpenThread open and inclusive. Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md).
Help us keep OpenThread open and inclusive. Please read and follow our [Code of Conduct](CODE_OF_CONDUCT.md).
## Bugs
If you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/openthread/openthread/issues/new). The best bug reports provide a detailed description of the issue and step-by-step instructions for predictably reproducing the issue. Even better, you can [submit a Pull Request](#submitting-a-pull-request) with a fix.
If you find a bug in the source code, you can help us by [submitting a GitHub Issue](https://github.com/openthread/openthread/issues/new). The best bug reports provide a detailed description of the issue and step-by-step instructions for predictably reproducing the issue. Even better, you can [submit a Pull Request](#submitting-a-pull-request) with a fix.
## New Features
@@ -24,9 +24,9 @@ You can request a new feature by [submitting a GitHub Issue](https://github.com/
If you would like to implement a new feature, please consider the scope of the new feature:
* *Large feature*: first [submit a GitHub Issue](https://github.com/openthread/openthread/issues/new) and communicate your proposal so that the community can review and provide feedback. Getting early feedback will help ensure your implementation work is accepted by the community. This will also allow us to better coordinate our efforts and minimize duplicated effort.
- _Large feature_: first [submit a GitHub Issue](https://github.com/openthread/openthread/issues/new) and communicate your proposal so that the community can review and provide feedback. Getting early feedback will help ensure your implementation work is accepted by the community. This will also allow us to better coordinate our efforts and minimize duplicated effort.
* *Small feature*: can be implemented and directly [submitted as a Pull Request](#submitting-a-pull-request).
- _Small feature_: can be implemented and directly [submitted as a Pull Request](#submitting-a-pull-request).
## Contributing Code
@@ -37,7 +37,6 @@ The OpenThread Project follows the "Fork-and-Pull" model for accepting contribut
Setup your GitHub fork and continuous-integration services:
1. Fork the [OpenThread repository](https://github.com/openthread/openthread) by clicking "Fork" on the web UI.
2. Enable [Travis CI](https://travis-ci.org/) by logging in the respective service with your GitHub account and enabling your newly created fork. We use Travis CI for Linux-based continuous integration checks. All contributions must pass these checks to be accepted.
Setup your local development environment:
@@ -51,12 +50,9 @@ git remote add upstream git@github.com:openthread/openthread.git
### Contributor License Agreement (CLA)
The OpenThread Project requires all contributors to sign a Contributor License Agreement ([individual](https://developers.google.com/open-source/cla/individual) or [corporate](https://developers.google.com/open-source/cla/corporate)) in order to protect contributors, users, and Google in issues of intellectual property.
With each Pull Request, an automated check occurs to verify that you have signed the CLA. Make sure that you sign the CLA with the same email address associated with your commits (i.e. via the `user.email` Git config as described on GitHub's [Set up Git](https://help.github.com/articles/set-up-git/) page.
NOTE: Only original source code from you and other people that have signed the CLA can be accepted into the repository. This policy does not apply to [third_party](https://github.com/openthread/openthread/tree/master/third_party).
Contributions to this project must be accompanied by a Contributor License Agreement. You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project. Head over to <https://cla.developers.google.com/> to see your current agreements on file or to sign a new one.
You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again.
### Submitting a Pull Request
@@ -112,17 +108,9 @@ This will open up a text editor where you can specify which commits to squash.
#### Coding Conventions and Style
OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use the `make pretty` and `make pretty-check` targets to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) for `make pretty` and `make pretty-check`.
OpenThread uses and enforces the [OpenThread Coding Conventions and Style](STYLE_GUIDE.md) on all code, except for code located in [third_party](third_party). Use `script/make-pretty` and `script/make-pretty check` to automatically reformat code and check for code-style compliance, respectively. OpenThread currently requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) for C/C++ and [yapf v0.29.0](https://github.com/google/yapf) for Python.
As part of the cleanup process, you should also run `make pretty-check` to ensure that your code passes the baseline code style checks.
```bash
./bootstrap
./configure
make pretty-check
```
Make sure to include any code format changes in your commits.
As part of the cleanup process, you should also run `script/make-pretty check` to ensure that your code passes the baseline code style checks.
#### Push and Test
@@ -134,8 +122,8 @@ git checkout <branch-name>
git push origin <branch-name>
```
This will trigger the Travis CI continuous-integration checks. You can view the results in the respective services. Note that the integration checks will report failures on occasion. If a failure occurs, you may try rerunning the test via the Travis web UI.
This will trigger continuous-integration checks using GitHub Actions. You can view the status and logs via the "Actions" tab in your fork.
#### Submit Pull Request
Once you've validated the Travis CI results, go to the page for your fork on GitHub, select your development branch, and click the pull request button. If you need to make any adjustments to your pull request, just push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update.
Once you've validated that all continuous-integration checks have passed, go to the page for your fork on GitHub, select your development branch, and click the pull request button. If you need to make any adjustments to your pull request, just push the updates to GitHub. Your pull request will automatically track the changes on your development branch and update.
+1 -9
View File
@@ -37,7 +37,7 @@ AM_DISTCHECK_CONFIGURE_FLAGS = \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--with-examples=posix \
--with-examples=simulation \
$(NULL)
SUBDIRS = \
@@ -71,14 +71,6 @@ DISTCLEANFILES = \
.local-version \
$(NULL)
PRETTY_SUBDIRS = \
examples \
include \
src \
tests \
tools \
$(NULL)
# Ignore the pseudo flash files on Posix platform during diskcheck
distcleancheck_listfiles = \
$(AM_V_at)find . -type f -name "*flash"
+20 -22
View File
@@ -1,16 +1,10 @@
[![OpenThread][ot-logo]][ot-repo]
[![Build Status][ot-travis-svg]][ot-travis]
[![Coverage Status][ot-codecov-svg]][ot-codecov]
[![Build Status][ot-docker-dev-svg]][ot-docker-dev]
[![OpenThread][ot-logo]][ot-repo] [![Build][ot-gh-action-build-svg]][ot-gh-action-build] [![Simulation][ot-gh-action-simulation-svg]][ot-gh-action-simulation] [![Docker][ot-gh-action-docker-svg]][ot-gh-action-docker] [![Language grade: C/C++][ot-lgtm-svg]][ot-lgtm] [![Coverage Status][ot-codecov-svg]][ot-codecov]
---
# What is OpenThread?
OpenThread released by Google is...
<a href="http://threadgroup.org/technology/ourtechnology#certifiedproducts">
<img src="https://cdn.rawgit.com/openthread/openthread/ab4c4e1e/doc/images/certified.svg" alt="Thread Certified Component" width="150px" align="right">
</a>
OpenThread released by Google is... <a href="http://threadgroup.org/technology/ourtechnology#certifiedproducts"> <img src="https://cdn.rawgit.com/openthread/openthread/ab4c4e1e/doc/images/certified.svg" alt="Thread Certified Component" width="150px" align="right"> </a>
**...an open-source implementation of the [Thread](http://threadgroup.org/technology/ourtechnology) networking protocol.** Google Nest has released OpenThread to make the technology used in Nest products more broadly available to developers to accelerate the development of products for the connected home.
@@ -23,27 +17,31 @@ More information about Thread can be found at [threadgroup.org](http://threadgro
[thread]: http://threadgroup.org/technology/ourtechnology
[ot-repo]: https://github.com/openthread/openthread
[ot-logo]: doc/images/openthread_logo.png
[ot-travis]: https://travis-ci.org/openthread/openthread
[ot-travis-svg]: https://travis-ci.org/openthread/openthread.svg?branch=master
[ot-gh-action-build]: https://github.com/openthread/openthread/actions?query=workflow%3ABuild+branch%3Amaster+event%3Apush
[ot-gh-action-build-svg]: https://github.com/openthread/openthread/workflows/Build/badge.svg?branch=master&event=push
[ot-gh-action-simulation]: https://github.com/openthread/openthread/actions?query=workflow%3ASimulation+branch%3Amaster+event%3Apush
[ot-gh-action-simulation-svg]: https://github.com/openthread/openthread/workflows/Simulation/badge.svg?branch=master&event=push
[ot-gh-action-docker]: https://github.com/openthread/openthread/actions?query=workflow%3ADocker+branch%3Amaster+event%3Apush
[ot-gh-action-docker-svg]: https://github.com/openthread/openthread/workflows/Docker/badge.svg?branch=master&event=push
[ot-lgtm]: https://lgtm.com/projects/g/openthread/openthread/context:cpp
[ot-lgtm-svg]: https://img.shields.io/lgtm/grade/cpp/g/openthread/openthread.svg?logo=lgtm&logoWidth=18
[ot-codecov]: https://codecov.io/gh/openthread/openthread
[ot-codecov-svg]: https://codecov.io/gh/openthread/openthread/branch/master/graph/badge.svg
[ot-docker-dev]: https://hub.docker.com/r/openthread/environment
[ot-docker-dev-svg]: https://img.shields.io/docker/cloud/build/openthread/environment.svg?label=docker%20%7C%20dev
# Who supports OpenThread?
<a href="https://www.arm.com/"><img src="doc/images/ot-contrib-arm.png" alt="ARM" width="200px"></a><a href="https://www.cascoda.com/"><img src="doc/images/ot-contrib-cascoda.png" alt="Cascoda" width="200px"></a><a href="https://www.google.com/"><img src="doc/images/ot-contrib-google.png" alt="Google" width="200px"></a><a href="http://www.nordicsemi.com/"><img src="doc/images/ot-contrib-nordic.png" alt="Nordic" width="200px"></a><a href="http://www.nxp.com/"><img src="doc/images/ot-contrib-nxp.png" alt="NXP" width="200px"></a><a href="https://www.particle.io/"><img src="doc/images/ot-contrib-particle.png" alt="Particle" width="200px"></a><a href="http://www.qorvo.com/"><img src="doc/images/ot-contrib-qorvo.png" alt="Qorvo" width="200px"></a><a href="https://www.qualcomm.com/"><img src="doc/images/ot-contrib-qc.png" alt="Qualcomm" width="200px"></a><a href="https://www.samsung.com/"><img src="doc/images/ot-contrib-samsung.png" alt="Samsung" width="200px"></a><a href="https://www.silabs.com/"><img src="doc/images/ot-contrib-silabs.png" alt="Silicon Labs" width="200px"></a><a href="https://www.st.com/"><img src="doc/images/ot-contrib-stm.png" alt="STMicroelectronics" width="200px"></a><a href="https://www.synopsys.com/"><img src="doc/images/ot-contrib-synopsys.png" alt="Synopsys" width="200px"></a><a href="https://www.ti.com/"><img src="doc/images/ot-contrib-ti.png" alt="Texas Instruments" width="200px"></a><a href="https://www.zephyrproject.org/"><img src="doc/images/ot-contrib-zephyr.png" alt="Zephyr Project" width="200px"></a>
<a href="https://www.arm.com/"><img src="doc/images/ot-contrib-arm.png" alt="ARM" width="200px"></a><a href="https://www.cascoda.com/"><img src="doc/images/ot-contrib-cascoda.png" alt="Cascoda" width="200px"></a><a href="https://www.google.com/"><img src="doc/images/ot-contrib-google.png" alt="Google" width="200px"></a><a href="http://www.nordicsemi.com/"><img src="doc/images/ot-contrib-nordic.png" alt="Nordic" width="200px"></a><a href="http://www.nxp.com/"><img src="doc/images/ot-contrib-nxp.png" alt="NXP" width="200px"></a><a href="http://www.qorvo.com/"><img src="doc/images/ot-contrib-qorvo.png" alt="Qorvo" width="200px"></a><a href="https://www.qualcomm.com/"><img src="doc/images/ot-contrib-qc.png" alt="Qualcomm" width="200px"></a><a href="https://www.samsung.com/"><img src="doc/images/ot-contrib-samsung.png" alt="Samsung" width="200px"></a><a href="https://www.silabs.com/"><img src="doc/images/ot-contrib-silabs.png" alt="Silicon Labs" width="200px"></a><a href="https://www.st.com/"><img src="doc/images/ot-contrib-stm.png" alt="STMicroelectronics" width="200px"></a><a href="https://www.synopsys.com/"><img src="doc/images/ot-contrib-synopsys.png" alt="Synopsys" width="200px"></a><a href="https://www.ti.com/"><img src="doc/images/ot-contrib-ti.png" alt="Texas Instruments" width="200px"></a><a href="https://www.zephyrproject.org/"><img src="doc/images/ot-contrib-zephyr.png" alt="Zephyr Project" width="200px"></a>
# Getting started
All end-user documentation and guides are located at [openthread.io](https://openthread.io). If you're looking to do things like...
* Learn more about OpenThread features and enhancements
* Use OpenThread in your products
* Learn how to build and configure a Thread network
* Port OpenThread to a new platform
* Build an application on top of OpenThread
* Certify a product using OpenThread
- Learn more about OpenThread features and enhancements
- Use OpenThread in your products
- Learn how to build and configure a Thread network
- Port OpenThread to a new platform
- Build an application on top of OpenThread
- Certify a product using OpenThread
...then [openthread.io](https://openthread.io) is the place for you.
@@ -71,8 +69,8 @@ Please only use the OpenThread name and marks when accurately referencing this s
There are numerous avenues for OpenThread support:
* Bugs and feature requests — [submit to the Issue Tracker](https://github.com/openthread/openthread/issues)
* Stack Overflow — [post questions using the `openthread` tag](http://stackoverflow.com/questions/tagged/openthread)
* Google Groups — [discussion and announcements at openthread-users](https://groups.google.com/forum/#!forum/openthread-users)
- Bugs and feature requests — [submit to the Issue Tracker](https://github.com/openthread/openthread/issues)
- Stack Overflow — [post questions using the `openthread` tag](http://stackoverflow.com/questions/tagged/openthread)
- Google Groups — [discussion and announcements at openthread-users](https://groups.google.com/forum/#!forum/openthread-users)
The openthread-users Google Group is the recommended place for users to discuss OpenThread and interact directly with the OpenThread team.
+30 -27
View File
@@ -1,15 +1,15 @@
# OpenThread Coding Conventions and Style
* [1 C and C++](#c-and-c)
* [1.1 Standards](#standards)
* [1.2 Conventions and Best Practices](#conventions-and-best-practices)
* [1.3 Tightly-constrained Systems and Shared Infrastructure](#tightly-constrained-systems-and-shared-infrastructure)
* [1.4 Format and Style](#format-and-style)
* [1.5 Comments](#comments)
* [2 Python](#python)
* [2.1 Standards](#standards)
* [2.2 Conventions and Best Practices](#conventions-and-best-practices)
* [2.3 Format and Style](#format-and-style)
- [1 C and C++](#c-and-c)
- [1.1 Standards](#standards)
- [1.2 Conventions and Best Practices](#conventions-and-best-practices)
- [1.3 Tightly-constrained Systems and Shared Infrastructure](#tightly-constrained-systems-and-shared-infrastructure)
- [1.4 Format and Style](#format-and-style)
- [1.5 Comments](#comments)
- [2 Python](#python)
- [2.1 Standards](#standards)
- [2.2 Conventions and Best Practices](#conventions-and-best-practices)
- [2.3 Format and Style](#format-and-style)
# C and C++
@@ -18,7 +18,7 @@
- C
- OpenThread uses and enforces the ISO9899:1999 (aka ISO C99, C99) C language standard as the minimum.
- C++
- OpenThread uses and enforces the ISO14882:2003 (aka ISO C++03, C++03) C++ language standard as the minimum.
- OpenThread uses and enforces the ISO14882:2011 (aka ISO C++11, C++11) C++ language standard as the minimum.
- Extensions
- Wherever possible, toolchain-specific (e.g GCC/GNU) extensions or the use of later standards shall be avoided or shall be leveraged through toolchain-compatibility preprocessor macros.
@@ -27,13 +27,13 @@
### Language Independent
- Inline functions should be used judiciously.
- The use of code in headers and, more specifically, the use of the non-local scope inline functions should be avoided. Exception: Simple setters and getters are fine since the compiler can efficiently optimize these and make their overhead as low as a direct data member access.
- The use of code in headers and, more specifically, the use of the non-local scope inline functions should be avoided. Exception: Simple setters and getters are fine since the compiler can efficiently optimize these and make their overhead as low as a direct data member access.
- Return Statements
- There should be one return statement per free function or method at the end of the free function or method.
- Non-local Goto
- There should be no calls to the functions `setjmp` or `longjmp`.
- Local Goto
- There should be no calls to the C/C++ keyword goto. Exception: The use of local gotos for the purposes of common error handling blocks and single points of function return at the bottom of a function.
- There should be no calls to the C/C++ keyword goto. Exception: The use of local gotos for the purposes of common error handling blocks and single points of function return at the bottom of a function.
- C Preprocessor
- Use of the C preprocessor should be limited to file inclusion and simple macros.
- Macros shall not be defined within a function or a block and should be defined at the top of a file.
@@ -63,16 +63,16 @@
- Unbounded Recursion
- There shall be no direct or indirect use of unbounded recursive function calls.
- Symmetric APIs
- Wherever possible and appropriate, particularly around the management of resources, APIs should be symmetric. For example, if there is a free function or object method that allocates a resource, then there should be one that deallocates it. If there is a free function or object method that opens a file or network stream, then there should be one that closes it.
- Wherever possible and appropriate, particularly around the management of resources, APIs should be symmetric. For example, if there is a free function or object method that allocates a resource, then there should be one that deallocates it. If there is a free function or object method that opens a file or network stream, then there should be one that closes it.
- Use C stdint.h or C++ cstdint for Plain Old Data Types
- Standard, scalar data types defined in stdint.h (C) or cstdint (C++) should be used for basic signed and unsigned integer types, especially when size and serialization to non-volatile storage or across a network is concerned. Examples of these are: `uint8_t`, `int8_t`, etc.
- Standard, scalar data types defined in stdint.h (C) or cstdint (C++) should be used for basic signed and unsigned integer types, especially when size and serialization to non-volatile storage or across a network is concerned. Examples of these are: `uint8_t`, `int8_t`, etc.
- Constant Qualifiers
- Read-only methods, global variables, stack variables, or data members are read-only should be qualified using the C or C++ `const` qualifier.
- Pointers or references to read-only objects or storage, including but not limited to function parameters, should be qualified using the C or C++ `const` qualifier.
- Header Include Guard
- All C and C++ headers shall use preprocessor header include guards.
- The terminating endif preprocessor directive shall have a comment, C or C++ depending on the header type, containing the preprocessor symbol introduced by the ifndef directive starting the guard.
- The symbol used for the guard should be the file name, converted to all uppercase, with any spaces (“ “) or dots (“.”) converted to underscores (“_”).
- The symbol used for the guard should be the file name, converted to all uppercase, with any spaces (“ “) or dots (“.”) converted to underscores (“\_”).
- Function and Method Prototypes
- All void functions or methods shall explicitly declare and specify the void type keyword.
- Unused parameters
@@ -86,16 +86,16 @@
### C++
- Prefer Passing Parameters by Reference to Pointer
- Unlike C, C++ offers an alternate way to alias data over and above a pointer, the reference, indicated by the & symbol. Where appropriate, the reference should be preferred to the pointer.
- Unlike C, C++ offers an alternate way to alias data over and above a pointer, the reference, indicated by the & symbol. Where appropriate, the reference should be preferred to the pointer.
- Passing Base Scalars
- Size- and call frequency-based considerations should be made when passing scalars as to whether they should be passed by value or by constant reference; however, pass-by-value should generally be preferred.
- Eliminate Unnecessary Destructors
- The creation of empty or useless destructors should be avoided. Empty or useless destructors should be removed.
- The creation of empty or useless destructors should be avoided. Empty or useless destructors should be removed.
- Default Parameters
- When you declare C++ free functions and object methods, you should avoid or minimize using default parameters.
- When you declare C++ virtual object methods, you shall avoid using default parameters.
- Global and Scoped Static Construction
- There shall be no use of global, static or otherwise, object construction. The use of scoped static object construction should be avoided.
- There shall be no use of global, static or otherwise, object construction. The use of scoped static object construction should be avoided.
- C++-style Casts
- Wherever possible and practical, C++ style casts should be used and preferred to the C style cast equivalent.
- Avoid `using namespace` Statements in Headers
@@ -114,23 +114,25 @@
## Format and Style
- OpenThread uses the `make pretty` build target to reformat code and enforce code format and style. The `make pretty-check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged.
- OpenThread uses `script/make-pretty` to reformat code and enforce code format and style. `script/make-pretty check` build target is included in OpenThread's continuous integration and must pass before a pull request is merged.
- The `make pretty` and `make pretty-check` build targets require [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0).
- `script/make-pretty` requires [clang-format v6.0.0](http://releases.llvm.org/download.html#6.0.0) for C/C++ and [yapf v0.29.0](https://github.com/google/yapf) for Python.
### File Names
- File names should match the names and types of what is described in the file. If a file contains many declarations and definitions, the author should choose the one that predominantly describes or that makes the most sense.
- File names should match the names and types of what is described in the file. If a file contains many declarations and definitions, the author should choose the one that predominantly describes or that makes the most sense.
- File contents and names should be limited in the scope of what they contain. It may also be possible that there is too much stuff in one file and you need to break it up into multiple files.
- File names should be all lower case.
- File extensions shall be indicative and appropriate for the type and usage of the source or header file.
### Naming
- Names should be descriptive but not overly so and they should give some idea of scope and should be selected such that *wrong code looks wrong*.
- Names should be descriptive but not overly so and they should give some idea of scope and should be selected such that _wrong code looks wrong_.
- Names shall not give any idea of type, such as is done with System Hungarian notation.
- Case
- C preprocessor symbols should be all uppercase.
- All OpenThread class, namespace, structure, method, function, enumeration, and type names in the C/C++ language shall be in *upper camel case*. Exception: the top level OpenThread namespace 'ot'.
- All OpenThread instantiated names of instances of classes, namespaces, structures, methods, functions, enumerations, and types as well as method and function parameters in the C++ language shall be in *lower camel case*.
- All OpenThread class, namespace, structure, method, function, enumeration, and type names in the C/C++ language shall be in _upper camel case_. Exception: the top level OpenThread namespace 'ot'.
- All OpenThread instantiated names of instances of classes, namespaces, structures, methods, functions, enumerations, and types as well as method and function parameters in the C++ language shall be in _lower camel case_.
- Symbol Qualification
- All OpenThread C public data types and free functions should have `ot` prepended to their name.
- All OpenThread C++ code should be in the ot top-level namespace.
@@ -142,6 +144,7 @@
- All variables that do not have such prefixes shall be assumed to be function local scope.
### White Space
- Indentation shall be 4 space characters.
- Conditionals shall always appear on a separate line from the code to execute as a result of the condition.
- Scoped Variable declarations
@@ -181,8 +184,8 @@
## Conventions and Best Practices
- Run `pylint` over your code. `pylint` is a tool for finding bugs and style problems in Python source code. It finds problems that are typically caught by a compiler for less dynamic languages like C and C++. Because of the dynamic nature of Python, some warnings may be incorrect; however, spurious warnings should be fairly infrequent.
- Run `pylint` over your code. `pylint` is a tool for finding bugs and style problems in Python source code. It finds problems that are typically caught by a compiler for less dynamic languages like C and C++. Because of the dynamic nature of Python, some warnings may be incorrect; however, spurious warnings should be fairly infrequent.
## Format and Style
- All code should adhere to [PEP 8](https://www.python.org/dev/peps/pep-0008/).
- All code should adhere to [Google Python Style Guide](http://google.github.io/styleguide/pyguide.html) except maximum line length being 119.
+7 -7
View File
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Copyright (c) 2016, The OpenThread Authors.
# All rights reserved.
@@ -36,10 +36,10 @@
nlbuild_autotools_stem="third_party/nlbuild-autotools/repo"
# Establish some key directories
abs_srcdir=$(cd "$(dirname "${0}")" && pwd)
srcdir=`dirname ${0}`
abs_srcdir=`pwd`
abs_top_srcdir="${abs_srcdir}"
exec ${srcdir}/${nlbuild_autotools_stem}/scripts/bootstrap -I "${abs_top_srcdir}/${nlbuild_autotools_stem}" $*
# filter out knowning information from stderr which is causing GitHub annotation check warnings.
(cd "$abs_srcdir" && exec "$abs_srcdir/$nlbuild_autotools_stem/scripts/bootstrap" -I "$abs_srcdir/$nlbuild_autotools_stem" "${@}") 2> \
>(grep -v "installing 'third_party/nlbuild-autotools/repo/third_party/autoconf/missing'" \
| grep -v "installing 'third_party/nlbuild-autotools/repo/third_party/autoconf/compile'" \
| grep -v "installing 'third_party/nlbuild-autotools/repo/third_party/autoconf/depcomp'" 1>&2)
+189 -118
View File
@@ -137,24 +137,17 @@ case ${host_os} in
*darwin*)
OPENTHREAD_TARGET=darwin
OPENTHREAD_TARGET_DEFINES="-DOPENTHREAD_TARGET_DARWIN"
;;
*linux*)
OPENTHREAD_TARGET=linux
OPENTHREAD_TARGET_DEFINES="-DOPENTHREAD_TARGET_LINUX"
;;
esac
AC_SUBST(OPENTHREAD_TARGET_DARWIN)
AM_CONDITIONAL([OPENTHREAD_TARGET_DARWIN], [test "${OPENTHREAD_TARGET}" = "darwin"])
AC_SUBST(OPENTHREAD_TARGET_LINUX)
AM_CONDITIONAL([OPENTHREAD_TARGET_LINUX], [test "${OPENTHREAD_TARGET}" = "linux"])
AC_SUBST(OPENTHREAD_TARGET_DEFINES)
#
# Checks for build host programs
#
@@ -170,12 +163,6 @@ if test "${enable_no_executables_hack}" = "yes"
then
AC_MSG_RESULT([yes])
AC_NO_EXECUTABLES
# Here we guess conservative values for tests that require link checks
# to test for these features. This will prevent these checks from
# being performed later in the configuration process.
ac_cv_func_strlcat=${ac_cv_func_strlcat-no}
ac_cv_func_strlcpy=${ac_cv_func_strlcpy-no}
ac_cv_func_strnlen=${ac_cv_func_strnlen-no}
else
AC_MSG_RESULT([no])
fi
@@ -208,6 +195,8 @@ AC_PROG_CXX_C_O
AM_PROG_AS
AC_C_BIGENDIAN
# Check for other compiler toolchain tools.
AC_CHECK_TOOL(AR, ar)
@@ -222,6 +211,11 @@ AC_PROG_LN_S
AC_PATH_PROG(CMP, cmp)
# Check for and initialize libtool
LT_INIT
AC_PROG_LIBTOOL
#
# Checks for specific compiler characteristics
#
@@ -232,8 +226,8 @@ AC_PATH_PROG(CMP, cmp)
# -Wall CC, CXX
#
PROSPECTIVE_CFLAGS="-Wall -Wextra -Wshadow -Werror -std=c99 -pedantic-errors -Wno-gnu-zero-variadic-macro-arguments"
PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Werror -std=gnu++98 -Wno-c++14-compat -fno-exceptions"
PROSPECTIVE_CFLAGS="-Wall -Wextra -Wshadow -Wundef -Wcast-align -Werror -Wno-error=undef -std=c99 -pedantic-errors"
PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Wundef -Wcast-align -Werror -Wno-error=undef -std=c++11 -Wno-c++14-compat -fno-exceptions -pedantic-errors"
AC_CACHE_CHECK([whether $CC is Clang],
[nl_cv_clang],
@@ -250,17 +244,60 @@ AC_CACHE_CHECK([whether $CC is Clang],
])
if test "${nl_cv_clang}" = "yes"; then
PROSPECTIVE_CFLAGS="${PROSPECTIVE_CFLAGS} -Wconversion"
PROSPECTIVE_CFLAGS="${PROSPECTIVE_CFLAGS} -Wconversion -Wno-gnu-zero-variadic-macro-arguments"
PROSPECTIVE_CXXFLAGS="${PROSPECTIVE_CXXFLAGS} -Wconversion"
fi
AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS})
AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS})
function convert_warning_flags_to_positive() {
flags_to_check=""
warning_flag_backup=""
for option in ${1}; do
case "$option"
in
-Wno-*)
flags_to_check="${flags_to_check} -W${option##-Wno-}"
warning_flag_backup="${warning_flag_backup} ${option##-Wno-}";;
*)
flags_to_check="${flags_to_check} ${option}";;
esac
done
}
# Check for and initialize libtool
function restore_negative_form_of_warning_flags() {
final_flags=${1}
for positive_option in ${warning_flag_backup}; do
final_flags=$(echo $ECHO_N $final_flags | $SED "s|-W${positive_option}|-Wno-${positive_option}|g")
done
unset flags_to_check
unset warning_flag_backup
}
LT_INIT
AC_PROG_LIBTOOL
function check_prospective_CFLAGS() {
if test "${nl_cv_clang}" = "yes"; then
AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS})
else
convert_warning_flags_to_positive "${PROSPECTIVE_CFLAGS}"
AX_CHECK_COMPILER_OPTIONS([C], ${flags_to_check})
restore_negative_form_of_warning_flags "${CFLAGS}"
CFLAGS=${final_flags}
unset final_flags
fi
}
function check_prospective_CXXFLAGS() {
if test "${nl_cv_clang}" = "yes"; then
AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS})
else
convert_warning_flags_to_positive "${PROSPECTIVE_CXXFLAGS}"
AX_CHECK_COMPILER_OPTIONS([C++], ${flags_to_check})
restore_negative_form_of_warning_flags "${CXXFLAGS}"
CXXFLAGS=${final_flags}
unset final_flags
fi
}
check_prospective_CFLAGS
check_prospective_CXXFLAGS
# Disable building shared libraries by default (can be enabled with --enable-shared)
@@ -322,7 +359,7 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_FUZZ_TARGETS], [test "${enable_fuzz_targets}"
if test "${enable_fuzz_targets}" = "no" ; then
PROSPECTIVE_CXXFLAGS="-fno-rtti"
AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS})
check_prospective_CXXFLAGS
fi
# Address Sanitizer
@@ -351,29 +388,18 @@ AM_CONDITIONAL([OPENTHREAD_WITH_ADDRESS_SANITIZER], [test "${enable_address_sani
if test "${enable_address_sanitizer}" = "yes" ; then
PROSPECTIVE_CFLAGS="-fsanitize=address"
PROSPECTIVE_CXXFLAGS="-fsanitize=address"
# Check if the compilers support address sanitizer
AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS})
AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CFLAGS})
check_prospective_CFLAGS
check_prospective_CXXFLAGS
fi
#
# Code style
#
AC_SUBST(PRETTY, ["\${abs_top_srcdir}/script/clang-format.sh"])
AC_SUBST(PRETTY_ARGS, ["-style=file -i"])
AC_SUBST(PRETTY_CHECK, ["\${abs_top_srcdir}/script/clang-format-check.sh"])
AC_SUBST(PRETTY_CHECK_ARGS, [""])
#
# Tests
#
AC_MSG_NOTICE([checking whether to build tests])
# Tests
NL_ENABLE_TESTS([yes])
AM_CONDITIONAL([OPENTHREAD_BUILD_TESTS], [test "${nl_cv_build_tests}" = "yes"])
@@ -414,65 +440,35 @@ AC_MSG_CHECKING([whether mbed TLS should be enabled])
AC_MSG_RESULT(${enable_builtin_mbedtls})
AM_CONDITIONAL([OPENTHREAD_ENABLE_BUILTIN_MBEDTLS], [test "${enable_builtin_mbedtls}" = "yes"])
#
# POSIX Application
#
AC_MSG_CHECKING([whether to build POSIX applicaton])
AC_ARG_ENABLE(posix-app,
[AS_HELP_STRING([--enable-posix-app], [Build POSIX application @<:@default=no@:>@.])],
[
case "${enableval}" in
no|yes)
enable_posix_app=${enableval}
;;
*)
AC_MSG_ERROR([Invalid value ${enable_posix_app} for --enable-posix-app])
;;
esac
],
[enable_posix_app=no])
if test "$enable_posix_app" = "yes"; then
CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX_APP=1"
else
CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX_APP=0"
fi
AC_MSG_RESULT(${enable_posix_app})
AM_CONDITIONAL([OPENTHREAD_PLATFORM_POSIX_APP], [test "${enable_posix_app}" = "yes"])
#
# POSIX Daemon
#
AC_MSG_CHECKING([whether to build POSIX applicaton in daemon mode])
AC_ARG_ENABLE(posix-app-daemon,
[AS_HELP_STRING([--enable-posix-app-daemon], [Build POSIX application in daemon mode@<:@default=no@:>@.])],
AC_ARG_ENABLE(posix-daemon,
[AS_HELP_STRING([--enable-posix-daemon], [Build POSIX application in daemon mode@<:@default=no@:>@.])],
[
case "${enableval}" in
no|yes)
enable_posix_app_daemon=${enableval}
enable_posix_daemon=${enableval}
;;
*)
AC_MSG_ERROR([Invalid value ${enable_posix_app} for --enable-posix-app-daemon])
AC_MSG_ERROR([Invalid value ${enable_posix} for --enable-posix-daemon])
;;
esac
],
[enable_posix_app_daemon=no])
[enable_posix_daemon=no])
if test "$enable_posix_app_daemon" = "yes"; then
CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_ENABLE_POSIX_APP_DAEMON=1"
if test "$enable_posix_daemon" = "yes"; then
CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE=1"
else
CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_ENABLE_POSIX_APP_DAEMON=0"
CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE=0"
fi
AC_MSG_RESULT(${enable_posix_app_daemon})
AM_CONDITIONAL([OPENTHREAD_ENABLE_POSIX_APP_DAEMON], [test "${enable_posix_app_daemon}" = "yes"])
AC_MSG_RESULT(${enable_posix_daemon})
AM_CONDITIONAL([OPENTHREAD_POSIX_CONFIG_DAEMON_ENABLE], [test "${enable_posix_daemon}" = "yes"])
#
# FTD Library
@@ -780,20 +776,23 @@ AM_CONDITIONAL([OPENTHREAD_ENABLE_CUSTOM_LINKER_FILE], [test "${with_custom_link
# Examples
#
AC_MSG_CHECKING([whether to build examples])
AC_ARG_WITH(examples,
[AS_HELP_STRING([--with-examples=TARGET],
[Specify the examples from one of: no, posix, cc1352, cc2538, cc2650, cc2652, efr32mg12, efr32mg21, gp712, kw41z, nrf52811, nrf52840, qpg6095, samr21 @<:@default=no@:>@.])],
[Build example applications for one of: simulation, cc1352, cc2538, cc2650, cc2652, efr32mg1, efr32mg12, efr32mg13, efr32mg21,
gp712, jn5189, k32w061, kw41z, nrf52811, nrf52833, nrf52840, qpg6095, samr21 @<:@default=no@:>@.
Note that building example applications also builds the associated OpenThread platform libraries
and any third_party libraries needed to support the examples.])],
[
case "${with_examples}" in
no)
;;
posix|cc1352|cc2538|cc2650|cc2652|efr32mg12|efr32mg21|gp712|kw41z|nrf52811|nrf52840|qpg6095|samr21)
if test ${enable_posix_app} = "yes"; then
AC_MSG_ERROR([--with-examples must be no when POSIX apps are enabled by --enable-posix-app])
fi
simulation|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|gp712|jn5189|k32w061|kw41z|nrf52811|nrf52833|nrf52840|qpg6095|samr21)
;;
*)
AC_MSG_ERROR([Invalid value ${with_examples} for --with-examples])
AC_MSG_RESULT(ERROR)
AC_MSG_ERROR([Invalid value given for --with-examples: ${with_examples}])
;;
esac
],
@@ -801,26 +800,115 @@ AC_ARG_WITH(examples,
AM_CONDITIONAL([OPENTHREAD_ENABLE_EXAMPLES], [test ${with_examples} != "no"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_POSIX], [test "${with_examples}" = "posix"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SIMULATION],[test "${with_examples}" = "simulation"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_CC1352], [test "${with_examples}" = "cc1352"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_CC2538], [test "${with_examples}" = "cc2538"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_CC2650], [test "${with_examples}" = "cc2650"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_CC2652], [test "${with_examples}" = "cc2652"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32MG1], [test "${with_examples}" = "efr32mg1"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32MG12], [test "${with_examples}" = "efr32mg12"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32MG13], [test "${with_examples}" = "efr32mg13"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_EFR32MG21], [test "${with_examples}" = "efr32mg21"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_GP712], [test "${with_examples}" = "gp712"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_JN5189], [test "${with_examples}" = "jn5189"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_K32W061], [test "${with_examples}" = "k32w061"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_KW41Z], [test "${with_examples}" = "kw41z"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52811], [test "${with_examples}" = "nrf52811"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52833], [test "${with_examples}" = "nrf52833"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF52840], [test "${with_examples}" = "nrf52840"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_QPG6095], [test "${with_examples}" = "qpg6095"])
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_SAMR21], [test "${with_examples}" = "samr21"])
AM_COND_IF([OPENTHREAD_EXAMPLES_POSIX], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_POSIX=1")
AM_COND_IF([OPENTHREAD_EXAMPLES_SIMULATION], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_EXAMPLES_SIMULATION=0")
AC_MSG_CHECKING([whether to enable examples])
AC_MSG_RESULT(${with_examples})
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF528XX], [test OPENTHREAD_EXAMPLES_NRF52811 || test OPENTHREAD_EXAMPLES_NRF52833 || test OPENTHREAD_EXAMPLES_NRF52840])
case ${with_examples} in
no)
AC_MSG_RESULT([no])
;;
*)
AC_MSG_RESULT([yes (${with_examples})])
;;
esac
#
# Platform
#
AC_MSG_CHECKING([whether to build platform libraries])
AC_ARG_WITH(platform,
[AS_HELP_STRING([--with-platform=TARGET],
[Build OpenThread platform libraries for one of: cc1352, cc2538, cc2650, cc2652,
efr32mg1, efr32mg12, efr32mg13, efr32mg21, gp712, jn5189, kw41z, nrf52811, nrf52833, nrf52840, posix, qpg6095, samr21, simulation @<:@default=simulation@:>@.])],
[
# Make sure the given target is valid.
case "${with_platform}" in
no|cc1352|cc2538|cc2650|cc2652|efr32mg1|efr32mg12|efr32mg13|efr32mg21|gp712|jn5189|kw41z|nrf52811|nrf52833|nrf52840|posix|qpg6095|samr21|simulation)
;;
*)
AC_MSG_RESULT(ERROR)
AC_MSG_ERROR([Invalid value given for --with-platform: ${with_platform}])
;;
esac
# If both --with-platform and --with-examples are specified, make sure the targets match.
case "${with_examples}" in
no)
;;
${with_platform})
;;
*)
AC_MSG_RESULT(ERROR)
AC_MSG_ERROR([Invalid value given for --with-platform: The targets for --with-examples and --with-platform must match.])
;;
esac
],
[
# If --with-platform is NOT specified, but --with-examples is, automatically build the
# corresponding platform libraries. (Essentially, --with-examples implies --with-platform).
with_platform=${with_examples}
])
AM_CONDITIONAL([OPENTHREAD_ENABLE_PLATFORM], [test ${with_platform} != "no"])
OPENTHREAD_ENABLE_PLATFORM=${with_platform}
AM_CONDITIONAL([OPENTHREAD_PLATFORM_CC1352], [test "${with_platform}" = "cc1352"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_CC2538], [test "${with_platform}" = "cc2538"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_CC2650], [test "${with_platform}" = "cc2650"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_CC2652], [test "${with_platform}" = "cc2652"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG1], [test "${with_platform}" = "efr32mg1"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG12], [test "${with_platform}" = "efr32mg12"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG13], [test "${with_platform}" = "efr32mg13"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_EFR32MG21], [test "${with_platform}" = "efr32mg21"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_GP712], [test "${with_platform}" = "gp712"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_JN5189], [test "${with_platform}" = "jn5189"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_KW41Z], [test "${with_platform}" = "kw41z"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52811], [test "${with_platform}" = "nrf52811"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52833], [test "${with_platform}" = "nrf52833"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF52840], [test "${with_platform}" = "nrf52840"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_POSIX], [test "${with_platform}" = "posix"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_QPG6095], [test "${with_platform}" = "qpg6095"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SAMR21], [test "${with_platform}" = "samr21"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_SIMULATION],[test "${with_platform}" = "simulation"])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_NRF528XX], [test OPENTHREAD_PLATFORM_NRF52811 || test OPENTHREAD_PLATFORM_NRF52833 || test OPENTHREAD_PLATFORM_NRF52840])
AM_CONDITIONAL([OPENTHREAD_PLATFORM_K32W], [test OPENTHREAD_PLATFORM_K32W061 || test OPENTHREAD_PLATFORM_JN5189])
AM_COND_IF([OPENTHREAD_PLATFORM_POSIX], CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX=1", CPPFLAGS="${CPPFLAGS} -DOPENTHREAD_PLATFORM_POSIX=0")
case ${with_platform} in
no)
AC_MSG_RESULT([no])
;;
*)
AC_MSG_RESULT([yes (${with_platform})])
;;
esac
AM_CONDITIONAL([OPENTHREAD_EXAMPLES_NRF528XX], [test OPENTHREAD_EXAMPLES_NRF52811 || test OPENTHREAD_EXAMPLES_NRF52840])
#
# Tools
#
@@ -857,7 +945,7 @@ NL_ENABLE_DOCS([auto],[NO])
AM_CONDITIONAL(OPENTHREAD_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"])
AM_CONDITIONAL(OPENTHREAD_POSIX, [test "${enable_posix_app}" = "yes" -o "${with_examples}" = "posix"])
AM_CONDITIONAL(OPENTHREAD_POSIX, [test "${with_platform}" = "posix" -o "${with_examples}" = "simulation"])
#
# Checks for libraries and packages.
@@ -875,21 +963,6 @@ AC_MSG_NOTICE([checking required package dependencies])
# Check for headers
#
#---------------------------------------------------
# Enable BSD Security Features
# This enables strlcpy() and other friends in GNU land.
# While the references below generally speak of: "glibc"
# The ARM Embedded platform uses the nano instance of NEWLIB
# Which greatly follows and mirrors glibc.
# --------------------------------------------------
#
# References:
# 1) http://stackoverflow.com/questions/29201515/what-does-d-default-source-do
# 2) http://man7.org/linux/man-pages/man7/feature_test_macros.7.html
#
CFLAGS="${CFLAGS} -D_BSD_SOURCE=1 -D_DEFAULT_SOURCE=1"
CXXFLAGS="${CXXFLAGS} -D_BSD_SOURCE=1 -D_DEFAULT_SOURCE=1"
OLD_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} -Wno-error=address"
AC_HEADER_STDBOOL
@@ -899,13 +972,6 @@ AC_HEADER_STDC
AC_CHECK_HEADERS([stdint.h])
AC_CHECK_HEADERS([string.h])
#
# Missing Functions
#
AC_CHECK_FUNC([strlcpy], [AC_DEFINE([HAVE_STRLCPY], [1], [Define if strlcpy exists.])])
AC_CHECK_FUNC([strlcat], [AC_DEFINE([HAVE_STRLCAT], [1], [Define if strlcat exists.])])
AC_CHECK_FUNC([strnlen], [AC_DEFINE([HAVE_STRNLEN], [1], [Define if strnlen exists.])])
#
# Check for types and structures
#
@@ -948,14 +1014,17 @@ NL_RESTORE_WERROR
AC_CONFIG_FILES([
Makefile
include/Makefile
include/openthread/Makefile
include/openthread/platform/Makefile
src/Makefile
src/cli/Makefile
src/ncp/Makefile
src/core/Makefile
src/posix/Makefile
src/posix/platform/Makefile
src/lib/Makefile
src/lib/hdlc/Makefile
src/lib/platform/Makefile
src/lib/spinel/Makefile
src/lib/url/Makefile
third_party/Makefile
third_party/jlink/Makefile
third_party/mbedtls/Makefile
@@ -970,20 +1039,26 @@ examples/platforms/cc1352/Makefile
examples/platforms/cc2538/Makefile
examples/platforms/cc2650/Makefile
examples/platforms/cc2652/Makefile
examples/platforms/efr32mg1/Makefile
examples/platforms/efr32mg12/Makefile
examples/platforms/efr32mg12/sleepy-demo/Makefile
examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/efr32mg12/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/efr32mg13/Makefile
examples/platforms/efr32mg13/sleepy-demo/Makefile
examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/efr32mg13/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/efr32mg21/Makefile
examples/platforms/efr32mg21/sleepy-demo/Makefile
examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-ftd/Makefile
examples/platforms/efr32mg21/sleepy-demo/sleepy-demo-mtd/Makefile
examples/platforms/gp712/Makefile
examples/platforms/k32w/Makefile
examples/platforms/kw41z/Makefile
examples/platforms/nrf528xx/Makefile
examples/platforms/qpg6095/Makefile
examples/platforms/samr21/Makefile
examples/platforms/posix/Makefile
examples/platforms/simulation/Makefile
examples/platforms/utils/Makefile
tools/Makefile
tools/harness-automation/Makefile
@@ -1051,10 +1126,6 @@ AC_MSG_NOTICE([
Link flags : ${LDFLAGS:--}
Link libraries : ${LIBS}
Link maps : ${enable_linker_map}
Pretty : ${PRETTY:--}
Pretty args : ${PRETTY_ARGS:--}
Pretty check : ${PRETTY_CHECK:--}
Pretty check args : ${PRETTY_CHECK_ARGS:--}
OpenThread FTD support : ${enable_ftd}
OpenThread MTD support : ${enable_mtd}
OpenThread Radio Only support : ${enable_radio_only}
@@ -1065,6 +1136,6 @@ AC_MSG_NOTICE([
OpenThread Vendor Extension Source : ${with_vendor_extension}
OpenThread builtin mbedtls support : ${enable_builtin_mbedtls}
OpenThread Examples : ${with_examples}
OpenThread POSIX Application : ${enable_posix_app}
OpenThread Platform Libraries : ${with_platform}
])
+4 -1
View File
@@ -38,7 +38,6 @@ EXTRA_DIST = \
$(srcdir)/images/ot-contrib-google.png \
$(srcdir)/images/ot-contrib-nordic.png \
$(srcdir)/images/ot-contrib-nxp.png \
$(srcdir)/images/ot-contrib-particle.png \
$(srcdir)/images/ot-contrib-qc.png \
$(srcdir)/images/ot-contrib-qorvo.png \
$(srcdir)/images/ot-contrib-samsung.png \
@@ -47,6 +46,7 @@ EXTRA_DIST = \
$(srcdir)/images/ot-contrib-synopsys.png \
$(srcdir)/images/ot-contrib-ti.png \
$(srcdir)/images/ot-contrib-zephyr.png \
$(srcdir)/ot_api_doc.h \
$(NULL)
#
@@ -77,6 +77,9 @@ CLEANFILES = \
if OPENTHREAD_BUILD_DOCS
openthreaddir = $(includedir)/openthread
dist_openthread_HEADERS = ot_api_doc.h
all-local: html/index.html
#
Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.6 KiB

+165
View File
@@ -0,0 +1,165 @@
/*
* Copyright (c) 2020, The OpenThread Authors.
* 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
* @brief
* This file defines the Doxygen group structure for OpenThread documentation.
*/
/**
* @defgroup api API
* @brief
* This module includes the application programming interface to the OpenThread stack.
*
* @{
*
* @defgroup api-error Error
*
* @defgroup api-execution Execution
*
* @{
*
* @defgroup api-instance Instance
* @defgroup api-tasklets Tasklets
*
* @}
*
* @defgroup api-net IPv6 Networking
* @{
*
* @defgroup api-dns DNSv6
* @defgroup api-icmp6 ICMPv6
* @defgroup api-ip6 IPv6
* @defgroup api-udp-group UDP
*
* @{
*
* @defgroup api-udp UDP
* @defgroup api-udp-forward UDP Forward
*
* @}
*
* @}
*
* @defgroup api-link Link
*
* @{
*
* @defgroup api-link-link Link
* @defgroup api-link-raw Raw Link
*
* @}
*
* @defgroup api-message Message
*
* @defgroup api-thread Thread
*
* @{
*
* @defgroup api-backbone-router Backbone Router
* @defgroup api-border-agent Border Agent
* @defgroup api-border-router Border Router
* @defgroup api-commissioner Commissioner
* @defgroup api-thread-general General
* @brief This module includes functions for all Thread roles.
* @defgroup api-joiner Joiner
* @defgroup api-thread-router Router/Leader
* @brief This module includes functions for Thread Routers and Leaders.
* @defgroup api-server Server
*
* @}
*
* @defgroup api-addons Add-Ons
*
* @{
*
* @defgroup api-channel-manager Channel Manager
* @defgroup api-channel-monitor Channel Monitoring
* @defgroup api-child-supervision Child Supervision
* @defgroup api-coap-group CoAP
*
* @{
*
* @defgroup api-coap CoAP
* @defgroup api-coap-secure CoAP Secure
*
* @}
*
* @defgroup api-cli Command Line Interface
* @defgroup api-crypto Crypto
* @defgroup api-entropy Entropy Source
* @defgroup api-factory-diagnostics Factory Diagnostics
* @defgroup api-heap Heap
* @defgroup api-jam-detection Jam Detection
* @defgroup api-logging Logging
* @defgroup api-ncp Network Co-Processor
* @defgroup api-network-time Network Time Synchronization
* @defgroup api-random-group Random Number Generator
*
* @{
*
* @defgroup api-random-crypto RNG Cryptographic
* @defgroup api-random-non-crypto RNG Non-cryptographic
*
* @}
*
* @defgroup api-sntp SNTP
*
* @}
*
* @}
*
*/
/**
* @defgroup platform Platform Abstraction
* @brief
* This module includes the platform abstraction used by the OpenThread stack.
*
* @{
*
* @defgroup plat-alarm Alarm
* @defgroup plat-ble BLE Host
* @defgroup plat-entropy Entropy
* @defgroup plat-factory-diagnostics Factory Diagnostics
* @defgroup plat-logging Logging
* @defgroup plat-memory Memory
* @defgroup plat-messagepool Message Pool
* @defgroup plat-misc Miscellaneous
* @defgroup plat-otns Network Simulator
* @defgroup plat-radio Radio
* @defgroup plat-settings Settings
* @defgroup plat-spi-slave SPI Slave
* @defgroup plat-time Time Service
* @defgroup plat-toolchain Toolchain
* @defgroup plat-uart UART
*
* @}
*
*/
+37
View File
@@ -0,0 +1,37 @@
# What is Thread?
<figure class="attempt-right">
<img src="../images/ot-logo-thread.png" srcset="../images/ot-logo-thread.png 1x, ../images/ot-logo-thread_2x.png 2x" border="0" alt="Thread" />
</figure>
<a href="http://threadgroup.org/">Thread<sup>®</sup></a> is an IPv6-based
networking protocol designed for low-power Internet of Things devices in an IEEE
802.15.4-2006 wireless mesh network, commonly called a Wireless Personal Area
Network (WPAN). Thread is independent of other 802.15 mesh networking
protocols, such a ZigBee, Z-Wave, and Bluetooth LE.
Thread's primary features include:
* Simplicity — Simple installation, start up, and operation
* Security — All devices in a Thread network are authenticated and all
communications are encrypted
* Reliability — Self-healing mesh networking, with no single point of failure,
and spread-spectrum techniques to provide immunity to interference
* Efficiency — Low-power Thread devices can sleep and operate on battery power
for years
* Scalability — Thread networks can scale up to hundreds of devices
If you're new to Thread, understanding the basics are critical to using
OpenThread in your own applications. The goal of this primer is to explain the
concepts behind Thread and how it works, and provide a springboard to OpenThread
development.
It is assumed you have good working knowledge of the following:
* IEEE 802.15.4
* Networking and routing concepts
* IPv6
This primer is based on version 1.1.1 of the Thread Specification. It does not
cover the full specification, which is available at
[threadgroup.org](http://threadgroup.org/ThreadSpec).
@@ -0,0 +1,276 @@
# IPv6 Addressing
Let's take a look at how Thread identifies each device in the network, and what
types of addresses they use to communicate with each other.
Key Term: In this primer, the term "interface" is used to identify an endpoint
of a Thread device within a network. Typically, a single Thread device has
a single Thread interface.
## Scopes
<figure class="attempt-right">
<a href="../images/ot-primer-scopes_2x.png"><img src="../images/ot-primer-scopes.png" srcset="../images/ot-primer-scopes.png 1x, ../images/ot-primer-scopes_2x.png 2x" border="0" alt="OT Scopes" /></a>
</figure>
There are three scopes in a Thread network for unicast addressing:
* Link-Local — all interfaces reachable by a single radio transmission
* Mesh-Local — all interfaces reachable within the same Thread network
* Global — all interfaces reachable from outside a Thread network
The first two scopes correspond to prefixes designated by a Thread network.
Link-Local have prefixes of `fe80::/16`, while Mesh-Local have prefixes of
`fd00::/8`.
<h2 style="clear:right">Unicast</h2>
There are multiple IPv6 unicast addresses that identify a single Thread device.
Each has a different function based on the scope and use case.
Before we detail each type, let's learn more about a common one, called the
Routing Locator (RLOC). The RLOC identifies a Thread interface, based on its
location in the network topology.
### How a Routing Locator is generated
All devices are assigned a Router ID and a Child ID. Each Router maintains a
table of all their Children, the combination of which uniquely identifies a
device within the topology. For example, consider the highlighted nodes in the
following topology, where the number in a Router (pentagon) is the Router ID,
and the number in an End Device (circle) is the Child ID:
<figure>
<a href="../images/ot-primer-rloc-topology_2x.png"><img src="../images/ot-primer-rloc-topology.png" srcset="../images/ot-primer-rloc-topology.png 1x, ../images/ot-primer-rloc-topology_2x.png 2x" border="0" width="600" alt="OT RLOC Topology" /></a>
</figure>
Each Child's Router ID corresponds to their Parent (Router). Because a Router is
not a Child, the Child ID for a Router is always 0. Together, these values are
unique for each device in the Thread network, and are used to create the RLOC16,
which represents the last 16 bits of the RLOC.
For example, here's how the RLOC16 is calculated for the upper-left node (Router
ID = 1 and Child ID = 1):
<figure>
<a href="../images/ot-primer-rloc16_2x.png"><img src="../images/ot-primer-rloc16.png" srcset="../images/ot-primer-rloc16.png 1x, ../images/ot-primer-rloc16_2x.png 2x" border="0" width="400" alt="OT RLOC16" /></a>
</figure>
The RLOC16 is part of the Interface Identifier (IID), which corresponds to the
last 64 bits of the IPv6 address. Some IIDs can be used to identify some types
of Thread interfaces. For example, the IID for RLOCs is always of the form
<code>0000:00ff:fe00:<var>RLOC16</var></code>.
The IID, combined with a Mesh-Local Prefix, results in the RLOC. For example,
using a Mesh-Local Prefix of `fde5:8dba:82e1:1::/64`, the RLOC for a node where
RLOC16 = `0x401` is:
<figure>
<a href="../images/ot-primer-rloc_2x.png"><img src="../images/ot-primer-rloc.png" srcset="../images/ot-primer-rloc.png 1x, ../images/ot-primer-rloc_2x.png 2x" border="0" width="600" alt="OT RLOC" /></a>
</figure>
This same logic can be used to determine the RLOC for all highlighted nodes in the sample topology above:
<figure>
<a href="../images/ot-primer-rloc-topology-address_2x.png"><img src="../images/ot-primer-rloc-topology-address.png" srcset="../images/ot-primer-rloc-topology-address.png 1x, ../images/ot-primer-rloc-topology-address_2x.png 2x" border="0" width="600" alt="OT Topology w/ Address" /></a>
</figure>
However, because the RLOC is based on the location of the node in the topology,
the RLOC of a node can change as the topology changes.
For example, perhaps node `0x400` is removed from the Thread network. Nodes
`0x401` and `0x402` establish new links to different Routers, and as a result
they are each assigned a new RLOC16 and RLOC:
<figure>
<a href="../images/ot-primer-rloc-topology-change_2x.png"><img src="../images/ot-primer-rloc-topology-change.png" srcset="../images/ot-primer-rloc-topology-change.png 1x, ../images/ot-primer-rloc-topology-change_2x.png 2x" border="0" width="600" alt="OT Topology after Change" /></a>
</figure>
## Unicast address types
The RLOC is just one of many IPv6 unicast addresses a Thread device can have.
Another category of addresses are called Endpoint Identifiers (EIDs), which
identify a unique Thread interface within a Thread network partition. EIDs are
independent of Thread network topology.
Common unicast types are detailed below.
<table>
<tbody>
<tr>
<th colspan=2><h3>Link-Local Address (LLA)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">An EID that identifies a Thread interface reachable by a single radio transmission.</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Example</b></td><td><code>fe80::54db:881c:3845:57f4</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td>Based on 802.15.4 Extended Address</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scope</b></td><td>Link-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Details</b></td><td><ul><li>Used to discover neighbors, configure links, and exchange routing information</li><li>Not a routable address</li><li>Always has a prefix of <code>fe80::/16</code></li></ul></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Mesh-Local EID (ML-EID)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">An EID that identifies a Thread interface, independent of network topology. Used to reach a Thread interface within the same Thread partition. Also called a Unique Local Address (ULA).</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Example</b></td><td><code>fde5:8dba:82e1:1:416:993c:8399:35ab</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td>Random, chosen after commissioning is complete</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scope</b></td><td>Mesh-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Details</b></td><td><ul><li>Does not change as the topology changes</li><li>Should be used by applications</li><li>Always has a prefix <code>fd00::/8</code></li></ul></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Routing Locator (RLOC)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">Identifies a Thread interface, based on its location in the network topology.</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Example</b></td><td><code>fde5:8dba:82e1:1::ff:fe00:1001</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td><code>0000:00ff:fe00:<var>RLOC16</var></code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scope</b></td><td>Mesh-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Details</b></td><td><ul><li>Generated once a device attaches to a network</li><li>For delivering IPv6 datagrams within a Thread network</li><li>Changes as the topology changes</li><li>Generally not used by applications</li></ul></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Anycast Locator (ALOC)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">Identifies a Thread interface via RLOC lookup, when the RLOC of a destination is not known.</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Example</b></td><td><code>fde5:8dba:82e1:1::ff:fe00:fc01</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td><code>0000:00ff:fe00:fc<var>XX</var></code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scope</b></td><td>Mesh-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Details</b></td><td><ul><li><code>fc<var>XX</var></code> = <a href="#anycast">ALOC destination</a>, which looks up the appropriate RLOC</li><li>Generally not used by applications</li></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Global Unicast Address (GUA)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">An EID that identifies a Thread interface on a global scope, beyond a Thread network.</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Example</b></td><td><code>2000::54db:881c:3845:57f4</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td><ul><li>SLAAC — Randomly assigned by the device itself</li><li>DHCP — Assigned by a DHCPv6 server</li><li>Manual — Assigned by the application layer</li></ul></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scope</b></td><td>Global</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Details</b></td><td><ul><li>A public IPv6 address</li><li>Always has a prefix of <code>2000::/3</code></li></td>
</tr>
</tbody>
</table>
## Multicast
Multicast is used to communicate information to multiple devices at once. In a
Thread network, specific addresses are reserved for multicast use with different
groups of devices, depending on the scope.
| IPv6 Address | Scope | Delivered to |
| ------------ | ---------- | ----------------- |
| `ff02::1` | Link-Local | All FTDs and MEDs |
| `ff02::2` | Link-Local | All FTDs |
| `ff03::1` | Mesh-Local | All FTDs and MEDs |
| `ff03::2` | Mesh-Local | All FTDs |
Key Point: A major difference between FTDs and MTDs are that FTDs subscribe to
the `ff03::2` multicast address. MTDs do not.
You might notice that Sleepy End Devices (SEDs) are not included as a
recipient in the multicast table above. Instead, Thread defines
link-local and realm-local scope unicast prefix-based IPv6 multicast
address used for All Thread Nodes, including SEDs. These multicast
addresses vary by Thread network, because it is built on the unicast
Mesh-Local prefix (see [RFC 3306](https://tools.ietf.org/html/rfc3306)
for more details on unicast-prefix-based IPv6 multicast addresses).
Arbitrary scopes beyond those already listed are also supported for Thread
devices.
## Anycast
Anycast is used to route traffic to a Thread interface when the RLOC of a
destination is not known. An Anycast Locator (ALOC) identifies the location of
multiple interfaces within a Thread partition. The last 16 bits of an ALOC,
called the ALOC16, is in the format of <code>0xfc<var>XX</var></code>, which
represents the type of ALOC.
For example, an ALOC16 between `0xfc01` and `0xfc0f` is reserved for DHCPv6
Agents. If the specific DHCPv6 Agent RLOC is unknown (perhaps because the
network topology has changed), a message can be sent to a DHCPv6 Agent ALOC to
obtain the RLOC.
Thread defines the following ALOC16 values:
| ALOC16 | Type |
| ------------------------------------------ | ------------------------ |
| `0xfc00` | Leader |
| `0xfc01` `0xfc0f` | DHCPv6 Agent |
| `0xfc10` `0xfc2f` | Service |
| `0xfc30` `0xfc37` | Commissioner |
| `0xfc40` `0xfc4e` | Neighbor Discovery Agent |
| `0xfc38` `0xfc3f`<br>`0xfc4f` `0xfcff` | Reserved |
## Recap
What you've learned:
* A Thread network consists of three scopes: Link-Local, Mesh-Local, and Global
* A Thread device has multiple unicast IPv6 addresses
* An RLOC represents a device's location in the Thread network
* An ML-EID is unique to a Thread device within a partition and should be used by applications
* Thread uses multicast to forward data to groups of nodes and routers
* Thread uses anycast when the RLOC of a destination is unknown
To learn more about Thread's IPv6 addressing, see sections 5.2 and 5.3 of the
[Thread Specification](http://threadgroup.org/ThreadSpec).
@@ -0,0 +1,292 @@
# Network Discovery and Formation
## Thread networks
Thread networks are identified by three unique identifiers:
* 2-byte Personal Area Network ID (PAN ID)
* 8-byte Extended Personal Area Network ID (XPAN ID)
* A human-readable Network Name
For example, a Thread network may have the following identifiers:
Identifier | Value
---- | ----
PAN ID | `0xBEEF`
XPAN ID | `0xBEEF1111CAFE2222`
Network Name | `yourThreadCafe`
<figure class="attempt-right">
<a href="../images/ot-primer-network-active-scan_2x.png"><img src="../images/ot-primer-network-active-scan.png" srcset="../images/ot-primer-network-active-scan.png 1x, ../images/ot-primer-network-active-scan_2x.png 2x" border="0" alt="OT Active Scan" /></a>
</figure>
When creating a new Thread network, or searching for an existing one to join, a
Thread device performs an active scan for 802.15.4 networks within radio range:
1. The device broadcasts an 802.15.4 Beacon Request on a specific Channel.
1. In return, any Routers or Router Eligible End Devices (REEDs) in range
broadcast a Beacon that contains their Thread network PAN ID, XPAN ID, and
Network Name.
1. The device repeats the previous two steps for each Channel.
Once a Thread device has discovered all networks in range, it can either attach
to an existing network, or create a new one if no networks are discovered.
<h2 style="clear:right">Mesh Link Establishment</h2>
Thread uses the Mesh Link Establishment (MLE) protocol to configure links and
disseminate information about the network to Thread devices.
In link configuration, MLE is used to:
* Discover links to neighboring devices
* Determine the quality of links to neighboring devices
* Establish links to neighboring devices
* Negotiate link parameters (device type, frame counters, timeout) with peers
MLE disseminates the following types of information to devices wishing to
establish links:
* Leader data (Leader RLOC, Partition ID, Partition weight)
* Network data (on-mesh prefixes, address autoconfiguration, more-specific
routes)
* Route propagation
Route propagation in Thread works similar to the Routing Information Protocol
(RIP), a distance-vector routing protocol.
Note: MLE only proceeds once a Thread device has obtained Thread network
credentials through Thread Commissioning. Commissioning and Security will be
covered in depth later in this Primer. For now, this page assumes that the
device has already been commissioned.
## Create a new network
If the device elects to create a new network, it selects the least busy Channel
and a PAN ID not in use by other networks, then becomes a Router and elects
itself the Leader. This device sends MLE Advertisement messages to other
802.15.4 devices to inform them of its link state, and responds to Beacon
Requests by other Thread devices performing an active scan.
## Join an existing network
If the device elects to join an existing network, it configures its Channel, PAN
ID, XPAN ID, and Network Name to match that of the target network via Thread
Commissioning, then goes through the MLE Attach process to attach as a Child
(End Device). This process is used for Child-Parent links.
Key Point: Every device, router-capable or not, initially attaches to a Thread
network as a Child (End Device).
1. The Child sends a multicast [Parent Request](#1_parent_request) to all
neighboring Routers and REEDs in the target network.
1. All neighboring Routers and REEDs (if the Parent Request Scan Mask includes
REEDs) send [Parent Responses](#2_parent_response) with information about
themselves.
1. The Child chooses a Parent device and sends a [Child ID
Request](#3_child_id_request) to it.
1. The Parent sends a [Child ID Response](#4_child_id_response) to confirm link
establishment.
### 1. Parent Request
A Parent Request is a multicast request from the attaching device that is used
to discover neighboring Routers and Router Eligible End Devices (REEDs) in the
target network.
<figure>
<a href="../images/ot-primer-network-mle-attach-01_2x.png"><img src="../images/ot-primer-network-mle-attach-01.png" srcset="../images/ot-primer-network-mle-attach-01.png 1x, ../images/ot-primer-network-mle-attach-01_2x.png 2x" width="350" border="0" alt="OT MLE Attach Parent Request" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Parent Request Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Mode</b></td>
<td>Describes the attaching device</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Challenge</b></td>
<td>Tests the timeliness of the Parent Response to prevent replay
attacks</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scan Mask</b></td>
<td>Limits the request to only Routers or to both Routers and REEDs</td>
</tr>
</tbody>
</table>
### 2. Parent Response
A Parent Response is a unicast response to a Parent Request that provides
information about a Router or REED to the attaching device.
<figure>
<a href="../images/ot-primer-network-mle-attach-02_2x.png"><img src="../images/ot-primer-network-mle-attach-02.png" srcset="../images/ot-primer-network-mle-attach-02.png 1x, ../images/ot-primer-network-mle-attach-02_2x.png 2x" width="350" border="0" alt="OT MLE Attach Parent Response" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Parent Response Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread protocol version</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Response</b></td>
<td>Copy of the Parent Request Challenge</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link Frame
Counter</b></td>
<td>802.15.4 Frame Counter on the Router/REED</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>MLE Frame
Counter</b></td>
<td>MLE Frame Counter on the Router/REED</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>RLOC16 of the Router/REED</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link
Margin</b></td>
<td>Receive signal quality of the Router/REED</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Connectivity</b></td>
<td>Describes the Router/REEDs level of connectivity</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>Information about the Router/REEDs Leader</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Challenge</b></td>
<td>Tests the timeliness of the Child ID Request to prevent replay
attacks</td>
</tr>
</tbody>
</table>
### 3. Child ID Request
A Child ID Request is a unicast request from the attaching device (Child) that
is sent to the Router or REED (Parent) for the purpose of establishing a
Child-Parent link. If the request is sent to a REED, it [upgrades itself to a
Router](/guides/thread-primer/router-selection#upgrade_to_a_router) before
accepting the request.
<figure>
<a href="../images/ot-primer-network-mle-attach-03_2x.png"><img src="../images/ot-primer-network-mle-attach-03.png" srcset="../images/ot-primer-network-mle-attach-03.png 1x, ../images/ot-primer-network-mle-attach-03_2x.png 2x" width="350" border="0" alt="OT MLE Attach Child ID Request" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Child ID Request Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread protocol version</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Response</b></td>
<td>Copy of the Parent Response Challenge</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link Frame
Counter</b></td>
<td>802.15.4 Frame Counter on the Child</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>MLE Frame
Counter</b></td><td>MLE Frame Counter on the Child</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Mode</b></td>
<td>Describes the Child</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Timeout</b></td>
<td>Inactivity duration before the Parent removes the Child</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Address
Registration (MEDs and SEDs only)</b></td>
<td>Register IPv6 addresses</td>
</tr>
</tbody>
</table>
### 4. Child ID Response
A Child ID Response is a unicast response from the Parent that is sent to the
Child to confirm that a Child-Parent link has been established.
<figure>
<a href="../images/ot-primer-network-mle-attach-04_2x.png"><img src="../images/ot-primer-network-mle-attach-04.png" srcset="../images/ot-primer-network-mle-attach-04.png 1x, ../images/ot-primer-network-mle-attach-04_2x.png 2x" width="350" border="0" alt="OT MLE Attach Child ID Response" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Child ID Response Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>Parent's RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Address16</b></td>
<td>Child's RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>Information about the Parents Leader (RLOC, Partition ID, Partition
weight)</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Network
Data</b></td>
<td>Information about the Thread network (on-mesh prefixes, address
autoconfiguration, more-specific routes)</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Route
(REED only)</b></td>
<td>Route propagation</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Timeout</b></td>
<td>Inactivity duration before the Parent removes the Child</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Address
Registration (MEDs and SEDs only)</b></td>
<td>Confirm registered addresses</td>
</tr>
</tbody>
</table>
## Recap
What you've learned:
* A Thread device performs an active scan for existing networks
* Thread uses Mesh Link Establishment to configure links and disseminate
information about network devices
* MLE Advertisement messages inform other Thread devices about a device's
network and link state
* The MLE Attach process establishes Child-Parent links
@@ -0,0 +1,152 @@
# Node Roles and Types
## Forwarding roles
<figure class="attempt-right">
<a href="../images/ot-primer-roles_2x.png"><img src="../images/ot-primer-roles.png" srcset="../images/ot-primer-roles.png 1x, ../images/ot-primer-roles_2x.png 2x" border="0" alt="OT Node Roles" /></a>
</figure>
In a Thread network, nodes are split into two forwarding roles:
### Router
A Router is a node that:
* forwards packets for network devices
* provides secure commissioning services for devices trying to join the network
* keeps its transceiver enabled at all times
### End Device
An End Device (ED) is a node that:
* communicates primarily with a single Router
* does not forward packets for other network devices
* can disable its transceiver to reduce power
Key Point: The relationship between Router and End Device is a Parent-Child
relationship. An End Device attaches to exactly one Router. The Router is always
the Parent, the End Device the Child.
## Device types
Furthermore, nodes comprise a number of types.
<figure class="attempt-right">
<a href="../images/ot-primer-taxonomy_2x.png"><img src="../images/ot-primer-taxonomy.png" srcset="../images/ot-primer-taxonomy.png 1x, ../images/ot-primer-taxonomy.png 2x" border="0" alt="OT Device Taxonomy" /></a>
</figure>
### Full Thread Device
A Full Thread Device (FTD) always has its radio on, subscribes to the
all-routers multicast address, and maintains IPv6 address mappings. There are
three types of FTDs:
* Router
* Router Eligible End Device (REED) — can be promoted to a Router
* Full End Device (FED) — cannot be promoted to a Router
An FTD can operate as a Router (Parent) or an End Device (Child).
### Minimal Thread Device
A Minimal Thread Device does not subscribe to the all-routers
multicast address and forwards all messages to its Parent. There are
two types of MTDs:
* Minimal End Device (MED) — transceiver always on, does not need to poll for
messages from its parent
* Sleepy End Device (SED) — normally disabled, wakes on occasion to poll for
messages from its parent
An MTD can only operate as an End Device (Child).
### Upgrading and downgrading
When a REED is the only node in reach of a new End Device wishing to join the
Thread network, it can upgrade itself and operate as a Router:
<figure>
<a href="../images/ot-primer-router-upgrade_2x.png"><img src="../images/ot-primer-router-upgrade.png" srcset="../images/ot-primer-router-upgrade.png 1x, ../images/ot-primer-router-upgrade_2x.png 2x" border="0" width="400" alt="OT End Device to Router" /></a>
</figure>
Conversely, when a Router has no children, it can downgrade itself and operate
as an End Device:
<figure>
<a href="../images/ot-primer-router-downgrade_2x.png"><img src="../images/ot-primer-router-downgrade.png" srcset="../images/ot-primer-router-downgrade.png 1x, ../images/ot-primer-router-downgrade_2x.png 2x" border="0" width="400" alt="OT Router to End Device" /></a>
</figure>
## Other roles and types
### Thread Leader
<figure class="attempt-right">
<a href="../images/ot-primer-leader_2x.png"><img src="../images/ot-primer-leader.png" srcset="../images/ot-primer-leader.png 1x, ../images/ot-primer-leader_2x.png 2x" border="0" alt="OT Leader and Border Router" /></a>
</figure>
The Thread Leader is a Router that is responsible for managing the set of
Routers in a Thread network. It is dynamically self-elected for fault tolerance,
and aggregates and distributes network-wide configuration information.
Note: There is always a single Leader in each Thread network
[partition](#partitions).
### Border Router
A Border Router is a device that can forward information between a Thread
network and a non-Thread network (for example, Wi-Fi). It also configures a
Thread network for external connectivity.
Any device may serve as a Border Router.
Note: There can be multiple Border Routers in a Thread network.
## Partitions
<figure class="attempt-right">
<a href="../images/ot-primer-partitions_2x.png"><img src="../images/ot-primer-partitions.png" srcset="../images/ot-primer-partitions.png 1x, ../images/ot-primer-partitions_2x.png 2x" border="0" alt="OT Partitions" /></a>
</figure>
A Thread network might be composed of partitions. This occurs when a group of
Thread devices can no longer communicate with another group of Thread devices.
Each partition logically operates as a distinct Thread network with its own
Leader, Router ID assignments, and network data, while retaining the same
security credentials for all devices across all partitions.
Partitions in a Thread network do not have wireless connectivity between each
other, and if partitions regain connectivity, they automatically merge into a
single partition.
Key Point: Security credentials define the Thread network. Physical radio
connectivity defines partitions within that Thread network.
Note that the use of "Thread network" in this primer assumes a single partition.
Where necessary, key concepts and examples are clarified with the term "partition."
Partitions are covered in-depth later in this primer.
## Device limits
There are limits to the number of device types a single Thread network supports.
Role | Limit
----|----
Leader | 1
Router | 32
End Device | 511 per Router
Thread tries to keep the number of Routers between 16 and 23. If a REED attaches
as an End Device and the number of Routers in the network is below 16, it
automatically promotes itself to a Router.
## Recap
What you learned:
* A Thread device is either a Router (Parent) or an End Device (Child)
* A Thread device is either a Full Thread Device (maintains IPv6 address
mappings) or a Minimal Thread Device (forwards all messages to its Parent)
* A Router Eligible End Device can promote itself to a Router, and vice versa
* Every Thread network partition has a Leader to manage Routers
* A Border Router is used to connect Thread and non-Thread networks
* A Thread network might be composed of multiple partitions
@@ -0,0 +1,176 @@
# Router Selection
## Connected Dominating Set
<figure class="attempt-right">
<a href="../images/ot-primer-cds_2x.png"><img src="../images/ot-primer-cds.png" srcset="../images/ot-primer-cds.png 1x, ../images/ot-primer-cds_2x.png 2x" width="350" border="0" alt="OT Connected Dominating Set" /></a><figcaption style="text-align: center"><i>Example of a Connected Dominating Set</i></figcaption>
</figure>
Routers must form a Connected Dominating Set (CDS), which means:
1. There is a Router-only path between any two Routers.
1. Any one Router in a Thread network can reach any other Router by staying
entirely within the set of Routers.
1. Every End Device in a Thread network is directly connected to a Router.
A distributed algorithm maintains the CDS, which ensures a minimum level of
redundancy. Every device initially attaches to the network as an End Device
(Child). As the state of the Thread network changes, the algorithm adds or
removes Routers to maintain the CDS.
Thread adds Routers to:
* Increase coverage if the network is below the Router threshold of 16
* Increase path diversity
* Maintain a minimum level of redundancy
* Extend connectivity and support more Children
Thread removes Routers to:
* Reduce the Routing state below the maximum of 32 Routers
* Allow new Routers in other parts of the network when needed
## Upgrade to a Router
After attaching to a Thread network, the Child device may elect to become a
Router. Before initiating the MLE Link Request process, the Child sends an
Address Solicit message to the Leader, asking for a Router ID. If the Leader
accepts, it responds with a Router ID and the Child upgrades itself to a Router.
The MLE Link Request process is then used to establish bi-directional
Router-Router links with neighboring Routers.
1. The new Router sends a multicast [Link Request](#1_link_request) to
neighboring Routers.
1. Routers respond with [Link Accept and Request](#2_link_accept_and_request)
messages.
1. The new Router responds to each Router with a unicast [Link
Accept](#3_link_accept) to establish the Router-Router link.
### 1. Link Request
A Link Request is a request from the Router to all other Routers in the Thread
network. When first becoming a Router, the device sends a multicast Link Request
to `ff02::2`. Later, after discovering the other Routers via MLE Advertisements,
the devices send unicast Link Requests.
<figure>
<a href="../images/ot-primer-network-mle-link-request-01_2x.png"><img src="../images/ot-primer-network-mle-link-request-01.png" srcset="../images/ot-primer-network-mle-link-request-01.png 1x, ../images/ot-primer-network-mle-link-request-01_2x.png 2x" width="350" border="0" alt="OT MLE Link Request" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Link Request Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread protocol version</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Challenge</b></td>
<td>Tests the timeliness of the Link Response to prevent replay
attacks</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>RLOC16 of the sender</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>Information about the Router's Leader, as stored on the sender (RLOC,
Partition ID, Partition weight)</td>
</tr>
</tbody>
</table>
### 2. Link Accept and Request
A Link Accept and Request is a combination of the Link Accept and Link Request
messages. Thread uses this optimization in the MLE Link Request process to
reduce the number of messages from four to three.
<figure>
<a href="../images/ot-primer-network-mle-link-request-02_2x.png"><img src="../images/ot-primer-network-mle-link-request-02.png" srcset="../images/ot-primer-network-mle-link-request-02.png 1x, ../images/ot-primer-network-mle-link-request-02_2x.png 2x" width="350" border="0" alt="OT MLE Link Accept and Request" /></a>
</figure>
### 3. Link Accept
A Link Accept is a unicast response to a Link Request from a neighboring Router
that provides information about itself and accepts the link to the neighboring
Router.
<figure>
<a href="../images/ot-primer-network-mle-link-request-03_2x.png"><img src="../images/ot-primer-network-mle-link-request-03.png" srcset="../images/ot-primer-network-mle-link-request-03.png 1x, ../images/ot-primer-network-mle-link-request-03_2x.png 2x" width="350" border="0" alt="OT MLE Link Accept" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Link Accept Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread protocol version</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Response</b></td>
<td>Tests the timeliness of the Link Response to prevent replay
attacks</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link Frame
Counter</b></td>
<td>802.15.4 Frame Counter on the sender</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>MLE Frame
Counter</b></td>
<td>MLE Frame Counter on the sender</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>RLOC16 of the sender</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>Information about the Router's Leader, as stored on the sender (RLOC,
Partition ID, Partition weight)</td>
</tr>
</tbody>
</table>
## Downgrade to a REED
When a Router downgrades to a REED, its Router-Router links are disconnected,
and the device initiates the MLE Attach process to establish a Child-Parent
link.
See [Join an existing
network](/guides/thread-primer/network-discovery#join_an_existing_network)
for more information on the MLE Attach process.
## One-way receive links
In some scenarios, it may be necessary to establish a one-way receive link.
After a Router reset, neighboring Routers may still have a valid receive link
with the reset Router. In this case, the reset Router sends a Link Request
message to re-establish the Router-Router link.
An End Device may also wish to establish a receive link with neighboring
non-Parent Routers to improve multicast reliability. We'll learn more about this
when we get to Multicast Routing.
## Recap
What you've learned:
* Routers in a Thread network must form a Connected Dominating Set (CDS)
* Thread devices are upgraded to Routers or downgraded to End Devices to
maintain the CDS
* The MLE Link Request process is used to establish Router-Router links
@@ -0,0 +1,25 @@
# 什么是 Thread
<figure class="attempt-right">
<img src="../images/ot-logo-thread.png" srcset="../images/ot-logo-thread.png 1x, ../images/ot-logo-thread_2x.png 2x" border="0" alt="Thread" />
</figure>
<a href="http://threadgroup.org/">Thread<sup>®</sup></a> 是一个为低功耗物联网(IEEE 802.15.4-2006 WPAN)设备设计的基于 IPv6 的网络协议。Thread 是一个新的网状网络协议,它并不依赖其它的 802.15 网状网络协议(如 ZigBee、Z-Wave 和 Bluetooth LE)。
Thread 的主要特性包括:
* 易于部署和维护 — 安装、启动和操作相对简单
* 通信安全 — Thread 网络中的设备都必须通过身份验证,并且所有的通信都经过了加密
* 稳定可靠 — 具有自愈能力的网状网络,无单点故障,并且采用扩频技术以提高抗干扰能力
* 低功耗 — Thread 低功耗设备可以进入休眠并使用电池供电,通常使用一块电池便能工作数年
* 规模可扩展 — Thread 网络的规模可以扩展达数百个设备
如果你不熟悉 Thread,那么了解基本的 Thread 知识对于你在应用中使用 OpenThread 是至关重要的。本入门教程的目的是解释 Thread 的基本概念和工作原理,并为你提供了 OpenThread 开发的起点。
本教程假定读者已具备如下的基本知识:
* IEEE 802.15.4
* 网络及路由概念
* IPv6
本入门教程基于 Thread Specification V1.1.1。Thread Specification 可以在 [threadgroup.org](http://threadgroup.org/ThreadSpec) 中获取。
@@ -0,0 +1,231 @@
# IPv6 寻址
让我们来看一下 Thread 如何识别网络中的每个设备,以及设备间用何种类型的地址进行相互通信。
Key Term: 在本入门教程中,术语“接口(interface)”用于标识网络内 Thread 设备的端点。通常,单个 Thread 设备具有单个 Thread 接口。
## 域
<figure class="attempt-right">
<a href="../images/ot-primer-scopes_2x.png"><img src="../images/ot-primer-scopes.png" srcset="../images/ot-primer-scopes.png 1x, ../images/ot-primer-scopes_2x.png 2x" border="0" alt="OT Scopes" /></a>
</figure>
Thread 网络中有三种域用于单播寻址:
* Link-Local — 所有通过单次射频传输可访问的接口
* Mesh-Local — 所有在同一 Thread 网络中可访问的接口
* Global — 所有从 Thread 网络外部可以访问的接口
前两个域与 Thread 网络指定的 Prefix(前缀)相对应。Link-Local 的 Prefix 为 `fe80::/16`Mesh-Local 的 Prefix 为 `fd00::/8`
<h2 style="clear:right">单播</h2>
单个 Thread 设备可以通过多种 IPv6 单播地址来进行标识。每种地址都有不同的功能(基于域和用例)。
在介绍每种类型之前,让我们先了解一个共同的概念,它叫作 RLOCRouting Locator)。RLOC 根据 Thread 接口在网络拓扑中的位置来对其进行标识。
### 如何生成 RLOC
所有设备都获得一个 Router ID 和一个 Child ID。每个 Router 维护一个包含其所有子节点的表,两个 ID 的组合唯一地标识拓扑中的设备。例如,请参考以下拓扑中高亮的节点,其中 Router(五边形)中的数字是 Router ID,End Device(圆形)中的数字是 Child ID:
<figure>
<a href="../images/ot-primer-rloc-topology_2x.png"><img src="../images/ot-primer-rloc-topology.png" srcset="../images/ot-primer-rloc-topology.png 1x, ../images/ot-primer-rloc-topology_2x.png 2x" border="0" width="600" alt="OT RLOC Topology" /></a>
</figure>
每个子节点的 Router ID 对应于它的父节点(Router)。因为 Router 不会是子节点,所以 Router 的 Child ID 始终为 0。这些值对于 Thread 网络中的每个设备都是唯一的,并用于创建 RLOC16(代表 RLOC 的后 16 位)。
例如,以下是左上节点(Router ID = 1Child ID = 1)的 RLOC16 的计算方法:
<figure>
<a href="../images/ot-primer-rloc16_2x.png"><img src="../images/ot-primer-rloc16.png" srcset="../images/ot-primer-rloc16.png 1x, ../images/ot-primer-rloc16_2x.png 2x" border="0" width="400" alt="OT RLOC16" /></a>
</figure>
RLOC16 是 IIDInterface Identifier)的一部分,IID 对应的是 IPv6 地址的后 64 位。一些 IID 可用于标识某些类型的 Thread 接口。例如,RLOC 的 IID 始终为 <code>0000:00ff:fe00:<var>RLOC16</var></code> 的形式。
RLOC 由 Mesh-Local Prefix 和 IID 组成。例如,如果 Mesh-Local Prefix 是 `fde5:8dba:82e1:1::/64`RLOC16 = `0x401`,那么该节点的 RLOC 就是:
<figure>
<a href="../images/ot-primer-rloc_2x.png"><img src="../images/ot-primer-rloc.png" srcset="../images/ot-primer-rloc.png 1x, ../images/ot-primer-rloc_2x.png 2x" border="0" width="600" alt="OT RLOC" /></a>
</figure>
可以使用相同的逻辑来确定以上示例拓扑中所有高亮的节点的 RLOC:
<figure>
<a href="../images/ot-primer-rloc-topology-address_2x.png"><img src="../images/ot-primer-rloc-topology-address.png" srcset="../images/ot-primer-rloc-topology-address.png 1x, ../images/ot-primer-rloc-topology-address_2x.png 2x" border="0" width="600" alt="OT Topology w/ Address" /></a>
</figure>
但是,因为 RLOC 是基于节点在拓扑中的位置的,所以节点的 RLOC 会随着拓扑的变化而改变。
例如,如果 Thread 网络中的 `0x400` 节点离开了网络,那么它的子节点 `0x401``0x402` 会与其它的 Router 建立新连接,从而获得新的 RLOC16 和 RLOC
<figure>
<a href="../images/ot-primer-rloc-topology-change_2x.png"><img src="../images/ot-primer-rloc-topology-change.png" srcset="../images/ot-primer-rloc-topology-change.png 1x, ../images/ot-primer-rloc-topology-change_2x.png 2x" border="0" width="600" alt="OT Topology after Change" /></a>
</figure>
## 单播地址类型
RLOC 只是 Thread 设备可以获得的多种 IPv6 单播地址之一。另一类用于在 Thread 网络分区内标识唯一的 Thread 接口的地址称为 EIDEndpoint Identifier)。EID 与 Thread 网络拓扑无关。
常见的单播类型如下。
<table>
<tbody>
<tr>
<th colspan=2><h3>Link-Local Address (LLA)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">一种用于标识单次射频传输可访问的 Thread 接口的 EID。</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>示例</b></td><td><code>fe80::54db:881c:3845:57f4</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td>基于 802.15.4 Extended Address</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>域</b></td><td>Link-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>详情</b></td><td><ul><li>用于发现邻居、配置链路和交换路由信息</li><li>非可路由地址</li><li>总是带 <code>fe80::/16</code> Prefix</li></ul></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Mesh-Local EID (ML-EID)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">一种用于标识 Thread 接口的 EID,其与网络拓扑无关。用于访问同一 Thread 分区内的 Thread 接口。也称为 ULAUnique Local Address)。</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>示例</b></td><td><code>fde5:8dba:82e1:1:416:993c:8399:35ab</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td>在 commissioning 完成后随机生成</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>域</b></td><td>Mesh-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>详情</b></td><td><ul><li>不会随拓扑变化而变化</li><li>应由应用程序使用</li><li>总是带 <code>fd00::/8</code> Prefix</li></ul></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Routing Locator (RLOC)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">根据 Thread 接口在网络拓扑中的位置来对其进行标识。</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>示例</b></td><td><code>fde5:8dba:82e1:1::ff:fe00:1001</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td><code>0000:00ff:fe00:<var>RLOC16</var></code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>域</b></td><td>Mesh-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>详情</b></td><td><ul><li>在设备连接到网络后生成</li><li>用于在 Thread 网络中传递 IPv6 数据报</li><li>随拓扑变化而变化</li><li>通常不会由应用程序使用</li></ul></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Anycast Locator (ALOC)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">用于标识 Thread 网络分区中一个或多个 Thread 接口的位置。如果始发者不知道目的地的 RLOC,则使用 ALOC 进行查找。</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>示例</b></td><td><code>fde5:8dba:82e1:1::ff:fe00:fc01</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td><code>0000:00ff:fe00:fc<var>XX</var></code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>域</b></td><td>Mesh-Local</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>详情</b></td><td><ul><li><code>fc<var>XX</var></code> = <a href="#anycast">ALOC 目的地址</a>,用于查询对应的 RLOC</li><li>通常不会由应用程序使用</li></td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<th colspan=2><h3>Global Unicast Address (GUA)</h3></th>
</tr>
<tr>
<td colspan=2 style="background-color:rgb(238, 241, 242)">一个EID,用于标识除 Thread 网络外的全局范围内的 Thread 接口。</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>示例</b></td><td><code>2000::54db:881c:3845:57f4</code></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>IID</b></td><td><ul><li>SLAAC — 由设备自身随机分配</li><li>DHCP — 由 DHCPv6 服务器分配</li><li>Manual — 由应用层分配</li></ul></td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>域</b></td><td>Global</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>详情</b></td><td><ul><li>一个公开的 IPv6 地址</li><li>总是带 <code>2000::/3</code> Prefix</li></td>
</tr>
</tbody>
</table>
## 多播
多播用于一次将信息传达给多个设备。Thread 网络中保留了特定的地址,以提供给不同分组的设备在多播时使用。
| IPv6 地址 | 域 | 传递给 |
| --------- | ---------- | --------------- |
| `ff02::1` | Link-Local | 所有 FTD 和 MED |
| `ff02::2` | Link-Local | 所有 FTD |
| `ff03::1` | Mesh-Local | 所有 FTD 和 MED |
| `ff03::2` | Mesh-Local | 所有 FTD |
Key Point: FTD 和 MTD 之间的主要区别在于 FTD 订阅了 `ff03::2` 多播地址。而 MTD 没有订阅。
你可能会注意到,上面的多播表中没有将 SED 作为接收者包括在内。Thread 为所有 Thread 节点(包括 SED)定义了(link-local 和 realm-local 域)基于单播 prefix 的 IPv6 多播地址。这些多播地址基于单播 Mesh-Local prefix 构成,因 Thread 网络而异。(有关基于单播 prefix 的 IPv6 多播地址的详情,请参阅 [RFC 3306](https://tools.ietf.org/html/rfc3306))。
Thread 设备还支持除表中所列举域之外的任意域。
## 任播
当目的地的 RLOC 未知时,可以使用任播将流量路由到 Thread 接口。ALOCAnycast Locator)标识 Thread 分区内多个接口的位置。ALOC 的后 16 位,称为 ALOC16,其格式为 <code>0xfc<var>XX</var></code>,表示 ALOC 的类型。
例如,`0xfc01``0xfc0f` 之间的 ALOC16 保留给了 DHCPv6 Agent。如果特定的 DHCPv6 Agent RLOC 是未知的(可能是因为网络拓扑已更改),则可以将消息发送到 DHCPv6 Agent ALOC 以获取 RLOC。
Thread 定义了以下 ALOC16 值:
| ALOC16 | 类型 |
| ------------------------------------------ | ------------------------ |
| `0xfc00` | Leader |
| `0xfc01` `0xfc0f` | DHCPv6 Agent |
| `0xfc10` `0xfc2f` | Service |
| `0xfc30` `0xfc37` | Commissioner |
| `0xfc40` `0xfc4e` | Neighbor Discovery Agent |
| `0xfc38` `0xfc3f`<br>`0xfc4f` `0xfcff` | Reserved |
## 回顾
你应该学到了:
* Thread 网络包含三个域:Link-Local、Mesh-Local 和 Global
* Thread 设备具有多种单播 IPv6 地址
* RLOC 表示设备在 Thread 网络中的位置
* ML-EID 对于分区内的 Thread 设备是唯一的,并且应由应用程序使用
* Thread 使用多播将数据转发到节点组和 Router 组
* 当目的地的 RLOC 未知时,Thread 可以使用任播
要了解有关 Thread 的 IPv6 寻址的更多信息,请参阅 [Thread Specification](http://threadgroup.org/ThreadSpec) 的 5.2 和 5.3 节。
@@ -0,0 +1,254 @@
# 网络发现与形成
## Thread 网络
Thread 网络由三个唯一的标识符标识:
* 2 字节的 PAN IDPersonal Area Network ID,个域网标识符)
* 8 字节的 XPAN IDExtended Personal Area Network ID,扩展个域网标识符)
* 方便人类阅读的 Network Name(网络名称)
例如,一个 Thread 网络可能具有以下标识符:
| 标识符 | 值 |
| ------------ | -------------------- |
| PAN ID | `0xBEEF` |
| XPAN ID | `0xBEEF1111CAFE2222` |
| Network Name | `yourThreadCafe` |
<figure class="attempt-right">
<a href="../images/ot-primer-network-active-scan_2x.png"><img src="../images/ot-primer-network-active-scan.png" srcset="../images/ot-primer-network-active-scan.png 1x, ../images/ot-primer-network-active-scan_2x.png 2x" border="0" alt="OT Active Scan" /></a>
</figure>
在创建新的 Thread 网络或搜索现有的网络时,Thread 设备会主动扫描射频范围内的 802.15.4 网络:
1. 设备在特定 Channel 上广播 802.15.4 信标请求(Beacon Request)。
2. 范围内的所有 Router 或 REED 都会广播包含其 Thread 网络 PAN ID、XPAN ID 和 Network Name 的信标(Beacon),以作为回应。
3. 设备为每个 Channel 重复前两个步骤。
Thread 设备发现范围内的所有网络后,可以选择连接到现有的网络,也可以在未发现任何网络的情况下创建新的网络。
<h2 style="clear:right">Mesh Link Establishment</h2>
Thread 使用 MLEMesh Link Establishment)协议来配置链路并将网络的相关信息传播到 Thread 设备。
在链路配置中,MLE 用于:
* 发现相邻设备的链路
* 确认到相邻设备的链路质量
* 建立到相邻设备的链路
* 与对端协商链路参数(设备类型、帧计数器、超时)
MLE 将以下类型的信息传播给希望建立链路的设备:
* Leader dataLeader RLOC, Partition ID(分区标识符), Partition weight(分区权重))
* Network dataon-mesh prefixes, address autoconfiguration(地址自动配置), more-specific routes(具体路由))
* Route propagation(路由传播)
Thread 中路由传播的工作原理类似于 RIPRouting Information Protocol,路由信息协议),RIP 是一种距离矢量路由协议。
Note: 仅当 Thread 设备通过 Thread Commissioning 获得 Thread 网络凭据后,才会继续进行 MLE 过程。Commissioning 和安全性将在本教程的后续部分中深入介绍。目前,假定设备已通过 Commissioning。
## 创建新网络
如果设备选择创建新网络,它将选择最不繁忙的 Channel 和其他网络未使用的 PAN ID,然后成为 Router 并选举自己为 Leader。该设备将 MLE Advertisement 消息发送到其他 802.15.4 设备,以通知其链路状态,并响应其他执行主动扫描的 Thread 设备所发出的信标请求。
## 加入现有网络
如果设备选择加入到现有的网络,则会通过 Thread Commissioning 将其 Channel、PAN ID、XPAN ID 和 Network Name 配置为与目标网络相同,然后进行 MLE Attach 过程以作为子节点(End Device)进行加入。此过程用于“父子链路(Child-Parent link)”。
Key Point: 每个设备(无论是否具有充当 Router 的能力),最初都作为子设备(End Device)连接到 Thread 网络。
1. 子节点向目标网络中的所有相邻的 Router 和 REED 发送多播 [Parent Request](#1-Parent-Request)。
2. 所有相邻的 Router 和 REED(如果 Parent Request Scan Mask(父节点请求扫描掩码)包括了 REED)都应发送 [Parent Response](#2-Parent-Response) 以将其自身的信息告诉给子节点。
3. 子节点选择一个父节点,并向其发送 [Child ID Request](#3-Child-ID-Request)。
4. 父节点发送 [Child ID Response](#4-Child-ID-Response) 以确认链路建立。
### 1. Parent Request
Parent Request 是来自待连接设备的多播请求,用于发现目标网络中的相邻的 Router 和 REED。
<figure>
<a href="../images/ot-primer-network-mle-attach-01_2x.png"><img src="../images/ot-primer-network-mle-attach-01.png" srcset="../images/ot-primer-network-mle-attach-01.png 1x, ../images/ot-primer-network-mle-attach-01_2x.png 2x" width="350" border="0" alt="OT MLE Attach Parent Request" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Parent Request Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Mode</b></td>
<td>描述待连接设备</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Challenge</b></td>
<td>测试 Parent Response 的时效性,以防止重放攻击</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Scan Mask</b></td>
<td>将请求限制为仅 Router 或 Router 和 REED</td>
</tr>
</tbody>
</table>
### 2. Parent Response
Parent Response 是对 Parent Request 的单播响应,它向待连接设备提供有关 Router 或 REED 的信息。
<figure>
<a href="../images/ot-primer-network-mle-attach-02_2x.png"><img src="../images/ot-primer-network-mle-attach-02.png" srcset="../images/ot-primer-network-mle-attach-02.png 1x, ../images/ot-primer-network-mle-attach-02_2x.png 2x" width="350" border="0" alt="OT MLE Attach Parent Response" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Parent Response Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread 协议版本</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Response</b></td>
<td>Parent Request Challenge 的副本</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link Frame
Counter</b></td>
<td>Router/REED 上的 802.15.4 帧计数器</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>MLE Frame
Counter</b></td>
<td>Router/REED 上的 MLE 帧计数器</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>Router/REED 的 RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link
Margin</b></td>
<td>Router/REED 的接收信号质量</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Connectivity</b></td>
<td>描述 Router/REED 的连通性</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>有关 Router/REED 的 Leader 的信息</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Challenge</b></td>
<td>测试 Child ID Request 的时效性,以防止重放攻击</td>
</tr>
</tbody>
</table>
### 3. Child ID Request
Child ID Request 是来自待连接设备(子)的单播请求,该单播请求被发送到 Router(父)或 REED(父),目的是建立父子链路。如果将请求发送到 REED,则 REED 会在接受请求之前将自身升级为 Router。
<figure>
<a href="../images/ot-primer-network-mle-attach-03_2x.png"><img src="../images/ot-primer-network-mle-attach-03.png" srcset="../images/ot-primer-network-mle-attach-03.png 1x, ../images/ot-primer-network-mle-attach-03_2x.png 2x" width="350" border="0" alt="OT MLE Attach Child ID Request" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Child ID Request Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread 协议版本</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Response</b></td>
<td>Parent Response Challenge 的副本</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link Frame
Counter</b></td>
<td>Child 上的 802.15.4 帧计数器</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>MLE Frame
Counter</b></td><td>Child 上的 MLE 帧计数器</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Mode</b></td>
<td>描述子节点</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Timeout</b></td>
<td>父节点移除子节点之前的闲置时间</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Address
Registration (MEDs and SEDs only)</b></td>
<td>注册 IPv6 地址</td>
</tr>
</tbody>
</table>
### 4. Child ID Response
Child ID Response 是父节点对 Child ID Request 的单播响应,该响应发送给对应的子节点以确认父子链路的建立。
<figure>
<a href="../images/ot-primer-network-mle-attach-04_2x.png"><img src="../images/ot-primer-network-mle-attach-04.png" srcset="../images/ot-primer-network-mle-attach-04.png 1x, ../images/ot-primer-network-mle-attach-04_2x.png 2x" width="350" border="0" alt="OT MLE Attach Child ID Response" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Child ID Response Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>父节点的 RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Address16</b></td>
<td>子节点的 RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>父节点的 Leader 的相关信息(RLOC, Partition ID, Partition weight</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Network
Data</b></td>
<td>Thread 网络的相关信息(on-mesh prefixes, address autoconfiguration, more-specific routes</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Route
(REED only)</b></td>
<td>路由传播</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Timeout</b></td>
<td>父节点移除子节点之前的闲置时间</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Address
Registration (MEDs and SEDs only)</b></td>
<td>确认已注册地址</td>
</tr>
</tbody>
</table>
## 回顾
你应该学到了:
* Thread 设备通过主动扫描发现现有网络
* Thread 使用 MLE 来配置链路并分发有关网络设备的信息
* MLE Advertisement 消息通知其他 Thread 设备有关设备的网络和链路状态
* MLE Attach 过程建立了父子链路
@@ -0,0 +1,125 @@
# 节点角色和类型
## 转发角色
<figure class="attempt-right">
<a href="../images/ot-primer-roles_2x.png"><img src="../images/ot-primer-roles.png" srcset="../images/ot-primer-roles.png 1x, ../images/ot-primer-roles_2x.png 2x" border="0" alt="OT Node Roles" /></a>
</figure>
在 Thread 网络中,节点分成两种转发角色:Router 和 End Device。
### Router
Router 节点的行为如下:
* 为网络设备转发数据包
* 为尝试加入网络的设备提供安全的 commissioning 服务
* 始终打开它的收发器
### End Device
End Device 节点的行为如下:
* 主要与单个 Router 进行通信
* 不会为其他网络设备转发数据包
* 可以关闭它的收发器来降低功耗
Key Point: Router 和 End Device 之间的关系称为父子关系。End Device 正确地依附到一个 Router 上,其中 Router 始终作为父节点,End Device 则始终是子节点。
## 设备类型
此外,节点有许多种类型。
<figure class="attempt-right">
<a href="../images/ot-primer-taxonomy_2x.png"><img src="../images/ot-primer-taxonomy.png" srcset="../images/ot-primer-taxonomy.png 1x, ../images/ot-primer-taxonomy.png 2x" border="0" alt="OT Device Taxonomy" /></a>
</figure>
### Full Thread Device
一个 FTDFull Thread Device)总是打开它的射频收发器,它订阅所有 Router 的多播地址,并维护 IPv6 地址映射。FTD 有三种类型:
* Router
* REEDRouter Eligible End Device)— 可以升级为 Router
* FEDFull End Device)— 无法升级为 Router
FTD 可以作为 Router(父)或 End Device(子)。
### Minimal Thread Device
MTDMinimal Thread Device)不会订阅 all-routers 多播地址,并且它会将它的所有消息发送给它的父节点。MTD 有两种类型:
* MEDMinimal End Device)— 始终打开自身的收发器,无需从父节点中轮询消息
* SEDSleepy End Device)— 通常会关闭自身的收发器(睡眠),偶然会打开收发器(唤醒)以从父节点中轮询消息
MTD 只能作为 End Device(子)。
### 升级和降级
当待加入设备仅能与某个 REED 通信时, 则该 REED 可以升级成为 Router
<figure>
<a href="../images/ot-primer-router-upgrade_2x.png"><img src="../images/ot-primer-router-upgrade.png" srcset="../images/ot-primer-router-upgrade.png 1x, ../images/ot-primer-router-upgrade_2x.png 2x" border="0" width="400" alt="OT End Device to Router" /></a>
</figure>
相反,当一个 Router 没有子节点时,它可以降级成 End Device:
<figure>
<a href="../images/ot-primer-router-downgrade_2x.png"><img src="../images/ot-primer-router-downgrade.png" srcset="../images/ot-primer-router-downgrade.png 1x, ../images/ot-primer-router-downgrade_2x.png 2x" border="0" width="400" alt="OT Router to End Device" /></a>
</figure>
## 其他角色和类型
### Thread Leader
<figure class="attempt-right">
<a href="../images/ot-primer-leader_2x.png"><img src="../images/ot-primer-leader.png" srcset="../images/ot-primer-leader.png 1x, ../images/ot-primer-leader_2x.png 2x" border="0" alt="OT Leader and Border Router" /></a>
</figure>
Thread Leader 是一个 Router,它负责管理 Thread 网络中的 Router。Thread Leader 是动态自选的(提高容错率),它负责汇总和分发全网络的配置信息。
Note: 每个 Thread 网络[分区](#分区)中总是只有一个 Leader。
### Border Router
Border Router 是一种可以在 Thread 网络和其他网络(如 Wi-Fi)之间转发信息的设备。它还为外部连接配置 Thread 网络。
任何设备都可以充当 Border Router。
Note: 一个 Thread 网络中可以有多个 Border Router。
## 分区
<figure class="attempt-right">
<a href="../images/ot-primer-partitions_2x.png"><img src="../images/ot-primer-partitions.png" srcset="../images/ot-primer-partitions.png 1x, ../images/ot-primer-partitions_2x.png 2x" border="0" alt="OT Partitions" /></a>
</figure>
一个 Thread 网络可能由多个分区组成。当一组 Thread 设备不能再与另一组 Thread 设备通信时,会发生这种情况。每个分区在逻辑上均作为独立的 Thread 网络来运行,它们具有各自的 Leader、Router ID 分配和网络数据,同时分区前相同的安全凭证都将被保留下来。
当分区之间可以连通时,它们会自动合并。
Key Point: 安全凭证(security credentials)定义了 Thread 网络。物理无线电的连通性定义了该 Thread 网络中的分区。
请注意,在本入门教程中一般将 Thread 网络假定成单个分区。在必要时,将使用“分区”一词来阐明关键概念和示例。本教程稍后将详细介绍分区。
## 设备限制
单个 Thread 网络所支持的设备类型数量是有限制的。
| 角色 | 限制 |
| ---------- | ------------------ |
| Leader | 1 |
| Router | 32 |
| End Device | 511(每个 Router |
Thread 会尝试将 Router 的数量保持在 16 ~ 23 之间。如果一个 REED 作为 End Device 加入,并且网络中的 Router 数量低于 16,那么它将自动升级为 Router。
## 回顾
你应该学到了:
* Thread 设备可以是 Router(父)或 End Device(子)
* Thread 设备可以是 FTD(维护 IPv6 地址映射),也可以是 MTD(将所有消息发送给其父节点)
* REED 可以升级为 RouterRouter 也可以降级为 REED
* 每个 Thread 网络分区都有一个 Leader 来管理 Router
* Border Router 用于连接 Thread 和其他网络
* 一个 Thread 网络可能由多个分区组成
@@ -0,0 +1,145 @@
# Router 选择
## Connected Dominating Set
<figure class="attempt-right">
<a href="../images/ot-primer-cds_2x.png"><img src="../images/ot-primer-cds.png" srcset="../images/ot-primer-cds.png 1x, ../images/ot-primer-cds_2x.png 2x" width="350" border="0" alt="OT Connected Dominating Set" /></a><figcaption style="text-align: center"><i>Example of a Connected Dominating Set</i></figcaption>
</figure>
Router 必须形成一个 CDSConnected Dominating Set,连接支配集),这意味着:
1. 在任何两个 Router 之间都有一个 Router-only 的路径。
2. Thread 网络中的任何一个 Router 都可以通过完全位于 Router 集中而到达其他任何 Router。
3. Thread 网络中的每个 End Device 都直接连接到 Router。
Thread 使用分布式算法维护 CDS,从而确保最低程度的冗余。每个设备最初都作为 End Device(子)连接到网络。随着 Thread 网络状态的更改,算法会增添或移除 Router 以维护 CDS。
Thread 在下列情况下将会增添 Router:
* 如果网络低于 Router 阈值(16) —— 为了增加覆盖范围
* 增加路径多样性
* 保持最低程度的冗余
* 扩展连接并支持更多子节点
Thread 在下列情况下将会移除 Router:
* 将路由状态减少到最多 32 个 Router 以下
* 必要时允许在网络的其他部分使用新 Router
## 升级成 Router
子设备连接到 Thread 网络后,可以选择成为 Router。在开始 MLE Link Request 过程之前,子设备会向 Leader 发送 Address Solicit 消息,以请求一个 Router ID。如果 Leader 同意该请求,则它将响应一个 Router ID 给子设备,并且子设备会将自身升级为 Router。
然后,MLE Link Request 过程用于与相邻的 Router 建立双向 Router-Router 链路。
1. 新 Router 将发送一个多播 [Link Request](#1-Link-Request) 到相邻的 Router。
2. Router 使用 [Link Accept and Request](#2-Link-Accept-and-Request) 消息进行响应。
3. 新 Router 使用单播的 [Link Accept](#3-Link-Accept) 响应每个 Router,以建立 Router-Router 链路。
### 1. Link Request
Link Request 是从 Router 到 Thread 网络中所有其他 Router 的请求。首次成为 Router 时,设备会发送一个多播 Link Request 到 `ff02::2`。稍后,在通过 MLE Advertisement 发现其他 Router 后,设备将发送单播的 Link Request。
<figure>
<a href="../images/ot-primer-network-mle-link-request-01_2x.png"><img src="../images/ot-primer-network-mle-link-request-01.png" srcset="../images/ot-primer-network-mle-link-request-01.png 1x, ../images/ot-primer-network-mle-link-request-01_2x.png 2x" width="350" border="0" alt="OT MLE Link Request" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Link Request Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread 协议版本</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Challenge</b></td>
<td>测试 Link Response 的及时性,以防止重放攻击</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>发送者的 RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>Router 的 Leader 的相关信息(RLOC, Partition ID, Partition weight</td>
</tr>
</tbody>
</table>
### 2. Link Accept and Request
Link Accept and Request 是 Link Accept 和 Link Request 消息的组合。Thread 在 MLE Link Request 过程中使用此优化将消息的数量从四减少到三。
<figure>
<a href="../images/ot-primer-network-mle-link-request-02_2x.png"><img src="../images/ot-primer-network-mle-link-request-02.png" srcset="../images/ot-primer-network-mle-link-request-02.png 1x, ../images/ot-primer-network-mle-link-request-02_2x.png 2x" width="350" border="0" alt="OT MLE Link Accept and Request" /></a>
</figure>
### 3. Link Accept
Link Accept 是对来自相邻 Router 的 Link Request 的单播响应,该响应提供有关自身的信息并接受到相邻 Router 的链路。
<figure>
<a href="../images/ot-primer-network-mle-link-request-03_2x.png"><img src="../images/ot-primer-network-mle-link-request-03.png" srcset="../images/ot-primer-network-mle-link-request-03.png 1x, ../images/ot-primer-network-mle-link-request-03_2x.png 2x" width="350" border="0" alt="OT MLE Link Accept" /></a>
</figure>
<table>
<tbody>
<tr>
<th colspan=2>Link Accept Message Contents</th>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Version</b></td>
<td>Thread 协议版本</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Response</b></td>
<td>测试 Link Response 的及时性,以防止重放攻击</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Link Frame
Counter</b></td>
<td>发送者上的 802.15.4 帧计数器</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>MLE Frame
Counter</b></td>
<td>发送者上的 MLE 帧计数器</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Source
Address</b></td>
<td>发送者的 RLOC16</td>
</tr>
<tr>
<td width="25%" style="background-color:rgb(238, 241, 242)"><b>Leader
Data</b></td>
<td>Router 的 Leader 的相关信息(RLOC, Partition ID, Partition weight</td>
</tr>
</tbody>
</table>
## 降级成 REED
当 Router 降级成 REED 时,其 Router-Router 链路断开,并且设备开始 MLE Attach 过程以建立父子链路。
有关 MLE Attach 过程的更多信息,请参阅 [加入现有网络](/guides/thread-primer/network-discovery#加入现有网络)。
## 单向接收链路
在某些情况下,建立单向接收链路是有必要的。
在 Router 重置后,相邻 Router 可能仍具有与重置的 Router 的有效接收链路。在这种情况下,重置的 Router 发送 Link Request 消息以重新建立 Router-Router 链路。
End Device 也可能希望与相邻的 Router(非父节点)建立接收链路,以提高多播可靠性。当我们进入多播路由时,我们将学习更多与此相关的内容。
## 回顾
你应该学到了:
* Thread 网络中的 Router 必须形成 CDS
* Thread 设备将升级成 Router 或降级成 REED 以维护 CDS
* MLE Link Request 过程用于建立 Router-Router 链路
+29
View File
@@ -0,0 +1,29 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
configure_file(${PROJECT_SOURCE_DIR}/etc/cmake/openthread-config-generic.h.in ${PROJECT_BINARY_DIR}/etc/cmake/openthread-config-generic.h)
+43
View File
@@ -0,0 +1,43 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
# Get a list of the available platforms and output as a list to the 'arg_platforms' argument
function(ot_get_platforms arg_platforms)
list(APPEND result "NO" "posix")
set(platforms_dir "${PROJECT_SOURCE_DIR}/examples/platforms")
file(GLOB platforms RELATIVE "${platforms_dir}" "${platforms_dir}/*")
foreach(platform IN LISTS platforms)
if(IS_DIRECTORY "${platforms_dir}/${platform}")
list(APPEND result "${platform}")
endif()
endforeach()
list(REMOVE_ITEM result utils)
list(SORT result)
set(${arg_platforms} "${result}" PARENT_SCOPE)
endfunction()
+27
View File
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2019, The OpenThread Authors.
* 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.
*/
+277
View File
@@ -0,0 +1,277 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
option(OT_APP_CLI "enable CLI app" ON)
option(OT_APP_NCP "enable NCP app" ON)
option(OT_APP_RCP "enable RCP app" ON)
option(OT_ASSERT "enable assert function OT_ASSERT()" ON)
if(OT_ASSERT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=1")
else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ASSERT_ENABLE=0")
endif()
option(OT_BACKBONE_ROUTER "enable backbone router functionality")
if(OT_BACKBONE_ROUTER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1")
endif()
option(OT_BORDER_AGENT "enable border agent support")
if(OT_BORDER_AGENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE=1")
endif()
option(OT_BORDER_ROUTER "enable border router support")
if(OT_BORDER_ROUTER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_BORDER_ROUTER_ENABLE=1")
endif()
if(NOT OT_EXTERNAL_MBEDTLS)
set(OT_MBEDTLS mbedtls)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=1")
else()
set(OT_MBEDTLS ${OT_EXTERNAL_MBEDTLS})
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS=0")
endif()
option(OT_BUILTIN_MBEDTLS_MANAGEMENT "enable builtin mbedtls management" ON)
if(OT_BUILTIN_MBEDTLS_MANAGEMENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=1")
else()
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=0")
endif()
option(OT_CHANNEL_MANAGER "enable channel manager support")
if(OT_CHANNEL_MANAGER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE=1")
endif()
option(OT_CHANNEL_MONITOR "enable channel monitor support")
if(OT_CHANNEL_MONITOR)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHANNEL_MONITOR_ENABLE=1")
endif()
option(OT_CHILD_SUPERVISION "enable child supervision support")
if(OT_CHILD_SUPERVISION)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1")
endif()
option(OT_COAP "enable coap api support")
if(OT_COAP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_API_ENABLE=1")
endif()
option(OT_COAPS "enable secure coap api support")
if(OT_COAPS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1")
endif()
option(OT_COAP_OBSERVE "enable coap observe (RFC7641) api support")
if(OT_COAP_OBSERVE)
list(APPEND OT_PRIVATE_DEFINES "OPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1")
endif()
option(OT_COMMISSIONER "enable commissioner support")
if(OT_COMMISSIONER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1")
endif()
option(OT_CSL_RECEIVER "enable csl receiver")
if(OT_CSL_RECEIVER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1")
endif()
option(OT_DHCP6_CLIENT "enable DHCP6 client support")
if(OT_DHCP6_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_CLIENT_ENABLE=1")
endif()
option(OT_DHCP6_SERVER "enable DHCP6 server support")
if(OT_DHCP6_SERVER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DHCP6_SERVER_ENABLE=1")
endif()
option(OT_DIAGNOSTIC "enable diagnostic support")
if(OT_DIAGNOSTIC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DIAG_ENABLE=1")
endif()
option(OT_DNS_CLIENT "enable DNS client support")
if(OT_DNS_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1")
endif()
option(OT_ECDSA "enable ECDSA support")
if(OT_ECDSA)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_ECDSA_ENABLE=1")
endif()
option(OT_DUA "enable Domain Unicast Address feature for Thread 1.2")
if(OT_DUA)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_DUA_ENABLE=1")
endif()
option(OT_MLR "enable Multicast Listener Registration feature for Thread 1.2")
if(OT_MLR)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLR_ENABLE=1")
endif()
option(OT_EXTERNAL_HEAP "enable external heap support")
if(OT_EXTERNAL_HEAP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE=1")
endif()
option(OT_IP6_FRAGM "enable ipv6 fragmentation support")
if(OT_IP6_FRAGM)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_FRAGMENTATION_ENABLE=1")
endif()
option(OT_JAM_DETECTION "enable jam detection support")
if(OT_JAM_DETECTION)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JAM_DETECTION_ENABLE=1")
endif()
option(OT_JOINER "enable joiner support")
if(OT_JOINER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_JOINER_ENABLE=1")
endif()
option(OT_LEGACY "enable legacy network support")
if(OT_LEGACY)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LEGACY_ENABLE=1")
endif()
option(OT_LINK_RAW "enable link raw service")
if(OT_LINK_RAW)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LINK_RAW_ENABLE=1")
endif()
option(OT_LOG_LEVEL_DYNAMIC "enable dynamic log level control")
if(OT_LOG_LEVEL_DYNAMIC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1")
endif()
option(OT_MAC_FILTER "enable mac filter support")
if(OT_MAC_FILTER)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1")
endif()
option(OT_MLE_LONG_ROUTES "enable MLE long routes extension (experimental, breaks Thread conformance)")
if(OT_MLE_LONG_ROUTES)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1")
endif()
option(OT_MTD_NETDIAG "enable TMF network diagnostics on MTDs")
if(OT_MTD_NETDIAG)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1")
endif()
option(OT_MULTIPLE_INSTANCE "enable multiple instances")
if(OT_MULTIPLE_INSTANCE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1")
endif()
option(OT_PLATFORM_NETIF "enable platform netif support")
if(OT_PLATFORM_NETIF)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE=1")
endif()
option(OT_PLATFORM_UDP "enable platform UDP support")
if(OT_PLATFORM_UDP)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1")
endif()
option(OT_REFERENCE_DEVICE "enable Thread Test Harness reference device support")
if(OT_REFERENCE_DEVICE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE=1")
endif()
option(OT_SERVICE "enable support for injecting Service entries into the Thread Network Data")
if(OT_SERVICE)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TMF_NETDATA_SERVICE_ENABLE=1")
endif()
option(OT_SETTINGS_RAM "enable volatile-only storage of settings")
if(OT_SETTINGS_RAM)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_SETTINGS_RAM=1")
endif()
option(OT_SLAAC "enable support for adding of auto-configured SLAAC addresses by OpenThread")
if(OT_SLAAC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_IP6_SLAAC_ENABLE=1")
endif()
option(OT_SNTP_CLIENT "enable SNTP Client support")
if(OT_SNTP_CLIENT)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1")
endif()
option(OT_TIME_SYNC "enable the time synchronization service feature")
if(OT_TIME_SYNC)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1")
endif()
option(OT_UDP_FORWARD "enable UDP forward support")
if(OT_UDP_FORWARD)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_UDP_FORWARD_ENABLE=1")
endif()
option(OT_FULL_LOGS "enable full logs")
if(OT_FULL_LOGS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_API=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_ARP=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_BBR=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_CLI=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_COAP=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_DUA=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_ICMP=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_IP6=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MAC=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MEM=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MESHCOP=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MLE=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MLR=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_NETDATA=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_NETDIAG=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PKT_DUMP=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PLATFORM=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL=1")
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PREPEND_REGION=1")
endif()
option(OT_OTNS "enable OTNS support")
if(OT_OTNS)
target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_OTNS_ENABLE=1")
endif()
# Checks
if(OT_PLATFORM_UDP AND OT_UDP_FORWARD)
message(FATAL_ERROR "OT_PLATFORM_UDP and OT_UDP_FORWARD are exclusive")
endif()
+6 -6
View File
@@ -1,7 +1,7 @@
VERSION=0.1
all: arm32v7_linux x86_linux sim
all: arm32v7_linux x86_linux simulation
arm32v7_linux: arm32v7_ubuntu_wpantund
docker build -t openthread/wpantund_arm32v7_linux arm32v7_ubuntu_wpantund && \
@@ -15,11 +15,11 @@ x86_linux: x86_ubuntu_wpantund
docker tag openthread/wpantund_amd64_linux openthread/wpantund_amd64_linux:$(VERSION) && \
docker push openthread/wpantund_amd64_linux:$(VERSION)
sim: ot_sim
docker build -t openthread/sim ot_sim && \
docker push openthread/sim && \
docker tag openthread/sim openthread/sim:$(VERSION) && \
docker push openthread/sim:$(VERSION)
simulation: ot_simulation
docker build -t openthread/simulation ot_sim && \
docker push openthread/simulation && \
docker tag openthread/simulation openthread/simulation:$(VERSION) && \
docker push openthread/simulation:$(VERSION)
publish_manifest:
docker manifest create openthread/wpantund openthread/wpantund_arm32v7_linux openthread/wpantund_amd64_linux
-34
View File
@@ -1,34 +0,0 @@
## Running wpantund from a Docker container:
For a device that has a Thread radio attached to port `/dev/ttyUSB0`, start `wpantund` as follows:
```
docker run --rm --detach -e "OPENTHREAD_DEVICE_PORT=/dev/ttyUSB0" --cap-add=NET_ADMIN --device=/dev/ttyUSB0 --name=wpantund openthread/wpantund
```
Once `wpantund` is running, one can control the Thread interface with `wpanctl` as follows:
```
docker exec -it wpantund wpanctl
```
## Content
arm32v7_ubuntu_wpantund
- `wpantund` running on ARMv7 (e.g. Raspberry Pi)
x86_ubuntu_wpantund
- `wpantund` running on x86
ot_sim
- OpenThread POSIX simulator
codelab_otsim
- For use with the [Docker Simulation Codelab](https://codelabs.developers.google.com/codelabs/openthread-simulation/), contains the OpenThread POSIX example and `wpantund` pre-built and ready to use.
environment
- Development environment with the GNU toolchain and all required OpenThread dependencies installed. OpenThread is not built in this image.
Images built from these Dockerfiles are available to pull from [Docker Hub](https://hub.docker.com/u/openthread/). See [Docker Support on openthread.io](https://openthread.io/guides#docker_support) for more information.
+105
View File
@@ -0,0 +1,105 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
#
# Ubuntu 14.04 with tools required to run OpenThread Android check
#
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
ENV ANDROID_JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64
ENV OPT_BIN=/opt/bin
ENV PATH=$OPT_BIN:$PATH
ENV ANDROID_NDK_PATH=/opt/ndk-bundle
WORKDIR /build
RUN apt-get -y update && apt-get --no-install-recommends install -y \
gcc-multilib \
g++-multilib \
git \
make \
python \
unzip \
wget
RUN wget https://dl.google.com/android/repository/android-ndk-r17c-linux-x86_64.zip \
&& unzip android-ndk-r17c-linux-x86_64.zip > /dev/null \
&& mv android-ndk-r17c $ANDROID_NDK_PATH \
&& rm android-ndk-r17c-linux-x86_64.zip
# Android build system
RUN mkdir build && cd build && git init && git pull --depth 1 https://android.googlesource.com/platform/build 2db32730e79cafcf13e1f898a7bee7f82b0449d6
RUN ln -s build/core/main.mk Makefile
RUN mkdir /opt/bin
# Workarounds for java checking
RUN printf '#!/bin/sh\n\
echo java version \\"1.6\\"'\
> $OPT_BIN/java \
&& printf '#!/bin/sh\n\
echo javac \\"1.6\\"'\
> $OPT_BIN/javac \
&& chmod a+x $OPT_BIN/java $OPT_BIN/javac \
&& mkdir -p /usr/lib/jvm/java-6-openjdk-amd64/lib/ \
&& touch /usr/lib/jvm/java-6-openjdk-amd64/lib/tools.jar
# Files for building ndk
# The default libstdc++.so does not contain full stl implementation, see https://developer.android.com/ndk/guides/cpp-support
RUN mkdir -p system/core/include/arch/linux-arm \
&& touch system/core/include/arch/linux-arm/AndroidConfig.h \
&& mkdir -p system/core/include/arch/linux-x86 \
&& touch system/core/include/arch/linux-x86/AndroidConfig.h \
&& mkdir -p bionic/libc/ \
&& cp -r "$ANDROID_NDK_PATH"/sysroot/usr/include bionic/libc/include \
&& mv bionic/libc/include/arm-linux-androideabi/asm bionic/libc/include/asm \
&& mkdir -p out/target/product/generic/obj/ \
&& cp -r "$ANDROID_NDK_PATH"/platforms/android-27/arch-arm/usr/lib out/target/product/generic/obj/ \
&& mkdir -p bionic/libstdc++ \
&& cp -r "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/include bionic/libstdc++ \
&& cp -r "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/include/* bionic/libstdc++/include \
&& cp "$ANDROID_NDK_PATH"/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi-v7a/libgnustl_shared.so out/target/product/generic/obj/lib/libstdc++.so \
&& printf "TARGET_PRODUCT := generic\n\
TARGET_BUILD_VARIANT := eng\n\
TARGET_BUILD_TYPE := release\n\
TARGET_TOOLS_PREFIX := $ANDROID_NDK_PATH/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-"\
> buildspec.mk
RUN rm -rf "$ANDROID_NDK_PATH"/platforms
RUN rm -rf "$ANDROID_NDK_PATH"/prebuilt
RUN rm -rf "$ANDROID_NDK_PATH"/shader-tools
RUN rm -rf "$ANDROID_NDK_PATH"/sources
RUN rm -rf "$ANDROID_NDK_PATH"/sysroot
RUN rm -rf "$ANDROID_NDK_PATH"/simpleperf
RUN cd "$ANDROID_NDK_PATH"/toolchains && rm -rf aarch64-linux-android-4.9 llvm mips64el-linux-android-4.9 mipsel-linux-android-4.9 x86-4.9 x86_64-4.9
RUN apt-get purge -y unzip wget git && apt-get -y autoremove && apt-get -y clean && rm -rf /var/lib/apt/lists/*
CMD ["bash"]
@@ -1,50 +0,0 @@
# Ubuntu image with tools required to build OpenThread
FROM arm32v7/ubuntu:18.04 as wpantund-dev
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y build-essential git make autoconf autoconf-archive \
automake dbus libtool gcc g++ libreadline-dev libdbus-1-dev libboost-dev
# wpantund
RUN mkdir -p ~/src && \
cd ~/src && \
git clone --recursive https://github.com/openthread/wpantund.git && \
cd wpantund && \
git checkout full/master && \
./configure --sysconfdir=/etc --enable-shared=no && \
make && \
make install
#FROM debian:stretch-slim
FROM arm32v7/ubuntu:18.04
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y libdbus-1-3 libreadline-dev net-tools
RUN mkdir -p /dev/net && \
mknod /dev/net/tun c 10 200 && \
chmod 600 /dev/net/tun
COPY --from=wpantund-dev /usr/local/share/man/man1/wpanctl.1 /usr/local/share/man/man1/wpanctl.1
COPY --from=wpantund-dev /usr/local/share/man/man1/wpantund.1 /usr/local/share/man/man1/wpantund.1
COPY --from=wpantund-dev /usr/local/share/wpantund /usr/local/share/wpantund
COPY --from=wpantund-dev /usr/local/include/wpantund /usr/local/include/wpantund
COPY --from=wpantund-dev /usr/local/bin/wpanctl /usr/local/bin/wpanctl
COPY --from=wpantund-dev /usr/local/sbin/wpantund /usr/local/sbin/wpantund
COPY --from=wpantund-dev /etc/dbus-1/system.d/wpantund.conf /etc/dbus-1/system.d/wpantund.conf
COPY --from=wpantund-dev /etc/wpantund.conf /etc/wpantund.conf
ENTRYPOINT mkdir -p /dev/net && mknod /dev/net/tun c 10 200 && chmod 600 /dev/net/tun && \
service dbus start && \
start-stop-daemon --start --background --quiet --exe /usr/local/sbin/wpantund -- -s $OPENTHREAD_DEVICE_PORT && \
tail -F /dev/null
+11 -26
View File
@@ -6,34 +6,19 @@ ENV DEBIAN_FRONTEND noninteractive
# Install dependencies:
RUN apt-get update -qq
# Install packages needed for wpantund build and runtime:
RUN apt-get install -y build-essential git make autoconf \
autoconf-archive automake dbus libtool gcc \
g++ gperf flex bison texinfo ncurses-dev \
libexpat-dev python sed python-pip gawk \
libreadline6-dev libdbus-1-dev \
libboost-dev inetutils-ping
RUN apt-get install -y --force-yes gcc-arm-none-eabi
RUN pip install pexpect
# Install wpantund:
RUN mkdir -p ~/src && \
cd ~/src && \
git clone --recursive https://github.com/openthread/wpantund.git && \
cd wpantund && \
git checkout full/master && \
./configure --sysconfdir=/etc && \
make && make install
RUN mkdir -p /dev/net && mknod /dev/net/tun c 10 200 && chmod 600 /dev/net/tun
# Restart dbus
RUN service dbus restart
# Install packages needed for build and runtime:
RUN apt-get --no-install-recommends install -y git sudo software-properties-common \
ca-certificates \
&& update-ca-certificates
# Install OpenThread
RUN cd ~/src && \
RUN mkdir -p ~/src && \
cd ~/src && \
git clone --recursive https://github.com/openthread/openthread.git && \
cd openthread && \
./script/bootstrap && \
./bootstrap && \
make -f examples/Makefile-posix
make -f examples/Makefile-simulation
# Install OpenThread Daemon and ot-ctl
RUN cd ~/src/openthread && make -f src/posix/Makefile-posix DAEMON=1
+22 -18
View File
@@ -2,26 +2,30 @@
FROM ubuntu:18.04
ENV DEBIAN_FRONTEND noninteractive
ENV LANG en_US.UTF-8
RUN apt-get -y update
RUN apt-get install -y git software-properties-common sudo
RUN apt-get install -y iproute2 psmisc rsyslog
RUN set -x \
&& apt-get update -y \
&& apt-get install -y locales \
&& localedef -i en_US -c -f UTF-8 -A /usr/share/locale/locale.alias en_US.UTF-8 \
&& apt-get --no-install-recommends install -fy \
git \
ninja-build \
python3 \
python3-pip \
python3-setuptools \
software-properties-common \
sudo \
&& python3 -m pip install -U cmake \
&& python3 -m pip install wheel
# setup openthread
WORKDIR /
COPY . openthread
WORKDIR /openthread
RUN git reset --hard && git clean -xfd
RUN ./script/bootstrap
# setup wpantund
WORKDIR /
RUN git clone https://github.com/openthread/wpantund.git
WORKDIR /wpantund
RUN ./script/bootstrap && ./bootstrap.sh && ./configure && sudo make -j8 && sudo make install
# entrypoint
WORKDIR /
COPY etc/docker/environment/docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["bash"]
RUN set -x \
&& cd openthread \
&& ./script/bootstrap \
&& mkdir build \
&& cd build \
&& cmake -GNinja -DOT_PLATFORM=simulation .. \
&& ninja
-19
View File
@@ -1,19 +0,0 @@
FROM alpine:3.6 as openthread-dev
LABEL maintainer="Marcin K Szczodrak"
RUN apk add -U autoconf automake ca-certificates flex git g++ libtool linux-headers make
# openthread
RUN git clone --recursive https://github.com/openthread/openthread.git && \
cd /openthread && \
./bootstrap && \
make -f examples/Makefile-posix
FROM alpine:3.6
LABEL maintainer="Marcin K Szczodrak"
RUN apk add --no-cache libstdc++
COPY --from=openthread-dev /openthread/output/x86_64-unknown-linux-gnu/bin/ot-cli-ftd /bin/ot-cli-ftd
COPY --from=openthread-dev /openthread/output/x86_64-unknown-linux-gnu/bin/ot-cli-mtd /bin/ot-cli-mtd
RUN ln -s /bin/ot-cli-ftd /bin/node
-36
View File
@@ -1,36 +0,0 @@
## Starting simulator
To start the OpenThread simulator, run:
```
docker run --rm -d --name otsim openthread/sim tail -F /dev/null
```
or
```
./start_sim
```
This runs in background a docker container with environment setup to simulate OpenThread nodes.
## Adding a Thread node
To start simulating an OpenThread node #1, run:
```
docker exec -it otsim node 1
```
or
```
./add_node 1
```
This runs a program called node, which is an OpenThread FTD binary, inside the docker container's simulator environment.
## Stopping simulator
To stop the OpenThread simualtor, run:
```
docker stop otsim
```
or
```
./stop_sim
```
This stop the docker daemon process.
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
docker exec -it otsim node $1
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
docker run --rm -d --name otsim openthread/sim tail -F /dev/null
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
docker stop otsim
-50
View File
@@ -1,50 +0,0 @@
# Ubuntu image with tools required to build OpenThread
FROM ubuntu:18.04 as wpantund-dev
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y apt-utils
RUN apt-get install -y build-essential git make autoconf autoconf-archive \
automake dbus libtool gcc g++ libreadline-dev libdbus-1-dev libboost-dev
# wpantund
RUN mkdir -p ~/src && \
cd ~/src && \
git clone --recursive https://github.com/openthread/wpantund.git && \
cd wpantund && \
git checkout full/master && \
./configure --sysconfdir=/etc --enable-shared=no && \
make && \
make install
#FROM debian:stretch-slim
FROM ubuntu:18.04
LABEL maintainer="Marcin K Szczodrak"
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get install -y libdbus-1-3 libreadline7 net-tools
RUN mkdir -p /dev/net && \
mknod /dev/net/tun c 10 200 && \
chmod 600 /dev/net/tun
COPY --from=wpantund-dev /usr/local/share/man/man1/wpanctl.1 /usr/local/share/man/man1/wpanctl.1
COPY --from=wpantund-dev /usr/local/share/man/man1/wpantund.1 /usr/local/share/man/man1/wpantund.1
COPY --from=wpantund-dev /usr/local/share/wpantund /usr/local/share/wpantund
COPY --from=wpantund-dev /usr/local/include/wpantund /usr/local/include/wpantund
COPY --from=wpantund-dev /usr/local/bin/wpanctl /usr/local/bin/wpanctl
COPY --from=wpantund-dev /usr/local/sbin/wpantund /usr/local/sbin/wpantund
COPY --from=wpantund-dev /etc/dbus-1/system.d/wpantund.conf /etc/dbus-1/system.d/wpantund.conf
COPY --from=wpantund-dev /etc/wpantund.conf /etc/wpantund.conf
ENTRYPOINT mkdir -p /dev/net && mknod /dev/net/tun c 10 200 && chmod 600 /dev/net/tun && \
service dbus start && \
start-stop-daemon --start --background --quiet --exe /usr/local/sbin/wpantund -- -s $OPENTHREAD_DEVICE_PORT && \
tail -F /dev/null
+217
View File
@@ -0,0 +1,217 @@
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
_openthread_config_file = ""
if (current_os == "fuchsia") {
_openthread_config_file = "<openthread-config-android.h>"
}
declare_args() {
# OpenThread config header.
openthread_config_file = _openthread_config_file
# Extra deps for OpenThread configuration.
openthread_config_deps = []
# Include directories for project specific configs.
openthread_project_include_dirs = []
# OpenThread project-specific core config header
openthread_project_core_config_file = ""
# OpenThread platform-specific config check header
openthread_core_config_platform_check_file = ""
# Extra deps for OpenThread core configuration.
openthread_core_config_deps = []
# Use external platform.
openthread_external_platform = ""
# Use external mbedtls. If blank, internal mbedtls will be used.
openthread_external_mbedtls = ""
# Package name for OpenThread.
openthread_package_name = "OPENTHREAD"
# Package version for OpenThread.
openthread_package_version = "1.0.0"
}
declare_args() {
# Configure OpenThread via GN arguments.
openthread_enable_core_config_args = openthread_project_core_config_file == ""
}
if (openthread_enable_core_config_args) {
declare_args() {
# Thread version: 1.1, 1.2
openthread_config_thread_version = ""
# Log output: none, debug_uart, app, platform
openthread_config_log_output = ""
# Enable assertions.
openthread_config_assert_enable = true
# Enable backbone router functionality
openthread_config_backbone_router_enable = false
# Enable border agent support
openthread_config_border_agent_enable = false
# Enable border router support
openthread_config_border_router_enable = false
# Enable channel manager support
openthread_config_channel_manager_enable = false
# Enable channel monitor support
openthread_config_channel_monitor_enable = false
# Enable child supervision support
openthread_config_child_supervision_enable = false
# Enable coap api support
openthread_config_coap_api_enable = false
# Enable secure coap api support
openthread_config_coap_secure_api_enable = false
# Enable coap observe (RFC7641) api support
openthread_config_coap_observe_api_enable = false
# Enable commissioner support
openthread_config_commissioner_enable = false
# Enable csl receiver
openthread_config_mac_csl_receiver_enable = false
# Enable DHCP6 client support
openthread_config_dhcp6_client_enable = false
# Enable DHCP6 server support
openthread_config_dhcp6_server_enable = false
# Enable diagnostic support
openthread_config_diag_enable = false
# Enable DNS client support
openthread_config_dns_client_enable = false
# Enable ECDSA support
openthread_config_ecdsa_enable = false
# Enable Domain Unicast Address feature for Thread 1.2
openthread_config_dua_enable = false
# Enable Multicast Listener Registration feature for Thread 1.2
openthread_config_mlr_enable = false
# Enable external heap support
openthread_config_heap_external_enable = false
# Enable ipv6 fragmentation support
openthread_config_ip6_fragmentation_enable = false
# Enable jam detection support
openthread_config_jam_detection_enable = false
# Enable joiner support
openthread_config_joiner_enable = false
# Enable legacy network support
openthread_config_legacy_enable = false
# Enable link raw service
openthread_config_link_raw_enable = false
# Enable dynamic log level control
openthread_config_log_level_dynamic_enable = false
# Enable mac filter support
openthread_config_mac_filter_enable = false
# Enable MLE long routes extension (experimental, breaks Thread conformance]
openthread_config_mle_long_routes_enable = false
# Enable TMF network diagnostics on MTDs
openthread_config_tmf_network_diag_mtd_enable = false
# Enable multiple instances
openthread_config_multiple_instance_enable = false
# Enable platform netif support
openthread_config_platform_netif_enable = false
# Enable platform UDP support
openthread_config_platform_udp_enable = false
# Enable Thread Test Harness reference device support
openthread_config_reference_device_enable = false
# Enable support for injecting Service entries into the Thread Network Data
openthread_config_tmf_netdata_service_enable = false
# Enable volatile-only storage of settings
openthread_settings_ram = false
# Enable support for adding of auto-configured SLAAC addresses by OpenThread
openthread_config_ip6_slaac_enable = false
# Enable SNTP Client support
openthread_config_sntp_client_enable = false
# Enable the time synchronization service feature
openthread_config_time_sync_enable = false
# Enable UDP forward support
openthread_config_udp_forward_enable = false
# Enable full logs
openthread_config_full_logs = false
# Enable OTNS support
openthread_config_otns_enable = false
# Enable NCP SPI support
openthread_config_ncp_spi_enable = false
# Enable NCP UART support
openthread_config_ncp_uart_enable = false
# Enable builtin mbedtls management
openthread_config_enable_builtin_mbedtls_management =
openthread_external_mbedtls == ""
}
}
if (openthread_external_mbedtls != "") {
mbedtls_target = openthread_external_mbedtls
} else {
mbedtls_target = "../../third_party/mbedtls"
}
+33
View File
@@ -0,0 +1,33 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
add_subdirectory(platforms)
if(OT_BUILD_EXECUTABLES)
add_subdirectory(apps)
endif()
+309
View File
@@ -0,0 +1,309 @@
#
# Copyright (c) 2017, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = arm-none-eabi-as
CPP = arm-none-eabi-cpp
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
--enable-ncp \
--enable-radio-only \
--enable-linker-map \
--with-examples=efr32mg1 \
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
$(NULL)
ifneq ($(DISABLE_BUILTIN_MBEDTLS), 1)
configure_OPTIONS += MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)"
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
#
# Differentiate between boards
#
ifeq ($(BOARD),BRD4151A)
MCU = EFR32MG1P232F256GM48
else
$(error Please provide a value for BOARD variable e.g BOARD= BRD4151A (currently supported BRD4151A))
endif
EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"efr32-mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg1/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/CMSIS/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/sl_crypto/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/Device/SiliconLabs/EFR32MG1P/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/emlib/inc
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg1/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(shell echo $(BOARD) | tr A-Z a-z)
EFR32MG1_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32MG1_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32MG1_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
-I$(HAL_CONF_DIR) \
-D__START=main \
-D$(MCU) \
$(EFR32MG1_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
#
# Platform-Specific switches
#
DMP ?= 0
RADIODEBUG ?= 0
ifeq ($(DMP),1)
COMMONCFLAGS += -DRADIO_CONFIG_DMP_SUPPORT=1
endif
ifeq ($(RADIODEBUG),1)
COMMONCFLAGS += -DRADIO_CONFIG_DEBUG_COUNTERS_SUPPORT=1
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-nostartfiles \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = efr32mg1
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(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)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
+6 -6
View File
@@ -89,12 +89,12 @@ EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"efr32-mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg12/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/CMSIS/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/util/third_party/mbedtls/sl_crypto/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/Device/SiliconLabs/EFR32MG12P/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/emlib/inc
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/CMSIS/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/sl_crypto/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/Device/SiliconLabs/EFR32MG12P/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/emlib/inc
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
+313
View File
@@ -0,0 +1,313 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = arm-none-eabi-as
CPP = arm-none-eabi-cpp
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
--enable-cli \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--enable-linker-map \
--with-examples=efr32mg13 \
MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)" \
$(NULL)
ifneq ($(DISABLE_BUILTIN_MBEDTLS), 1)
configure_OPTIONS += MBEDTLS_CPPFLAGS="$(EFR32_MBEDTLS_CPPFLAGS)"
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
#
# Differentiate between boards
# - BRD4168A / SLWSTK6000B / MGM13P Module / 2.4GHz@19dBm
#
ifeq ($(BOARD),BRD4168A)
MCU = EFR32MG13P732F512GM48
else
$(error Please provide a value for BOARD variable e.g BOARD=BRD4168A (currently supported BRD4168A))
endif
EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"efr32-mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg13/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/CMSIS/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/sl_crypto/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/Device/SiliconLabs/EFR32MG13P/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/emlib/inc
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/radio/rail_lib/chip/efr32/efr32xg1x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg13/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(shell echo $(BOARD) | tr A-Z a-z)
EFR32MG13_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-efr32-config.h\"'
EFR32MG13_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-efr32-config-check.h\"'
EFR32MG13_CONFIG_FILE_CPPFLAGS += -I$(CONFIG_FILE_PATH)
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
-I$(HAL_CONF_DIR) \
-D__START=main \
-D$(MCU) \
$(EFR32MG13_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
#
# Platform-Specific switches
#
DMP ?= 0
RADIODEBUG ?= 0
ifeq ($(DMP),1)
COMMONCFLAGS += -DRADIO_CONFIG_DMP_SUPPORT=1
endif
ifeq ($(RADIODEBUG),1)
COMMONCFLAGS += -DRADIO_CONFIG_DEBUG_COUNTERS_SUPPORT=1
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-nostartfiles \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = efr32mg13
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(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)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
+9 -7
View File
@@ -74,16 +74,18 @@ EFR32_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"efr32-mbedtls-config.h\"'
EFR32_MBEDTLS_CPPFLAGS += -D$(MCU)
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/efr32mg21/crypto
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/CMSIS/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/util/third_party/mbedtls/sl_crypto/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/Device/SiliconLabs/EFR32MG21/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/emlib/inc
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/platform/radio/rail_lib/chip/efr32/efr32xg2x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.6/hardware/kit/common/drivers
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/configs
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/CMSIS/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/util/third_party/mbedtls/sl_crypto/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/Device/SiliconLabs/EFR32MG21/Include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/emlib/inc
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/platform/radio/rail_lib/chip/efr32/efr32xg2x
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/silabs/gecko_sdk_suite/v2.7/hardware/kit/common/drivers
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
EFR32_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
EFR32_MBEDTLS_CPPFLAGS += -Wno-unused-function
EFR32_MBEDTLS_CPPFLAGS += -Wno-unused-parameter
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/efr32mg21/
HAL_CONF_DIR = $(CONFIG_FILE_PATH)/$(shell echo $(BOARD) | tr A-Z a-z)
+2
View File
@@ -81,6 +81,8 @@ CPPFLAGS += \
CFLAGS += \
$(COMMONCFLAGS) \
-D_BSD_SOURCE=1 \
-D_DEFAULT_SOURCE=1 \
$(target_CFLAGS) \
$(NULL)
+295
View File
@@ -0,0 +1,295 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = arm-none-eabi-as
CPP = arm-none-eabi-cpp
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
--enable-cli \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=jn5189 \
$(NULL)
ifneq ($(DISABLE_BUILTIN_MBEDTLS), 1)
configure_OPTIONS += MBEDTLS_CPPFLAGS="$(JN5189_MBEDTLS_CPPFLAGS)"
endif
JN5189_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
JN5189_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"jn5189-mbedtls-config.h\"'
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/include/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/devices/JN5189
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/middleware/mbedtls/port/ksdk/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/devices/JN5189/drivers/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/devices/JN5189/utilities/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/devices/JN5189/utilities/debug-console/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/devices/JN5189/utilities/str/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/drivers/components/serial_manager/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/drivers/components/uart/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/JN5189DK6/CMSIS/Include/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/
JN5189_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls/
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-jn5189-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/k32w/jn5189/
SIGN_IMAGE_PATH = $(AbsTopSourceDir)/third_party/nxp/JN5189DK6/tools/imagetool/
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
-DCPU_JN518X \
-DCPU_JN518X_REV=2 \
-DJENNIC_CHIP_FAMILY_JN518x \
-DJENNIC_CHIP_FAMILY_NAME=_JN518x \
-DSDK_DEBUGCONSOLE=0 \
-D$(CONFIG_FILE) \
-DUSE_RTOS=0 \
-I$(CONFIG_FILE_PATH) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = jn5189
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
TopTargetBinDir = $(TopResultDir)/$(TargetTuple)/bin
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(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)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage post-build-step
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
post-build-step:
$(SIGN_IMAGE_PATH)/sign_images.sh $(TopTargetBinDir)
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
+298
View File
@@ -0,0 +1,298 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = arm-none-eabi-as
CPP = arm-none-eabi-cpp
CC = arm-none-eabi-gcc
CXX = arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
BuildJobs ?= 10
configure_OPTIONS = \
--enable-cli \
--enable-diag \
--enable-ftd \
--enable-mtd \
--enable-ncp \
--with-ncp-bus=uart \
--enable-radio-only \
--enable-linker-map \
--with-examples=k32w061 \
$(NULL)
ifneq ($(DISABLE_BUILTIN_MBEDTLS), 1)
configure_OPTIONS += MBEDTLS_CPPFLAGS="$(K32W061_MBEDTLS_CPPFLAGS)"
endif
K32W061_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
K32W061_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"k32w061-mbedtls-config.h\"'
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/include/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/devices/K32W061
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/middleware/mbedtls/port/ksdk/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/devices/K32W061/drivers/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/devices/K32W061/utilities/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/devices/K32W061/utilities/debug-console/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/devices/K32W061/utilities/str/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/drivers/components/serial_manager/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/drivers/components/uart/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/nxp/K32W061DK6/CMSIS/Include/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/
K32W061_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls/
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-k32w061-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/k32w/k32w061/
SIGN_IMAGE_PATH = $(AbsTopSourceDir)/third_party/nxp/K32W061DK6/tools/imagetool/
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
-DCPU_K32W061HN \
-DCPU_JN518X \
-DCPU_JN518X_REV=2 \
-DJENNIC_CHIP_FAMILY_JN518x \
-DJENNIC_CHIP_FAMILY_NAME=_JN518x \
-DSDK_DEBUGCONSOLE=0 \
-D$(CONFIG_FILE) \
-DUSE_RTOS=0 \
-I$(CONFIG_FILE_PATH) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = k32w061
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
TopTargetBinDir = $(TopResultDir)/$(TargetTuple)/bin
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(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)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=soft -mthumb
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage post-build-step
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
post-build-step:
$(SIGN_IMAGE_PATH)/sign_images.sh $(TopTargetBinDir)
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
-1
View File
@@ -60,7 +60,6 @@ NRF52811_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52811-mbedtls-conf
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/crypto
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/nrfx/mdk
NRF52811_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/cmsis
+342
View File
@@ -0,0 +1,342 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
.NOTPARALLEL:
AR = arm-none-eabi-ar
CCAS = $(CCPREFIX) arm-none-eabi-gcc
CPP = arm-none-eabi-cpp
CC = $(CCPREFIX) arm-none-eabi-gcc
CXX = $(CCPREFIX) arm-none-eabi-g++
LD = arm-none-eabi-ld
STRIP = arm-none-eabi-strip
NM = arm-none-eabi-nm
RANLIB = arm-none-eabi-ranlib
OBJCOPY = arm-none-eabi-objcopy
GCCVersion = $(shell expr `$(CC) -dumpversion | cut -f1 -d.`)
configure_OPTIONS = \
--enable-ftd \
--enable-mtd \
--enable-linker-map \
--with-examples=nrf52833 \
MBEDTLS_CPPFLAGS="$(NRF52833_MBEDTLS_CPPFLAGS)" \
$(NULL)
ifdef SRC_PATH
configure_OPTIONS += --srcdir="$(SRC_PATH)"
endif
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
NRF52833_MBEDTLS_CPPFLAGS = -DMBEDTLS_CONFIG_FILE='\"mbedtls-config.h\"'
NRF52833_MBEDTLS_CPPFLAGS += -DMBEDTLS_USER_CONFIG_FILE='\"nrf52833-mbedtls-config.h\"'
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/mbedtls/repo/include/mbedtls
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/libraries/nrf_security/mbedtls_plat_config
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/nrfx/mdk
NRF52833_MBEDTLS_CPPFLAGS += -I$(AbsTopSourceDir)/third_party/NordicSemiconductor/cmsis
NRF52833_MBEDTLS_CPPFLAGS += -DNRF52833_XXAA
NRF52833_CONFIG_FILE_CPPFLAGS = -DOPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-nrf52833-config.h\"'
NRF52833_CONFIG_FILE_CPPFLAGS += -DOPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE='\"openthread-core-nrf52833-config-check.h\"'
NRF52833_CONFIG_FILE_CPPFLAGS += -I$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833
COMMONCFLAGS := \
-fdata-sections \
-ffunction-sections \
-Os \
-g \
$(NRF52833_CONFIG_FILE_CPPFLAGS) \
$(NULL)
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
ifeq ($(BOOTLOADER),1)
$(info Warning: BOOTLOADER=1 switch is deprecated. Defaulting to BOOTLOADER=USB.)
override BOOTLOADER = USB
endif
ifeq ($(BOOTLOADER),USB)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833/nrf52833_bootloader_usb.ld
COMMONCFLAGS += -DAPP_USBD_NRF_DFU_TRIGGER_ENABLED=1
endif
ifeq ($(BOOTLOADER),UART)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833/nrf52833_bootloader_uart.ld
endif
ifeq ($(BOOTLOADER),BLE)
configure_OPTIONS += --with-custom-linker-file=$(AbsTopSourceDir)/examples/platforms/nrf528xx/nrf52833/nrf52833_bootloader_ble.ld
endif
#
# Select transport which CLI, NCP and RCP examples will use to communicate.
# To disable all transports use the DISABLE_TRANSPORTS switch. This will disable
# the build of all above examples.
# If NCP_SPI switch is set, only NCP and RCP examples will be built.
# Otherwise the user can select USB transport. If no transports were selected,
# the default serial transport is UART.
#
ifndef DISABLE_TRANSPORTS
configure_OPTIONS += --enable-ncp
configure_OPTIONS += --enable-radio-only
ifeq ($(NCP_SPI),1)
COMMONCFLAGS += -DSPIS_AS_SERIAL_TRANSPORT=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_SPI_ENABLE=1
else
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
configure_OPTIONS += --enable-cli
ifeq ($(USB),1)
COMMONCFLAGS += -DUSB_CDC_AS_SERIAL_TRANSPORT=1
else
COMMONCFLAGS += -DUART_AS_SERIAL_TRANSPORT=1
endif # USB == 1
endif # NCP_SPI == 1
endif # DISABLE_TRANSPORTS
NRF52833_MBEDTLS_CPPFLAGS += -DDISABLE_CC310=1
ifeq ($(shell expr $(GCCVersion) \>= 7), 1)
COMMONCFLAGS += -Wno-expansion-to-defined
endif
CPPFLAGS += \
$(COMMONCFLAGS) \
$(target_CPPFLAGS) \
$(NULL)
CFLAGS += \
$(COMMONCFLAGS) \
$(target_CFLAGS) \
$(NULL)
CXXFLAGS += \
$(COMMONCFLAGS) \
$(target_CXXFLAGS) \
-fno-exceptions \
-fno-rtti \
$(NULL)
LDFLAGS += \
$(COMMONCFLAGS) \
$(target_LDFLAGS) \
-specs=nano.specs \
-specs=nosys.specs \
-Wl,--gc-sections \
$(NULL)
CCASFLAGS += \
$(COMMONCCASFLAGS) \
$(target_CCASFLAGS) \
-x \
assembler-with-cpp \
$(NULL)
ECHO := @echo
MAKE := make
MKDIR_P := mkdir -p
LN_S := ln -s
RM_F := rm -f
INSTALL := /usr/bin/install
INSTALLFLAGS := -p
BuildPath = build
TopBuildDir = $(BuildPath)
AbsTopBuildDir = $(PWD)/$(TopBuildDir)
ResultPath = output
TopResultDir = $(ResultPath)
AbsTopResultDir = $(PWD)/$(TopResultDir)
TargetTuple = nrf52833
ARCHS = cortex-m4
TopTargetLibDir = $(TopResultDir)/$(TargetTuple)/lib
ifndef BuildJobs
BuildJobs := $(shell getconf _NPROCESSORS_ONLN)
endif
JOBSFLAG := -j$(BuildJobs)
#
# configure-arch <arch>
#
# Configure OpenThread for the specified architecture.
#
# arch - The architecture to configure.
#
define configure-arch
$(ECHO) " CONFIG $(TargetTuple)..."
(cd $(BuildPath)/$(TargetTuple) && $(AbsTopSourceDir)/configure \
INSTALL="$(INSTALL) $(INSTALLFLAGS)" \
CPP="$(CPP)" CC="$(CC)" CXX="$(CXX)" CCAS="$(CCAS)" OBJC="$(OBJC)" OBJCXX="$(OBJCXX)" AR="$(AR)" RANLIB="$(RANLIB)" NM="$(NM)" STRIP="$(STRIP)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CCASFLAGS="$(CCASFLAGS)" LDFLAGS="$(LDFLAGS)" \
--host=arm-none-eabi \
--prefix=/ \
--exec-prefix=/$(TargetTuple) \
$(configure_OPTIONS))
endef # configure-arch
#
# build-arch <arch>
#
# Build the OpenThread intermediate build products for the specified
# architecture.
#
# arch - The architecture to build.
#
define build-arch
$(ECHO) " BUILD $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
all
endef # build-arch
#
# stage-arch <arch>
#
# Stage (install) the OpenThread final build products for the specified
# architecture.
#
# arch - The architecture to stage.
#
define stage-arch
$(ECHO) " STAGE $(TargetTuple)"
$(MAKE) $(JOBSFLAG) -C $(BuildPath)/$(TargetTuple) --no-print-directory \
DESTDIR=$(AbsTopResultDir) \
install
endef # stage-arch
#
# ARCH_template <arch>
#
# Define macros, targets and rules to configure, build, and stage the
# OpenThread for a single architecture.
#
# arch - The architecture to instantiate the template for.
#
define ARCH_template
CONFIGURE_TARGETS += configure-$(1)
BUILD_TARGETS += do-build-$(1)
STAGE_TARGETS += stage-$(1)
BUILD_DIRS += $(BuildPath)/$(TargetTuple)
DIRECTORIES += $(BuildPath)/$(TargetTuple)
configure-$(1): target_CPPFLAGS=$($(1)_target_CPPFLAGS)
configure-$(1): target_CFLAGS=$($(1)_target_CFLAGS)
configure-$(1): target_CXXFLAGS=$($(1)_target_CXXFLAGS)
configure-$(1): target_LDFLAGS=$($(1)_target_LDFLAGS)
configure-$(1): target_CCASFLAGS=$($(1)_target_CCASFLAGS)
configure-$(1): $(BuildPath)/$(TargetTuple)/config.status
$(BuildPath)/$(TargetTuple)/config.status: | $(BuildPath)/$(TargetTuple)
$$(call configure-arch,$(1))
do-build-$(1): configure-$(1)
do-build-$(1):
+$$(call build-arch,$(1))
stage-$(1): do-build-$(1)
stage-$(1): | $(TopResultDir)
$$(call stage-arch,$(1))
$(1): stage-$(1)
endef # ARCH_template
.DEFAULT_GOAL := all
all: stage
#
# Cortex-m4
#
cortex-m4_target_ABI = cortex-m4
cortex-m4_target_CPPFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_CFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_CXXFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
cortex-m4_target_LDFLAGS = -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -mabi=aapcs
# Instantiate an architecture-specific build template for each target
# architecture.
$(foreach arch,$(ARCHS),$(eval $(call ARCH_template,$(arch))))
#
# Flashing / Debugging
#
TARGET_APP ?= ot-cli-ftd
APP_FILE_NAME = $(TopResultDir)/$(TargetTuple)/bin/$(TARGET_APP)
APP_FILE_HEX = $(TopResultDir)/$(TargetTuple)/bin/$(TARGET_APP).hex
nrfjprog: $(APP_FILE_NAME)
arm-none-eabi-objcopy -O ihex $(<) $(APP_FILE_HEX)
nrfjprog -f NRF52 --sectorerase --reset --program $(APP_FILE_HEX)
#
# Common / Finalization
#
configure: $(CONFIGURE_TARGETS)
build: $(BUILD_TARGETS)
stage: $(STAGE_TARGETS)
DIRECTORIES = $(TopResultDir) $(TopResultDir)/$(TargetTuple)/lib $(BUILD_DIRS)
CLEAN_DIRS = $(TopResultDir) $(BUILD_DIRS)
all: stage
$(DIRECTORIES):
$(ECHO) " MKDIR $@"
@$(MKDIR_P) "$@"
clean:
$(ECHO) " CLEAN"
@$(RM_F) -r $(CLEAN_DIRS)
help:
$(ECHO) "Simply type 'make -f $(firstword $(MAKEFILE_LIST))' to build OpenThread for the following "
$(ECHO) "architectures: "
$(ECHO) ""
$(ECHO) " $(ARCHS)"
$(ECHO) ""
$(ECHO) "To build only a particular architecture, specify: "
$(ECHO) ""
$(ECHO) " make -f $(firstword $(MAKEFILE_LIST)) <architecture>"
$(ECHO) ""
@@ -38,6 +38,7 @@ DEBUG ?= 0
BORDER_AGENT ?= 1
BORDER_ROUTER ?= 1
COAP ?= 1
COAP_OBSERVE ?= 1
COAPS ?= 1
COMMISSIONER ?= 1
CHANNEL_MANAGER ?= 1
@@ -73,7 +74,7 @@ configure_OPTIONS = \
--enable-mtd \
--enable-ncp \
--enable-radio-only \
--with-examples=posix \
--with-examples=simulation \
$(NULL)
# Platform specific switches
@@ -90,12 +91,16 @@ else
COMMONCFLAGS += -DOPENTHREAD_CONFIG_NCP_UART_ENABLE=1
endif # NCP_SPI == 1
ifeq ($(OTNS),1)
VIRTUAL_TIME ?= 1
endif
ifeq ($(VIRTUAL_TIME),1)
COMMONCFLAGS += -DOPENTHREAD_POSIX_VIRTUAL_TIME=1
COMMONCFLAGS += -DOPENTHREAD_SIMULATION_VIRTUAL_TIME=1
endif
ifeq ($(VIRTUAL_TIME_UART),1)
COMMONCFLAGS += -DOPENTHREAD_POSIX_VIRTUAL_TIME_UART=1
COMMONCFLAGS += -DOPENTHREAD_SIMULATION_VIRTUAL_TIME_UART=1
endif
include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
@@ -103,8 +108,8 @@ include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/common-switches.mk
TopSourceDir := $(dir $(shell readlink $(firstword $(MAKEFILE_LIST))))..
AbsTopSourceDir := $(dir $(realpath $(firstword $(MAKEFILE_LIST))))..
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-posix-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/posix/
CONFIG_FILE = OPENTHREAD_PROJECT_CORE_CONFIG_FILE='\"openthread-core-simulation-config.h\"'
CONFIG_FILE_PATH = $(AbsTopSourceDir)/examples/platforms/simulation/
COMMONCFLAGS += \
-D$(CONFIG_FILE) \
-I$(CONFIG_FILE_PATH) \
-7
View File
@@ -47,11 +47,4 @@ SUBDIRS += \
$(NULL)
endif
# Always pretty (e.g. for 'make pretty') these subdirectories.
PRETTY_SUBDIRS = \
platforms \
apps \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+33
View File
@@ -0,0 +1,33 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
if(OT_APP_CLI)
add_subdirectory(cli)
endif()
add_subdirectory(ncp)
-7
View File
@@ -50,11 +50,4 @@ SUBDIRS += ncp
endif
endif
# Always pretty (e.g. for 'make pretty') these subdirectories.
PRETTY_SUBDIRS = \
cli \
ncp \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+65
View File
@@ -0,0 +1,65 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
add_executable(ot-cli-ftd
main.c
)
add_executable(ot-cli-mtd
main.c
)
set(COMMON_INCLUDES
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms
${PROJECT_SOURCE_DIR}/src/core
)
target_include_directories(ot-cli-ftd PRIVATE ${COMMON_INCLUDES})
target_include_directories(ot-cli-mtd PRIVATE ${COMMON_INCLUDES})
target_link_libraries(ot-cli-ftd PRIVATE
openthread-cli-ftd
${OT_PLATFORM_LIB}
openthread-ftd
${OT_PLATFORM_LIB}
mbedcrypto
ot-config
)
target_link_libraries(ot-cli-mtd PRIVATE
openthread-cli-mtd
${OT_PLATFORM_LIB}
openthread-mtd
${OT_PLATFORM_LIB}
mbedcrypto
ot-config
)
install(TARGETS ot-cli-ftd ot-cli-mtd
DESTINATION bin)
+1
View File
@@ -34,6 +34,7 @@ bin_PROGRAMS = \
CPPFLAGS_COMMON += \
-I$(top_srcdir)/include \
-I$(top_srcdir)/src \
-I$(top_srcdir)/src/core \
-I$(top_srcdir)/examples/platforms \
$(NULL)
+3 -3
View File
@@ -7,7 +7,7 @@ This example application exposes OpenThread configuration and management APIs vi
```bash
$ cd <path-to-openthread>
$ ./bootstrap
$ make -f examples/Makefile-posix
$ make -f examples/Makefile-simulation
```
## 2. Start node 1
@@ -27,9 +27,9 @@ Done
> dataset
Active Timestamp: 1
Channel: 13
Channel Mask: 07fff800
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d/64
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
+9 -2
View File
@@ -36,8 +36,9 @@
#include <openthread/platform/logging.h>
#include "openthread-system.h"
#include "cli/cli_config.h"
#if OPENTHREAD_EXAMPLES_POSIX
#if OPENTHREAD_EXAMPLES_SIMULATION
#include <setjmp.h>
#include <unistd.h>
@@ -46,6 +47,10 @@ jmp_buf gResetJump;
void __gcov_flush();
#endif
#ifndef OPENTHREAD_ENABLE_COVERAGE
#define OPENTHREAD_ENABLE_COVERAGE 0
#endif
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
void *otPlatCAlloc(size_t aNum, size_t aSize)
{
@@ -67,7 +72,7 @@ int main(int argc, char *argv[])
{
otInstance *instance;
#if OPENTHREAD_EXAMPLES_POSIX
#if OPENTHREAD_EXAMPLES_SIMULATION
if (setjmp(gResetJump))
{
alarm(0);
@@ -102,7 +107,9 @@ pseudo_reset:
#endif
assert(instance);
#if OPENTHREAD_CONFIG_CLI_TRANSPORT == OT_CLI_TRANSPORT_UART
otCliUartInit(instance);
#endif
while (!otSysPseudoResetWasRequested())
{
+11 -44
View File
@@ -1,4 +1,3 @@
#!/bin/bash
#
# Copyright (c) 2019, The OpenThread Authors.
# All rights reserved.
@@ -27,48 +26,16 @@
# POSSIBILITY OF SUCH DAMAGE.
#
set -e -x -o pipefail
set(COMMON_INCLUDES
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms
${PROJECT_SOURCE_DIR}/src/core
)
setup_python()
{
python -m pip install flake8
}
if(OT_APP_NCP)
include(ncp.cmake)
endif()
check_python()
{
flake8 --config=script/pystyle.cfg tests tools
}
check_clang()
{
clang-format --version
./bootstrap
./configure
make pretty-check
}
main()
{
case $1 in
setup)
setup_python
;;
python)
check_python
;;
clang)
check_cpp
;;
'')
setup_python
check_python
check_clang
;;
*)
echo "USAGE: $0 [setup|python|clang]"
exit 1
;;
esac
}
main "$@"
if(OT_APP_RCP)
include(rcp.cmake)
endif()
+9
View File
@@ -54,6 +54,9 @@ SOURCES_COMMON += \
LDADD_MBEDTLS = \
$(NULL)
LDADD_MBEDTLS_RADIO = \
$(NULL)
LDADD_DIAG = \
$(NULL)
@@ -61,6 +64,10 @@ if OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
LDADD_MBEDTLS += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto.a \
$(NULL)
LDADD_MBEDTLS_RADIO += \
$(top_builddir)/third_party/mbedtls/libmbedcrypto-radio.a \
$(NULL)
endif # OPENTHREAD_ENABLE_BUILTIN_MBEDTLS
if OPENTHREAD_ENABLE_NCP_SPINEL_ENCRYPTER
@@ -151,8 +158,10 @@ ot_rcp_LDADD = \
$(top_builddir)/src/ncp/libopenthread-rcp.a \
$(top_builddir)/src/core/libopenthread-radio.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS_RADIO) \
$(top_builddir)/src/core/libopenthread-radio.a \
$(LDADD_COMMON) \
$(LDADD_MBEDTLS_RADIO) \
$(NULL)
ot_rcp_LDFLAGS = \
+6 -15
View File
@@ -36,7 +36,7 @@
#include "openthread-system.h"
#if OPENTHREAD_EXAMPLES_POSIX
#if OPENTHREAD_EXAMPLES_SIMULATION
#include <setjmp.h>
#include <unistd.h>
@@ -45,6 +45,10 @@ jmp_buf gResetJump;
void __gcov_flush();
#endif
#ifndef OPENTHREAD_ENABLE_COVERAGE
#define OPENTHREAD_ENABLE_COVERAGE 0
#endif
#if OPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE
void *otPlatCAlloc(size_t aNum, size_t aSize)
{
@@ -66,7 +70,7 @@ int main(int argc, char *argv[])
{
otInstance *instance;
#if OPENTHREAD_EXAMPLES_POSIX
#if OPENTHREAD_EXAMPLES_SIMULATION
if (setjmp(gResetJump))
{
alarm(0);
@@ -118,16 +122,3 @@ pseudo_reset:
return 0;
}
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_APP)
void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
OT_UNUSED_VARIABLE(aLogRegion);
va_list ap;
va_start(ap, aFormat);
otNcpPlatLogv(aLogLevel, aLogRegion, aFormat, ap);
va_end(ap);
}
#endif
+58
View File
@@ -0,0 +1,58 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
add_executable(ot-ncp-ftd
main.c
)
add_executable(ot-ncp-mtd
main.c
)
target_include_directories(ot-ncp-ftd PRIVATE ${COMMON_INCLUDES})
target_include_directories(ot-ncp-mtd PRIVATE ${COMMON_INCLUDES})
target_link_libraries(ot-ncp-ftd PRIVATE
openthread-ncp-ftd
${OT_PLATFORM_LIB}
openthread-ftd
${OT_PLATFORM_LIB}
mbedcrypto
ot-config
)
target_link_libraries(ot-ncp-mtd PRIVATE
openthread-ncp-mtd
${OT_PLATFORM_LIB}
openthread-mtd
${OT_PLATFORM_LIB}
mbedcrypto
ot-config
)
install(TARGETS ot-ncp-ftd ot-ncp-mtd DESTINATION bin)
+43
View File
@@ -0,0 +1,43 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
add_executable(ot-rcp
main.c
)
target_include_directories(ot-rcp PRIVATE ${COMMON_INCLUDES})
target_link_libraries(ot-rcp PRIVATE
openthread-rcp
${OT_PLATFORM_LIB}
openthread-radio
${OT_PLATFORM_LIB}
ot-config
)
install(TARGETS ot-rcp DESTINATION bin)
+75 -1
View File
@@ -28,22 +28,28 @@
# OpenThread Features (Makefile default configuration).
BACKBONE_ROUTER ?= 0
BIG_ENDIAN ?= 0
BORDER_AGENT ?= 0
BORDER_ROUTER ?= 0
COAP ?= 0
COAP_OBSERVE ?= 0
COAPS ?= 0
COMMISSIONER ?= 0
COVERAGE ?= 0
CHANNEL_MANAGER ?= 0
CHANNEL_MONITOR ?= 0
CHILD_SUPERVISION ?= 0
CLI_TRANSPORT ?= UART
DEBUG ?= 0
DHCP6_CLIENT ?= 0
DHCP6_SERVER ?= 0
DIAGNOSTIC ?= 0
DISABLE_DOC ?= 0
DISABLE_TOOLS ?= 0
DNS_CLIENT ?= 0
DUA ?= 0
DYNAMIC_LOG_LEVEL ?= 0
ECDSA ?= 0
EXTERNAL_HEAP ?= 0
IP6_FRAGM ?= 0
@@ -55,7 +61,11 @@ LOG_OUTPUT ?= APP
endif
LINK_RAW ?= 0
MAC_FILTER ?= 0
MLE_LONG_ROUTES ?= 0
MLR ?= 0
MTD_NETDIAG ?= 0
MULTIPLE_INSTANCE ?= 0
OTNS ?= 0
PLATFORM_UDP ?= 0
REFERENCE_DEVICE ?= 0
SERVICE ?= 0
@@ -63,10 +73,15 @@ SETTINGS_RAM ?= 0
# SLAAC is enabled by default
SLAAC ?= 1
SNTP_CLIENT ?= 0
THREAD_VERSION ?= 1.1
TIME_SYNC ?= 0
UDP_FORWARD ?= 0
ifeq ($(BACKBONE_ROUTER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1
endif
ifeq ($(BIG_ENDIAN),1)
COMMONCFLAGS += -DBYTE_ORDER_BIG_ENDIAN=1
endif
@@ -87,6 +102,10 @@ ifeq ($(COAPS),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_SECURE_API_ENABLE=1
endif
ifeq ($(COAP_OBSERVE),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COAP_OBSERVE_API_ENABLE=1
endif
ifeq ($(COMMISSIONER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_COMMISSIONER_ENABLE=1
endif
@@ -107,6 +126,14 @@ ifeq ($(CHILD_SUPERVISION),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CHILD_SUPERVISION_ENABLE=1
endif
ifneq ($(CLI_TRANSPORT),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_CLI_TRANSPORT=OT_CLI_TRANSPORT_$(CLI_TRANSPORT)
endif
ifeq ($(CSL_RECEIVER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_CSL_RECEIVER_ENABLE=1
endif
ifeq ($(DEBUG),1)
configure_OPTIONS += --enable-debug --disable-optimization
endif
@@ -127,10 +154,22 @@ ifeq ($(DISABLE_DOC),1)
configure_OPTIONS += --disable-docs
endif
ifeq ($(DISABLE_TOOLS),1)
configure_OPTIONS += --disable-tools
endif
ifeq ($(DNS_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DNS_CLIENT_ENABLE=1
endif
ifeq ($(DUA),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_DUA_ENABLE=1
endif
ifeq ($(DYNAMIC_LOG_LEVEL),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL_DYNAMIC_ENABLE=1
endif
ifeq ($(ECDSA),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_ECDSA_ENABLE=1
endif
@@ -167,10 +206,23 @@ ifeq ($(MAC_FILTER),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MAC_FILTER_ENABLE=1
endif
# Enable MLE long routes extension (experimental, breaks Thread conformance)
ifeq ($(MLE_LONG_ROUTES),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLE_LONG_ROUTES_ENABLE=1
endif
ifeq ($(MLR),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MLR_ENABLE=1
endif
ifeq ($(MTD_NETDIAG),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TMF_NETWORK_DIAG_MTD_ENABLE=1
endif
ifeq ($(MULTIPLE_INSTANCE),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_MULTIPLE_INSTANCE_ENABLE=1
endif
ifeq ($(PLATFORM_UDP),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_PLATFORM_UDP_ENABLE=1
endif
@@ -192,8 +244,14 @@ ifeq ($(SNTP_CLIENT),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_SNTP_CLIENT_ENABLE=1
endif
ifeq ($(THREAD_VERSION),1.1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=2
else ifeq ($(THREAD_VERSION),1.2)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_THREAD_VERSION=3
endif
ifeq ($(TIME_SYNC),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1 -DOPENTHREAD_MAC_CONFIG_HEADER_IE_SUPPORT=1
COMMONCFLAGS += -DOPENTHREAD_CONFIG_TIME_SYNC_ENABLE=1 -DOPENTHREAD_CONFIG_MAC_HEADER_IE_SUPPORT=1
endif
ifeq ($(UDP_FORWARD),1)
@@ -204,6 +262,10 @@ ifeq ($(DISABLE_BUILTIN_MBEDTLS),1)
configure_OPTIONS += --disable-builtin-mbedtls
endif
ifneq ($(BUILTIN_MBEDTLS_MANAGEMENT),)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_ENABLE_BUILTIN_MBEDTLS_MANAGEMENT=$(BUILTIN_MBEDTLS_MANAGEMENT)
endif
ifeq ($(DISABLE_EXECUTABLE),1)
configure_OPTIONS += --enable-executable=no
endif
@@ -222,18 +284,30 @@ ifeq ($(SETTINGS_RAM),1)
COMMONCFLAGS += -DOPENTHREAD_SETTINGS_RAM=1
endif
ifeq ($(OTNS),1)
COMMONCFLAGS += -DOPENTHREAD_CONFIG_OTNS_ENABLE=1
endif
ifneq ($(SPINEL_ENCRYPTER_LIBS),)
configure_OPTIONS += --with-ncp-spinel-encrypter-libs=$(SPINEL_ENCRYPTER_LIBS)
endif
ifeq ($(FULL_LOGS),1)
# HINT: Add more here, or comment out ones you do not need/want
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_LEVEL=OT_LOG_LEVEL_DEBG
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_API=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_ARP=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_BBR=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_CLI=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_COAP=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_DUA=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_ICMP=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_IP6=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MAC=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MEM=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MESHCOP=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MLE=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MLR=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_NETDATA=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_NETDIAG=1
LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_PKT_DUMP=1
+29
View File
@@ -0,0 +1,29 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
add_subdirectory(utils)
+29 -32
View File
@@ -35,12 +35,15 @@ DIST_SUBDIRS = \
cc2538 \
cc2650 \
cc2652 \
efr32mg1 \
efr32mg12 \
efr32mg13 \
efr32mg21 \
gp712 \
k32w \
kw41z \
nrf528xx \
posix \
simulation \
qpg6095 \
samr21 \
utils \
@@ -52,51 +55,63 @@ SUBDIRS = \
utils \
$(NULL)
if OPENTHREAD_EXAMPLES_CC1352
if OPENTHREAD_PLATFORM_CC1352
SUBDIRS += cc1352
endif
if OPENTHREAD_EXAMPLES_CC2538
if OPENTHREAD_PLATFORM_CC2538
SUBDIRS += cc2538
endif
if OPENTHREAD_EXAMPLES_CC2650
if OPENTHREAD_PLATFORM_CC2650
SUBDIRS += cc2650
endif
if OPENTHREAD_EXAMPLES_CC2652
if OPENTHREAD_PLATFORM_CC2652
SUBDIRS += cc2652
endif
if OPENTHREAD_EXAMPLES_EFR32MG12
if OPENTHREAD_PLATFORM_EFR32MG1
SUBDIRS += efr32mg1
endif
if OPENTHREAD_PLATFORM_EFR32MG12
SUBDIRS += efr32mg12
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
if OPENTHREAD_PLATFORM_EFR32MG13
SUBDIRS += efr32mg13
endif
if OPENTHREAD_PLATFORM_EFR32MG21
SUBDIRS += efr32mg21
endif
if OPENTHREAD_EXAMPLES_GP712
if OPENTHREAD_PLATFORM_GP712
SUBDIRS += gp712
endif
if OPENTHREAD_EXAMPLES_KW41Z
if OPENTHREAD_PLATFORM_K32W
SUBDIRS += k32w
endif
if OPENTHREAD_PLATFORM_KW41Z
SUBDIRS += kw41z
endif
if OPENTHREAD_EXAMPLES_NRF528XX
if OPENTHREAD_PLATFORM_NRF528XX
SUBDIRS += nrf528xx
endif
if OPENTHREAD_EXAMPLES_POSIX
SUBDIRS += posix
if OPENTHREAD_PLATFORM_SIMULATION
SUBDIRS += simulation
endif
if OPENTHREAD_EXAMPLES_QPG6095
if OPENTHREAD_PLATFORM_QPG6095
SUBDIRS += qpg6095
endif
if OPENTHREAD_EXAMPLES_SAMR21
if OPENTHREAD_PLATFORM_SAMR21
SUBDIRS += samr21
endif
@@ -104,22 +119,4 @@ noinst_HEADERS = \
openthread-system.h \
$(NULL)
# Always pretty (e.g. for 'make pretty') these subdirectories.
PRETTY_SUBDIRS = \
cc1352 \
cc2538 \
cc2650 \
cc2652 \
efr32mg12 \
efr32mg21 \
gp712 \
kw41z \
nrf528xx \
posix \
qpg6095 \
samr21 \
utils \
$(NULL)
include $(abs_top_nlbuild_autotools_dir)/automake/post.am
+22 -2
View File
@@ -57,10 +57,18 @@ if OPENTHREAD_EXAMPLES_CC2652
include $(top_srcdir)/examples/platforms/cc2652/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG1
include $(top_srcdir)/examples/platforms/efr32mg1/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG12
include $(top_srcdir)/examples/platforms/efr32mg12/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG13
include $(top_srcdir)/examples/platforms/efr32mg13/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_EFR32MG21
include $(top_srcdir)/examples/platforms/efr32mg21/Makefile.platform.am
endif
@@ -69,6 +77,14 @@ if OPENTHREAD_EXAMPLES_GP712
include $(top_srcdir)/examples/platforms/gp712/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_JN5189
include $(top_srcdir)/examples/platforms/k32w/jn5189/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_K32W061
include $(top_srcdir)/examples/platforms/k32w/k32w061/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_KW41Z
include $(top_srcdir)/examples/platforms/kw41z/Makefile.platform.am
endif
@@ -77,6 +93,10 @@ if OPENTHREAD_EXAMPLES_NRF52811
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52811/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_NRF52833
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52833/Makefile.platform.am
endif
if OPENTHREAD_EXAMPLES_NRF52840
include $(top_srcdir)/examples/platforms/nrf528xx/nrf52840/Makefile.platform.am
endif
@@ -89,6 +109,6 @@ if OPENTHREAD_EXAMPLES_SAMR21
include $(top_srcdir)/examples/platforms/samr21/Makefile.platform.am
endif # OPENTHREAD_EXAMPLES_SAMR21
if OPENTHREAD_EXAMPLES_POSIX
include $(top_srcdir)/examples/platforms/posix/Makefile.platform.am
if OPENTHREAD_EXAMPLES_SIMULATION
include $(top_srcdir)/examples/platforms/simulation/Makefile.platform.am
endif
+100
View File
@@ -0,0 +1,100 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
set(OT_PLATFORM_LIB "openthread-cc1352" PARENT_SCOPE)
if(NOT OT_CONFIG)
set(OT_CONFIG "openthread-core-cc1352-config.h")
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
endif()
list(APPEND OT_PLATFORM_DEFINES
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-cc1352-config-check.h\""
)
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
target_compile_definitions(ot-config INTERFACE "MBEDTLS_USER_CONFIG_FILE=\"cc1352-mbedtls-config.h\"")
list(APPEND OT_PUBLIC_INCLUDES
"${CMAKE_CURRENT_SOURCE_DIR}/crypto"
"${PROJECT_SOURCE_DIR}/third_party/ti/devices/cc13x2_cc26x2"
)
set(OT_PUBLIC_INCLUDES ${OT_PUBLIC_INCLUDES} PARENT_SCOPE)
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
add_library(openthread-cc1352
alarm.c
diag.c
entropy.c
flash.c
logging.c
misc.c
radio.c
system.c
uart.c
crypto/aes_alt.c
cc1352_ccfg.c
cc1352_startup.c
cxx_helpers.c
)
set_target_properties(
openthread-cc1352
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
)
target_link_libraries(openthread-cc1352
PUBLIC
cc13x2-cc26x2-driver
PRIVATE
${OT_MBEDTLS}
ot-config
)
target_link_options(openthread-cc1352
PUBLIC
-Wl,--gc-sections
-Wl,-Map=$<TARGET_PROPERTY:NAME>.map
)
target_compile_definitions(openthread-cc1352
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_options(openthread-cc1352 PRIVATE ${OT_CFLAGS})
target_include_directories(openthread-cc1352
PRIVATE
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/src/core
${PROJECT_SOURCE_DIR}/examples/platforms
)
+4 -8
View File
@@ -28,11 +28,11 @@
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
lib_LIBRARIES = libopenthread-cc1352.a
# Do not enable -Wcast-align for this platform
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
# Do not enable -pedantic-errors for cc13xx driverlib
override CFLAGS := $(filter-out -pedantic-errors,$(CFLAGS))
override CXXFLAGS := $(filter-out -pedantic-errors,$(CXXFLAGS))
lib_LIBRARIES = libopenthread-cc1352.a
libopenthread_cc1352_a_CPPFLAGS = \
-I$(top_srcdir)/include \
@@ -73,10 +73,6 @@ libopenthread_cc1352_a_DEPENDENCIES
$(top_srcdir)/third_party/ti/devices/cc13x2_cc26x2/driverlib/bin/gcc/driverlib.a \
$(NULL)
PRETTY_FILES = \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_cc1352_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")
+16 -32
View File
@@ -1,34 +1,24 @@
# OpenThread on CC1352 Example
This directory contains example platform drivers for the [Texas Instruments
CC1352R1][cc1352r1].
This directory contains example platform drivers for the [Texas Instruments CC1352R1][cc1352r1].
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. Consult the [SimpleLink
CC26X2R1 SDK][cc26x2r1-sdk] for more development option. The platform drivers
were built for the [CC1352R1 LAUNCHXL][cc1352r1-launchxl], usage on other
boards with a cc1352r1 may require changes to the peripheral drivers.
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. Consult the [SimpleLink CC26X2R1 SDK][cc26x2r1-sdk] for more development option. The platform drivers were built for the [CC1352R1 LAUNCHXL][cc1352r1-launchxl], usage on other boards with a cc1352r1 may require changes to the peripheral drivers.
[cc1352r1-launchxl]: http://www.ti.com/tool/launchxl-cc26x2r1
[cc26x2r1-sdk]: http://www.ti.com/tool/simplelink-cc26x2-sdk
<!---
TODO: Update link when cc1352 product page is live
[cc1352r1]: http://www.ti.com/product/cc1352r1
-->
[cc1352r1]: http://www.ti.com/tool/launchxl-cc26x2r1
## Toolchain
Building the examples for the cc1352 requires [GNU AutoConf][gnu-autoconf],
[GNU AutoMake][gnu-automake], [Python][python], and the [ARM gcc
toolchain][arm-toolchain].
Building the examples for the cc1352 requires [GNU AutoConf][gnu-autoconf], [GNU AutoMake][gnu-automake], [Python][python], and the [ARM gcc toolchain][arm-toolchain].
With the exception of the arm toolchain, most of these tools are installed by
default on modern Posix systems. It is recommended to setup a Linux virtual
machine for building on a Windows host system. For help setting up VirtualBox
with Ubuntu, consult this [community help wiki
article][ubuntu-wiki-virtualbox].
With the exception of the arm toolchain, most of these tools are installed by default on modern Posix systems. It is recommended to setup a Linux virtual machine for building on a Windows host system. For help setting up VirtualBox with Ubuntu, consult this [community help wiki article][ubuntu-wiki-virtualbox].
[gnu-autoconf]: https://www.gnu.org/software/autoconf
[gnu-automake]: https://www.gnu.org/software/automake
@@ -38,8 +28,7 @@ article][ubuntu-wiki-virtualbox].
[mingw]: http://www.mingw.org
[ubuntu-wiki-virtualbox]: https://help.ubuntu.com/community/VirtualBox
In a Bash terminal, follow these instructions to install the GNU toolchain and
other dependencies.
In a Bash terminal, follow these instructions to install the GNU toolchain and other dependencies.
```bash
$ cd <path-to-openthread>
@@ -58,11 +47,9 @@ $ make -f examples/Makefile-cc1352
## Flash Binaries
If the build completed successfully, the `elf` files may be found in
`<path-to-openthread>/output/cc1352/bin`.
If the build completed successfully, the `elf` files may be found in `<path-to-openthread>/output/cc1352/bin`.
Flash the images with [Uniflash][uniflash]. Make sure to deselect the binary
check-box, Uniflash assumes a file without an extension is a binary file.
Flash the images with [Uniflash][uniflash]. Make sure to deselect the binary check-box, Uniflash assumes a file without an extension is a binary file.
[uniflash]: http://www.ti.com/tool/uniflash
@@ -70,15 +57,13 @@ check-box, Uniflash assumes a file without an extension is a binary file.
### CLI example
1. With a terminal client (PuTTY, minicom, etc.) open the com port associated
with the cc1352 UART. The serial port settings are:
* 115200 baud
* 8 data bits
* no parity bit
* 1 stop bit
1. With a terminal client (PuTTY, minicom, etc.) open the com port associated with the cc1352 UART. The serial port settings are:
- 115200 baud
- 8 data bits
- no parity bit
- 1 stop bit
2. Type `help` for a list of commands.
3. Follow the instructions in the [CLI README][cli-readme] for instructions on
setting up a network.
3. Follow the instructions in the [CLI README][cli-readme] for instructions on setting up a network.
[cli-readme]: ../../../src/cli/README.md
@@ -114,7 +99,6 @@ whitelist
### NCP example
Refer to the documentation in the [wpantund][wpantund] project for build
instructions and usage information.
Refer to the documentation in the [wpantund][wpantund] project for build instructions and usage information.
[wpantund]: https://github.com/openthread/wpantund
@@ -0,0 +1,50 @@
#
# Copyright (c) 2020, The OpenThread Authors.
# 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.
#
set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
set(CMAKE_ASM_COMPILER arm-none-eabi-as)
set(CMAKE_RANLIB arm-none-eabi-ranlib)
set(COMMON_C_FLAGS "-mcpu=cortex-m4 -march=armv7e-m -mfloat-abi=hard -mfpu=fpv4-sp-d16 -mthumb -fdata-sections -ffunction-sections")
set(CMAKE_C_FLAGS "${COMMON_C_FLAGS} -std=gnu99")
set(CMAKE_CXX_FLAGS "${COMMON_C_FLAGS} -fno-exceptions -fno-rtti")
set(CMAKE_ASM_FLAGS "${COMMON_C_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_INIT "${COMMON_C_FLAGS} -nostartfiles -specs=nano.specs -specs=nosys.specs")
set(CMAKE_C_FLAGS_DEBUG "-Og -g")
set(CMAKE_CXX_FLAGS_DEBUG "-Og -g")
set(CMAKE_ASM_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-Os")
set(CMAKE_CXX_FLAGS_RELEASE "-Os")
set(CMAKE_ASM_FLAGS_RELEASE "")
+3 -6
View File
@@ -71,8 +71,7 @@ void mbedtls_aes_free(mbedtls_aes_context *ctx);
* @retval 0 If successful
* @retval MBEDTLS_ERR_AES_INVALID_KEY_LENGTH If keybits was not 128
*/
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
unsigned int keybits);
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits);
/**
* @brief AES key schedule (decryption)
@@ -84,8 +83,7 @@ int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key,
* @retval 0 If successful
* @retval MBEDTLS_ERR_AES_INVALID_KEY_LENGTH If keybits was not 128
*/
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key,
unsigned int keybits);
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits);
/**
* \brief AES-ECB block encryption/decryption
@@ -99,8 +97,7 @@ int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key,
* @retval 0 If successful
* @retval AES_KEYSTORE_READ_ERROR If the indicated keystore ram could not be read
*/
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16],
unsigned char output[16]);
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16]);
#ifdef __cplusplus
}
-11
View File
@@ -46,17 +46,6 @@
*/
static bool sDiagMode = false;
void otPlatDiagProcess(otInstance *aInstance, int argc, char *argv[], char *aOutput, size_t aOutputMaxLen)
{
OT_UNUSED_VARIABLE(aInstance);
// Add more platform specific diagnostics features here.
if (argc > 1)
{
snprintf(aOutput, aOutputMaxLen, "diag feature '%s' is not supported\r\n", argv[0]);
}
}
void otPlatDiagModeSet(bool aMode)
{
sDiagMode = aMode;
+61 -113
View File
@@ -28,43 +28,21 @@
#include <string.h>
#include <openthread/instance.h>
#include <driverlib/aon_batmon.h>
#include <driverlib/flash.h>
#include <driverlib/interrupt.h>
#include <driverlib/vims.h>
#include <openthread-core-config.h>
#include <openthread/config.h>
#include <openthread/platform/alarm-milli.h>
#include <utils/code_utils.h>
#include "platform-cc1352.h"
/*
* The settings configuration base address *MUST* be defined in the core config
* file. The base address *MUST* be aligned on an 8K page boundary or the flash
* program calls will fail.
*/
#ifndef SETTINGS_CONFIG_BASE_ADDRESS
#error "SETTINGS_CONFIG_BASE_ADDRESS not defined in the OpenThread Core Config"
#endif /* SETTINGS_CONFIG_BASE_ADDRESS */
/*
* The settings configuration page size *MUST* be defined in the core config
* file. The page size *MUST* be 8K or the flash program calls will fail.
*/
#if (SETTINGS_CONFIG_PAGE_SIZE != 0x2000)
#error "SETTINGS_CONFIG_PAGE_SIZE must be defined in OpenThread Core Config"
#endif
/*
* The settings configuration page number _SHOULD_ be defined in the core
* config file.
*/
#ifndef SETTINGS_CONFIG_PAGE_NUM
#warn "SETTINGS_CONFIG_PAGE_NUM not defined in the OpenThread Core Config"
#endif /* SETTINGS_CONFIG_PAGE_NUM */
#define FLASH_BASE_ADDRESS 0x52000
#define FLASH_PAGE_SIZE 0x2000
#define FLASH_PAGE_NUM 2 /* must be a multiple of 2 */
#define FLASH_SWAP_SIZE (FLASH_PAGE_SIZE * (FLASH_PAGE_NUM / 2))
enum
{
@@ -158,117 +136,87 @@ static void restoreFlashCache(uint32_t mode)
VIMSLineBufEnable(VIMS_BASE);
}
/**
* Translate the errors from the Flash programming FSM to OpenThread error
* codes.
*
* @param [in] error Return from the Flash programming function.
*
* @return The corresponding OpenThread @ref otError value.
*/
static otError fsmErrorToOtError(uint32_t error)
static uint32_t mapAddress(uint8_t aSwapIndex, uint32_t aOffset)
{
otError ret = OT_ERROR_GENERIC;
uint32_t address = FLASH_BASE_ADDRESS + aOffset;
switch (error)
if (aSwapIndex)
{
case FAPI_STATUS_SUCCESS:
ret = OT_ERROR_NONE;
break;
case FAPI_STATUS_INCORRECT_DATABUFFER_LENGTH:
ret = OT_ERROR_INVALID_ARGS;
break;
case FAPI_STATUS_FSM_ERROR:
ret = OT_ERROR_FAILED;
break;
default:
break;
address += FLASH_SWAP_SIZE;
}
return ret;
return address;
}
/**
* Function documented in platforms/utils/flash.h
*/
otError utilsFlashInit(void)
void otPlatFlashInit(otInstance *aInstance)
{
return OT_ERROR_NONE;
OT_UNUSED_VARIABLE(aInstance);
}
/**
* Function documented in platforms/utils/flash.h
*/
uint32_t utilsFlashGetSize(void)
uint32_t otPlatFlashGetSwapSize(otInstance *aInstance)
{
return FlashSizeGet();
OT_UNUSED_VARIABLE(aInstance);
return FLASH_SWAP_SIZE;
}
/**
* Function documented in platforms/utils/flash.h
*/
otError utilsFlashErasePage(uint32_t aAddress)
void otPlatFlashErase(otInstance *aInstance, uint8_t aSwapIndex)
{
OT_UNUSED_VARIABLE(aInstance);
uint32_t mode;
uint32_t fsmRet;
otError ret;
otEXPECT_ACTION(checkVoltage(), ret = OT_ERROR_FAILED);
mode = disableFlashCache();
fsmRet = FlashSectorErase(aAddress);
restoreFlashCache(mode);
ret = fsmErrorToOtError(fsmRet);
exit:
return ret;
}
/**
* Function documented in platforms/utils/flash.h
*/
otError utilsFlashStatusWait(uint32_t aTimeout)
{
uint32_t start = otPlatAlarmMilliGetNow();
otError ret = OT_ERROR_BUSY;
while ((otPlatAlarmMilliGetNow() - start) < aTimeout)
{
if (FlashCheckFsmForReady() == FAPI_STATUS_FSM_READY)
{
ret = OT_ERROR_NONE;
break;
}
}
return ret;
}
/**
* Function documented in platforms/utils/flash.h
*/
uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
{
uint32_t mode;
uint32_t written = 0;
otEXPECT(checkVoltage());
mode = disableFlashCache();
for (uint8_t page = 0; page < FLASH_PAGE_NUM; page++)
{
FlashSectorErase(mapAddress(aSwapIndex, (page * FLASH_PAGE_SIZE)));
}
restoreFlashCache(mode);
while (FlashCheckFsmForReady() != FAPI_STATUS_FSM_READY)
{
}
exit:
return;
}
/**
* Function documented in platforms/utils/flash.h
*/
void otPlatFlashWrite(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, const void *aData, uint32_t aSize)
{
OT_UNUSED_VARIABLE(aInstance);
uint32_t mode;
uint32_t written = 0;
uint32_t address;
otEXPECT(checkVoltage());
mode = disableFlashCache();
address = mapAddress(aSwapIndex, aOffset);
while (written < aSize)
{
uint32_t toWrite = aSize - written;
uint8_t *data = aData + written;
uint32_t address = aAddress + written;
uint32_t fsmRet;
bool interruptsWereDisabled;
uint32_t toWrite = aSize - written;
const uint8_t *data = (uint8_t *)aData + written;
uint32_t fsmRet;
bool interruptsWereDisabled;
if (toWrite > MAX_WRITE_INCREMENT)
{
@@ -281,7 +229,7 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
*/
interruptsWereDisabled = IntMasterDisable();
fsmRet = FlashProgram(data, address, toWrite);
fsmRet = FlashProgram((uint8_t *)data, address + written, toWrite);
if (!interruptsWereDisabled)
{
@@ -299,15 +247,15 @@ uint32_t utilsFlashWrite(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
restoreFlashCache(mode);
exit:
return written;
return;
}
/**
* Function documented in platforms/utils/flash.h
*/
uint32_t utilsFlashRead(uint32_t aAddress, uint8_t *aData, uint32_t aSize)
void otPlatFlashRead(otInstance *aInstance, uint8_t aSwapIndex, uint32_t aOffset, void *aData, uint32_t aSize)
{
memcpy(aData, (void *)aAddress, (size_t)aSize);
OT_UNUSED_VARIABLE(aInstance);
return aSize;
memcpy(aData, (void *)mapAddress(aSwapIndex, aOffset), (size_t)aSize);
}
+1 -2
View File
@@ -36,8 +36,7 @@
#include <openthread/platform/logging.h>
#include <openthread/platform/toolchain.h>
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED) || \
(OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_NCP_SPINEL)
#if (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED)
OT_TOOL_WEAK void otPlatLog(otLogLevel aLogLevel, otLogRegion aLogRegion, const char *aFormat, ...)
{
OT_UNUSED_VARIABLE(aLogLevel);
@@ -38,27 +38,14 @@
#define OPENTHREAD_CONFIG_PLATFORM_INFO "CC1352"
/**
* @def SETTINGS_CONFIG_BASE_ADDRESS
* @def OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE
*
* Define to 1 to enable otPlatFlash* APIs to support non-volatile storage.
*
* When defined to 1, the platform MUST implement the otPlatFlash* APIs instead of the otPlatSettings* APIs.
*
* The base address of the pages to be used for non-volatile-settings storage.
*/
#define SETTINGS_CONFIG_BASE_ADDRESS (0x52000)
/**
* @def SETTINGS_CONFIG_PAGE_SIZE
*
* The size in bytes of a page for the cc26x2 platform.
*
* @note *MUST BE* 8K.
*/
#define SETTINGS_CONFIG_PAGE_SIZE (0x2000)
/**
* @def SETTINGS_CONFIG_PAGE_NUM
*
* The number of flash pages to use for non-volatile settings storage.
*/
#define SETTINGS_CONFIG_PAGE_NUM (2)
#define OPENTHREAD_CONFIG_PLATFORM_FLASH_API_ENABLE 1
/**
* @def OPENTHREAD_CONFIG_NCP_UART_ENABLE
+15 -11
View File
@@ -32,10 +32,12 @@
*
*/
#include "openthread-core-config.h"
#include <openthread/config.h>
#include <assert.h>
#include <utils/code_utils.h>
#include <utils/encoding.h>
#include <openthread/random_noncrypto.h> /* to seed the CSMA-CA funciton */
#include <openthread/platform/alarm-milli.h>
#include <openthread/platform/diag.h>
@@ -456,7 +458,7 @@ static uint_fast8_t rfCoreModifySourceMatchEntry(uint8_t aEntryNo, cc1352_addres
* @return The index where the address was found.
* @retval CC1352_SRC_MATCH_NONE The address was not found.
*/
static uint8_t rfCoreFindShortSrcMatchIdx(const uint16_t aAddress)
static uint8_t rfCoreFindShortSrcMatchIdx(uint16_t aAddress)
{
uint8_t i;
uint8_t ret = CC1352_SRC_MATCH_NONE;
@@ -1507,7 +1509,7 @@ void otPlatRadioEnableSrcMatch(otInstance *aInstance, bool aEnable)
/**
* Function documented in platform/radio.h
*/
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
otError otPlatRadioAddSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
{
OT_UNUSED_VARIABLE(aInstance);
@@ -1541,7 +1543,7 @@ exit:
/**
* Function documented in platform/radio.h
*/
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, const uint16_t aShortAddress)
otError otPlatRadioClearSrcMatchShortEntry(otInstance *aInstance, uint16_t aShortAddress)
{
OT_UNUSED_VARIABLE(aInstance);
@@ -1575,14 +1577,15 @@ otError otPlatRadioAddSrcMatchExtEntry(otInstance *aInstance, const otExtAddress
{
OT_UNUSED_VARIABLE(aInstance);
otError error = OT_ERROR_NONE;
uint8_t idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress);
otError error = OT_ERROR_NONE;
uint64_t extAddress = otEncodingReadUint64Le(aExtAddress->m8);
uint8_t idx = rfCoreFindExtSrcMatchIdx(&extAddress);
if (idx == CC1352_SRC_MATCH_NONE)
{
/* the entry does not exist already, add it */
otEXPECT_ACTION((idx = rfCoreFindEmptyExtSrcMatchIdx()) != CC1352_SRC_MATCH_NONE, error = OT_ERROR_NO_BUFS);
sSrcMatchExtData.extAddrEnt[idx] = *((uint64_t *)aExtAddress);
sSrcMatchExtData.extAddrEnt[idx] = extAddress;
}
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
@@ -1608,10 +1611,11 @@ otError otPlatRadioClearSrcMatchExtEntry(otInstance *aInstance, const otExtAddre
{
OT_UNUSED_VARIABLE(aInstance);
otError error = OT_ERROR_NONE;
uint8_t idx;
otError error = OT_ERROR_NONE;
uint64_t extAddress = otEncodingReadUint64Le(aExtAddress->m8);
uint8_t idx;
otEXPECT_ACTION((idx = rfCoreFindExtSrcMatchIdx((uint64_t *)aExtAddress)) != CC1352_SRC_MATCH_NONE,
otEXPECT_ACTION((idx = rfCoreFindExtSrcMatchIdx(&extAddress)) != CC1352_SRC_MATCH_NONE,
error = OT_ERROR_NO_ADDRESS);
if (sReceiveCmd.status == ACTIVE || sReceiveCmd.status == IEEE_SUSPENDED)
@@ -1809,7 +1813,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA
if (sState == cc1352_stateReceive)
{
otEXPECT(rfCoreExecuteAbortCmd() == CMDSTA_Done);
sReceiveCmd.localExtAddr = *((uint64_t *)(aAddress));
sReceiveCmd.localExtAddr = otEncodingReadUint64Le(aAddress->m8);
otEXPECT(rfCoreClearReceiveQueue(&sRxDataQueue) == CMDSTA_Done);
otEXPECT(rfCoreSendReceiveCmd() == CMDSTA_Done);
/* the interrupt from abort changed our state to sleep */
@@ -1817,7 +1821,7 @@ void otPlatRadioSetExtendedAddress(otInstance *aInstance, const otExtAddress *aA
}
else if (sState != cc1352_stateTransmit)
{
sReceiveCmd.localExtAddr = *((uint64_t *)(aAddress));
sReceiveCmd.localExtAddr = otEncodingReadUint64Le(aAddress->m8);
}
exit:
+82
View File
@@ -0,0 +1,82 @@
#
# Copyright (c) 2019, The OpenThread Authors.
# 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.
#
set(OT_PLATFORM_LIB "openthread-cc2538" PARENT_SCOPE)
if(NOT OT_CONFIG)
set(OT_CONFIG "openthread-core-cc2538-config.h")
set(OT_CONFIG ${OT_CONFIG} PARENT_SCOPE)
endif()
list(APPEND OT_PLATFORM_DEFINES
"OPENTHREAD_CORE_CONFIG_PLATFORM_CHECK_FILE=\"openthread-core-cc2538-config-check.h\""
"OPENTHREAD_CONFIG_NCP_UART_ENABLE=1"
)
set(OT_PLATFORM_DEFINES ${OT_PLATFORM_DEFINES} PARENT_SCOPE)
list(APPEND OT_PLATFORM_DEFINES "OPENTHREAD_PROJECT_CORE_CONFIG_FILE=\"${OT_CONFIG}\"")
add_library(openthread-cc2538
alarm.c
diag.c
entropy.c
flash.c
misc.c
radio.c
startup-gcc.c
system.c
logging.c
uart.c
$<TARGET_OBJECTS:openthread-platform-utils>
)
set_target_properties(
openthread-cc2538
PROPERTIES
C_STANDARD 99
CXX_STANDARD 11
)
target_link_libraries(openthread-cc2538 PRIVATE openthread-platform-utils ot-config)
target_link_options(openthread-cc2538 PUBLIC -T${PROJECT_SOURCE_DIR}/examples/platforms/cc2538/cc2538.ld)
target_link_options(openthread-cc2538 PUBLIC -Wl,--gc-sections -Wl,-Map=$<TARGET_PROPERTY:NAME>.map)
target_compile_definitions(openthread-cc2538
PUBLIC
${OT_PLATFORM_DEFINES}
)
target_compile_options(openthread-cc2538 PRIVATE
${OT_CFLAGS}
)
target_include_directories(openthread-cc2538 PRIVATE
${OT_PUBLIC_INCLUDES}
${PROJECT_SOURCE_DIR}/examples/platforms
${PROJECT_SOURCE_DIR}/src/core
)
+4 -4
View File
@@ -28,6 +28,10 @@
include $(abs_top_nlbuild_autotools_dir)/automake/pre.am
# Do not enable -Wcast-align for this platform
override CFLAGS := $(filter-out -Wcast-align,$(CFLAGS))
override CXXFLAGS := $(filter-out -Wcast-align,$(CXXFLAGS))
lib_LIBRARIES = libopenthread-cc2538.a
libopenthread_cc2538_a_CPPFLAGS = \
@@ -58,10 +62,6 @@ libopenthread_cc2538_a_SOURCES = \
$(PLATFORM_SOURCES) \
$(NULL)
PRETTY_FILES = \
$(PLATFORM_SOURCES) \
$(NULL)
Dash = -
libopenthread_cc2538_a_LIBADD = \
$(shell find $(top_builddir)/examples/platforms/utils $(Dash)type f $(Dash)name "*.o")

Some files were not shown because too many files have changed in this diff Show More