155 Commits

Author SHA1 Message Date
Jonathan Hui 76db9dfec8 [cli] remove invalid log when tx buffer is full (#13091)
In CliUartOutput, if otPlatUartFlush() fails when trying to send
buffered output to make room for new output, it logs a warning using
otLogWarnPlat. However, this warning is added to the same full
buffer, which does not help and can cause further issues.

This commit removes the offending log line as suggested in issue #7478.
2026-05-11 18:25:38 -07:00
Abtin Keshavarzian fb216d335c [cmake] update CMake configurations for Apple platforms (#12729)
This commit updates various CMake configuration files to simplify
the check for Apple platforms. It replaces the `CMAKE_CXX_COMPILER_ID`
check for `AppleClang` with the built-in `APPLE` variable across
multiple targets (such as `ftd`, `mtd`, `cli`, and others). This
ensures that Apple-specific linker and compiler flags (like `-Wl,-map`
and `-Wimplicit-int-conversion`) are correctly applied when building
on macOS, regardless of the specific compiler used.

Additionally, this commit updates `CMakeLists.txt` to explicitly set
the `CMAKE_AR` and `CMAKE_RANLIB` paths to the default system
locations (`/usr/bin/ar` and `/usr/bin/ranlib`) when the `APPLE`
variable is set.
2026-03-20 13:19:29 -05:00
Yakun Xu e5d2c5860e [gn] add cli_uart (#12345)
This commit adds the `cli_uart` for applications to integrate OpenThread
CLI based on UART APIs. One of the example is OTNS.
2026-02-02 17:30:38 -08:00
Esko Dijk 213745a81f [cli] provide default 'APP' log output implementation in CLI module (#12309)
Refactors the example CLI app and the CLI module code to provide a
default implementation of the 'APP' log output option for any CLI
apps. This default is used when log output is configured to 'APP'
output and the CLI application itself does not provide its own
implementation of `otPlatLog()`.

This extends the current logging option (syslog) for the Posix app
ot-cli with the option to direct the log output to the CLI app, which
then prints it in stdout. This logging option can be enabled using the
existing -DOT_LOG_OUTPUT=APP. Previously, this gave a build error for
the Posix platform. This logging method is useful/required for running
NCPs in OTNS, such that the simulator can capture all log output and
at the same time syslog is not overly burdened on the host machine.
2026-01-21 12:30:29 -08:00
Yakun Xu 31631142c2 [build] add format-nonliteral to missed code (#12251)
This commit enables the format-nonliteral check for code missed in
`#12236`. This commit also enables the format-nonliteral warnings in
CMake to catch such warnings in future in CMake build.
2026-01-06 14:53:38 -08:00
Jonathan Hui 412596c990 [examples] define OPENTHREAD_FTD and OPENTHREAD_MTD (#11516) 2025-05-20 14:59:24 -07:00
Abtin Keshavarzian d1147d62b9 [trel] detect and handle socket addr discrepancy for TREL peers (#10869)
This commit introduces a new mechanism for the TREL link to detect and
handle discrepancies between the IPv6 address and port used by a TREL
peer in a received TREL packet, and the information previously
reported by the platform layer (through DNS-SD discovery) for the
same peer.

Ideally, the platform underlying DNS-SD should detect changes to
advertised ports and addresses by peers. However, there are
situations where this is not detected reliably.

As a received frame over the TREL radio link is processed by the MAC
or MLE layers, if the frame passes receive security checks at either
layer (indicating it is a secure and authenticated/fresh frame from a
valid neighbor), the TREL peer socket address is automatically
updated from the received TREL packet info. This ensures the TREL
peer table is updated correctly if there are changes to TREL peer
addresses of valid Thread neighbors upon rx from such neighbor,
increasing the robustness of the TREL link.

This commit also introduces a new `otPlatTrel` platform API,
`otPlatTrelNotifyPeerSocketAddressDifference()`. The TREL
implementation now notifies the platform layer whenever it detects a
discrepancy in a TREL peer's socket address, regardless of whether
the peer table is automatically updated. This allows the platform
layer to take any appropriate action, such as restarting or
confirming DNS-SD service resolution query for the peer service
instance and/or address resolution query for its associated host
name.

This commit also adds a new test that validates the newly added
behavior, including the auto-update of peer table information and
notification of the platform through the new API, triggered by either
MLE or MAC messages over the TREL radio link.
2024-12-18 20:35:58 -08:00
Thomas 5bd9de5f30 [examples] remove unneeded implementation otTaskletsSignalPending (#10849)
The implementation of `otTaskletsSignalPending` in
`examples/apps/<app>/main.c` is exactly the same as the weak
implementation in `tasklet_api.cpp`. No need to repeat it and blocking
other implementations of that function.
2024-10-21 13:51:19 +01:00
Jonathan Hui c182933979 [doxygen] remove empty line at end of block (#10748) 2024-09-24 09:51:34 -07:00
Abtin Keshavarzian cb1220d79b [cli] fix unused retval warning on otPlatLogCrashDump() call (#10369) 2024-06-12 17:50:48 -07:00
Mason Tran 502797c0b3 [spinel] add support for logging crash dumps (#10061)
This commit adds a new feature that allows platforms to log crash logs.

### Additions
- `void otPlatLogCrashDump(void)` - API that logs a crash dump using
  OpenThread Logging APIs
- `SPINEL_PROP_RCP_LOG_CRASH_DUMP` - spinel prop that calls
  `otPlatLogCrashDump()` when `Set`
- `SPINEL_CAP_RCP_LOG_CRASH_DUMP` - spinel capability denoting that a
  RCP supports logging crash dumps

### Usage
- For `ot-cli-ftd|mtd`, `otPlatLogCrashDump()` is called at the end of
  app initialization, before the main loop. See [main.c]
- For Host/RCP setups, during initialization, the Host gets the RCP
  capabilities. If the RCP has the `SPINEL_CAP_RCP_LOG_CRASH_DUMP`
  capability, the Host will `Set` the `SPINEL_PROP_RCP_LOG_CRASH_DUMP`
  property, triggering the RCP to call `otPlatLogCrashDump()`.
  - If RCP Recovery is enabled, the this will also happen once the RCP
    has been restored
2024-04-29 09:09:54 -07:00
Marek Porwisz 834c8cbc8e [spinel] add support for multiple spinel interfaces (#9360)
This feature allows the RCP to support multiple host stacks on different PANs
by making use of the spinel Interface ID.

Created unit tests for testing multipan feature with multiple ot-instance
support.

Based on Si-Labs PR #8914 by @parag-silabs, but a little different approach.
Instead of handling everything by a single sub-mac instance, multiple
OpenThread instances are created on RCP side that map to different IID.
Thanks to this there are separate data kept for each interface. Platform
is able to determine interface by ot instance pointer passed as an argument
to most of the API functions.
Tx/scan queue was removed as it is possible to request transmission in
parallel, it is up to the platform to decide if it should fail or queue
second tx or it has two radios available.

NOTE:
Platform needs to provide different otRadioFrame of each instance and
the processing needs to take into account the instance being used.

Signed-off-by: Marek Porwisz <marek.porwisz@nordicsemi.no>
2023-11-28 16:16:37 -08:00
Yakun Xu 9165bc62d7 [simulation] SIGHUP when parent dies (#9624) 2023-11-20 17:48:17 -08:00
Yakun Xu 11a38a63de [build] remove autotools (#9027)
This commit removes autotools support from OpenThread project.
2023-06-28 08:54:23 -07:00
Jonathan Hui 73ce42c6e6 [docs] remove redundant "This method" and "This function" (#9096)
- "This method "
- "This static method "
- "This function "
- "This structure "
- "This enumeration "
- "This class "
- "This methods "
- "This constructor "
- "This struct "
- "This type "
- "This template method "
- "This template class "
- "This const method "
- "This macro "
2023-05-29 10:11:10 -07:00
Mason Tran f3701b746a [build] add cmake option for generating .map files (#9006)
This adds the CMake option `OT_LINKER_MAP` which will generate `.map`
files for any executables built when the option is `ON`.
2023-04-28 13:39:59 -07:00
Nick Bertoldi 5657335de4 [cli] store cli user commands in container and support list prepend (#8977)
Calls to otCliSetUserCommand overwrite the pointer user command list
pointer each time it is invoked, which results in successive calls to
otCliSetUserCommand replacing the previously registered command list
instead of appending to it. This is particularly relevant for the
posix platform in which the main function registers a set of posix
specific commands without any way to extend the set.

This commit replaces the command list pointer with a container of
command lists associated with a registered context in order to support
prepending the active list of user commands up to a configurable value
which defaults to 1 to maintain current behavior.
2023-04-26 09:07:30 -07:00
Abtin Keshavarzian 2b67cd8ebb [simul-platform] enhance radio nodeidfilter command (#8740)
This commit updates the custom CLI command `nodeidfilter` defined for
simulation platform enabling filtering at radio level. This commit
enhances this command so it can be used as both a deny-list or an
allow-list. It also adds support to output the list and filter mode
when no arg is given.
2023-02-13 08:42:36 -08:00
Abtin Keshavarzian 99a615bec2 [clang-format] use AllowShortFunctionsOnASingleLine: All (#8502)
This commit updates `AllowShortFunctionsOnASingleLine` to `All`
from `InlineOnly`.
2022-12-08 09:34:05 -08:00
Jonathan Hui 9c467a23ae [clang-format] apply v14 changes (#8490) 2022-12-07 16:23:20 -08:00
Jiachen Dong bcf9d8058e [harness-simulation] add the usage of the CLI command nodeidfilter (#8196) 2022-09-23 12:20:05 -07:00
Mason Tran cc8e4cce15 [cmake] add interface libraries ot-config-(ftd|mtd|radio) (#8190)
This allows for more granular control of any configuration which
might need to be incorporated in the core library build.
2022-09-22 23:20:35 -07:00
Mason Tran 32d7405174 [examples] make built-in otPlatCalloc and otPlatFree definitions weak (#8188)
This will allow platforms to define their own `otPlatCalloc` and
`otPlatFree` functions which may not map directly to `calloc()`
and `free()`
2022-09-21 11:11:37 -07:00
Jiachen Dong a0c4ede86d [harness-simulation] add support for RF enclosure simulation (#8092)
This commit adds support for RF enclosure simulation. It can pass
Leader 9.2.9, Router 9.2.9 and Router 9.2.10 in Thread Test Harness
v56.0 now.
2022-09-14 14:31:06 -07:00
Mason Tran c8556dfd66 [cmake] add option for RCP specific mbedtls library (#7781)
This commit enables a different mbedtls library to be used for RCP
builds. This will make it possible to use a PSA Crypto mbedtls library
for FTD/MTD images while using a non-PSA crypto library on RCPs.
2022-06-02 19:26:29 -07:00
Yakun Xu 013ab41291 [gcov] use __gcov_dump() instead for gcc 11 (#7629)
__gcov_flush is removed from gcc 11. This commit moves reset setup to a
single header file.
2022-04-25 06:23:00 -07:00
Eduardo Montoya 47fd27be3e [mac] remove beacons payload (#7472)
Thread Specification v1.2.1 removes support for Thread Beacons payload.
2022-04-06 12:18:22 -07:00
Abtin Keshavarzian 564982c818 [log] implement new logging model with module name support (#7385)
This commit implements new logging model in OpenThread. Each core
module can specify its own module name using `RegisterLogModule()`.
The registered log module name is then included in the all the log
messages emitted from the specific file. This model replaces and
enhances the log region model.
2022-02-17 15:50:45 -08:00
nikita-s-wrk f4e1526a49 [cmake] add ability to pick custom lib for MTD/FTD (#7041)
This commit enables different libraries option for ftd, mtd and rcp
builds.
2021-10-19 17:28:02 -07:00
Simon Lin fcadd11ffb [cli-uart] fix va_end may not be called for va_copy (#7079) 2021-10-18 09:07:49 -07:00
Li Cao 097aa4f65d [cli] add cli-radio build (#6769)
Background:

In an early stage of developing a new product, developers may want to
verify the Thread related hardware functionality, for example, send,
receive, etc.  However if the product uses the posix <-> RCP mode,
it's hard to verify it before the posix daemon can run on the
host. cli-ftd and cli-mtd could be an alternative. However, if the
product uses the posix <-> RCP mode, the space of the 802.15.4 radio
chip will be very small. For example, nRF52811 doesn't have enough
space to flash cli-ftd or cli-mtd firmware. So this PR creates a new
firmware ot-cli-radio which has very limited functionality for
verifying the hardware.

Basically, the ot-cli-radio consists of openthread-radio and
libopenthread-cli-radio.a. It supports very few cli commands. The most
important command is diag. Currently, there are: diag, help, reset,
version.

Currently, the diag commands have different implementation on RCP:

- For commands like diag start, the process function
  (Diags::ProcessStart) is first called on host. Then host sends an
  SPI frame to the RCP and Diags::ProcessStart (different
  implementation) is called again on RCP.

- For commands like diag send, Diags::ProcessSend is first called on
  host.  Then host sends an SPI frame to the RCP, directly calling
  send API. And there is no Diags::ProcessSend implemented on RCP.

Let's call the implementation of Diags::Process* currently on host as
native diag commands. When we run ot-cli-radio, we should use the
native diag commands because it won't interact with a posix daemon and
it processes the diag commands through the whole process. So this PR
adds a new option OPENTHREAD_CONFIG_DIAG_NATIVE_CMDS_ON_RCP to control
whether to use the native diag implementation on RCP. When we use a
normal RCP, the option should be disabled. While when use
ot-cli-radio, the option should be enabled.
2021-09-18 09:51:35 -07:00
Simon Lin db2e313ef0 [cli] disallow concurrent commands (#6695)
This commit disallows concurrent commands.

With this commit, the CLI only execute a new command after it complete
the previous command. CLI can also prompt properly after the command
execution is done.

Other fixes and enhancements:
- Fixes premature command prompt
- Add ping async command for ping in async mode: output Done
  immediately but print ping responses later on.
- Fixes networkdiagnostic get outputs multiple Done by always waiting
  for 5 seconds.
2021-09-09 20:46:43 -07:00
Sam Kumar 6fa60be75c [tcp] add third_party module for TCPlp (#6885)
This commit creates a module in third_party for TCPlp code. It is a
placeholder for now; the actual code will be added in future commits.
2021-08-06 22:04:31 -07:00
Abtin Keshavarzian cbd9661308 [cli] new config to log input command and the resulting output (#6827)
This commit adds `OPENTHREAD_CONFIG_CLI_LOG_INPUT_OUTPUT_ENABLE`
option which configures the CLI module to log its input command
string and the resulting output. This is done in addition to emitting
the output string to the console. By default this config is enabled
on all POSIX based platforms and when `LOG_OUTPUT` is not set to use
CLI console itself.
2021-07-20 18:53:27 -07:00
Jonathan Hui aaabf25ff2 [network-key] change name from master to network (#6721) 2021-06-16 23:07:23 -07:00
Yakun Xu 833f8e2cff [cli] process exit in ot-ctl (#6605)
The exit command should only exit ot-ctl itself in daemon mode. This
commit adds processing exit command in the ot-ctl.

This commit also moves the exit command implementation out from core
as a user command on simulation and posix cli mode.
2021-05-10 23:22:51 -07:00
Jiacheng Guo 6fa74b7674 [cli] fix false alarm when printing empty line (#6499)
The OpenThread cli may print false alarms when calling
`OutputLine("")`. Fix accordingly.
2021-04-21 22:16:04 -07:00
Yakun Xu db1b980e57 [api] remove UART from in cli/ncp API (#6243)
This commit removes application library CLI/NCP dependency on platform
layer UART APIs. Instead, application layer provides callbacks sending
CLI/NCP data.

With this change, platforms with native support for formatted output
can simply implement the CLI output callback with something like
`vprintf()`.
2021-03-18 22:13:05 -07:00
kangping 31746000e8 [heap] fix external heap configuration (#6123)
The Instance::HeapCAlloc() method can not be used in constructors when
EXTERNAL_HEAP is enabled but works well when internal heap is
used. This is because the external heap methods are set by public
otHeapSetCAllocFree API after the OT instance is constructed.

This commit fixes this issue by having Instance::HeapCAlloc() using
otPlatCAlloc when EXTERNAL_HEAP is enabled. It also fixes build issues
when MULTIPLE_INSTANCE and EXTERNAL_HEAP are used together.
2021-02-05 10:15:13 -08:00
Jonathan Hui db364960a7 [nrf52811] only build CLI and RCP examples (not NCP) (#6043) 2021-01-06 15:01:56 -08:00
Abtin Keshavarzian 9964e5ee39 [logging] add optional otPlatLogLine() & use it in NCP/CLI (#5704)
This commit adds a new platform function `otPlatLogLine()`. This
function is optional and if not implemented by platform layer, a
default weak implementation is provided and used by the OpenThread
core using `otPlatLog()`.The new function is used by OpenThread core
when the feature `OPENTHREAD_CONFIG_LOG_DEFINE_AS_MACRO_ONLY` is not
enabled (which is the default behavior). In this case, the OT core
itself will prepare a full log line.

This commit also adds implementations of the new platform function for
the NCP and CLI modules.
2020-10-27 16:59:47 -07:00
Jonathan Hui 84097f706a [cmake] replace mbedcrypto with ${OT_MBEDTLS} (#5622) 2020-10-11 11:08:43 -07:00
Jonathan Hui 115e04f435 [cmake] add build options for FTD, MTD, and RCP (#5622) 2020-10-11 11:08:43 -07:00
Yakun Xu 8370395c47 [cli] remove multiple servers support (#5387) 2020-08-14 22:15:32 -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
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
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
Yakun Xu 23ed067d68 [cmake] make ot-config private (#5014) 2020-05-28 10:36:59 -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