Skip to content

feat(openthread): adds native api #11474

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2025

Conversation

SuGlider
Copy link
Collaborator

@SuGlider SuGlider commented Jun 16, 2025


Description of Change

Extends Arduino OpenThread Library to implement Native API.
For more details, please read the new README.md file and provided library examples.

Tests scenarios

Using C6 and H2 with the provided CLI and Native examples

Related links

None

@SuGlider SuGlider added this to the 3.2.1 milestone Jun 16, 2025
@SuGlider SuGlider self-assigned this Jun 16, 2025
@SuGlider SuGlider requested a review from lucasssvaz as a code owner June 16, 2025 05:33
@SuGlider SuGlider added the Area: OpenThread Issues and Feature Request about OpenThread Protocol label Jun 16, 2025
@SuGlider SuGlider moved this from Todo to In Progress in Arduino ESP32 Core Project Roadmap Jun 16, 2025
Copy link
Contributor

github-actions bot commented Jun 16, 2025

Messages
📖 This PR seems to be quite large (total lines of code: 1038), you might consider splitting it into smaller PRs

👋 Hello SuGlider, we appreciate your contribution to this project!


📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more.

🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project.

Click to see more instructions ...


This automated output is generated by the PR linter DangerJS, which checks if your Pull Request meets the project's requirements and helps you fix potential issues.

DangerJS is triggered with each push event to a Pull Request and modify the contents of this comment.

Please consider the following:
- Danger mainly focuses on the PR structure and formatting and can't understand the meaning behind your code or changes.
- Danger is not a substitute for human code reviews; it's still important to request a code review from your colleagues.
- Addressing info messages (📖) is strongly recommended; they're less critical but valuable.
- To manually retry these Danger checks, please navigate to the Actions tab and re-run last Danger workflow.

Review and merge process you can expect ...


We do welcome contributions in the form of bug reports, feature requests and pull requests.

1. An internal issue has been created for the PR, we assign it to the relevant engineer.
2. They review the PR and either approve it or ask you for changes or clarifications.
3. Once the GitHub PR is approved we do the final review, collect approvals from core owners and make sure all the automated tests are passing.
- At this point we may do some adjustments to the proposed change, or extend it by adding tests or documentation.
4. If the change is approved and passes the tests it is merged into the default branch.

Generated by 🚫 dangerJS against a0e01f4

Copy link
Contributor

github-actions bot commented Jun 16, 2025

Test Results

 76 files   76 suites   12m 45s ⏱️
 38 tests  38 ✅ 0 💤 0 ❌
241 runs  241 ✅ 0 💤 0 ❌

Results for commit a0e01f4.

♻️ This comment has been updated with latest results.

@SuGlider SuGlider requested a review from me-no-dev as a code owner June 16, 2025 05:38
@SuGlider SuGlider requested a review from P-R-O-C-H-Y June 16, 2025 05:39
Copy link
Contributor

Memory usage test (comparing PR against master branch)

The table below shows the summary of memory usage change (decrease - increase) in bytes and percentage for each target.

MemoryFLASH [bytes]FLASH [%]RAM [bytes]RAM [%]
TargetDECINCDECINCDECINCDECINC
ESP32C6💚 -110K⚠️ +434💚 -10.42⚠️ +0.04💚 -200⚠️ +184💚 -0.43⚠️ +0.39
ESP32H2💚 -110K⚠️ +434💚 -10.23⚠️ +0.04💚 -216⚠️ +168💚 -0.47⚠️ +0.37
Click to expand the detailed deltas report [usage change in BYTES]
TargetESP32C6ESP32H2
ExampleFLASHRAMFLASHRAM
libraries/OpenThread/examples/CLI/COAP/coap_lamp⚠️ +394⚠️ +184⚠️ +386⚠️ +160
libraries/OpenThread/examples/CLI/COAP/coap_switch⚠️ +388⚠️ +176⚠️ +394⚠️ +160
libraries/OpenThread/examples/CLI/SimpleCLI⚠️ +432⚠️ +152⚠️ +434⚠️ +144
libraries/OpenThread/examples/CLI/SimpleNode💚 -1430⚠️ +176💚 -1440⚠️ +168
libraries/OpenThread/examples/CLI/SimpleThreadNetwork/ExtendedRouterNode⚠️ +318⚠️ +176⚠️ +322⚠️ +168
libraries/OpenThread/examples/CLI/SimpleThreadNetwork/LeaderNode⚠️ +350⚠️ +184⚠️ +358⚠️ +160
libraries/OpenThread/examples/CLI/SimpleThreadNetwork/RouterNode⚠️ +350⚠️ +184⚠️ +358⚠️ +160
libraries/OpenThread/examples/CLI/ThreadScan⚠️ +366⚠️ +152⚠️ +364⚠️ +144
libraries/OpenThread/examples/CLI/onReceive⚠️ +434⚠️ +152⚠️ +434⚠️ +144
libraries/OpenThread/examples/Native/SimpleThreadNetwork/LeaderNode💚 -109K💚 -200💚 -110K💚 -216
libraries/OpenThread/examples/Native/SimpleThreadNetwork/RouterNode💚 -110K💚 -200💚 -110K💚 -216

@me-no-dev me-no-dev requested a review from Copilot June 16, 2025 08:17
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Extends the Arduino OpenThread library by adding a native OThread API alongside the existing CLI API and updates all examples and build scripts to use the new class.

  • Introduces OThread.begin()/end() and prefixes all static API calls with OThread.
  • Updates example sketches to call OThread.begin(...) before OThreadCLI.begin()
  • Updates README documentation and CMakeLists to include the new source

Reviewed Changes

Copilot reviewed 31 out of 31 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libraries/OpenThread/examples/CLI/onReceive/onReceive.ino Switched from OThreadCLI.begin() to OThread.begin() then CLI
libraries/OpenThread/examples/CLI/ThreadScan/ThreadScan.ino Updated API calls to OThread. prefix and copyright
libraries/OpenThread/examples/CLI/SimpleThreadNetwork/RouterNode/RouterNode.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/examples/CLI/SimpleThreadNetwork/LeaderNode/LeaderNode.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/examples/CLI/SimpleThreadNetwork/ExtendedRouterNode/ExtendedRouterNode.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/examples/CLI/SimpleNode/SimpleNode.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/examples/CLI/SimpleCLI/SimpleCLI.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/examples/CLI/COAP/coap_switch/coap_switch.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/examples/CLI/COAP/coap_lamp/coap_lamp.ino Prefixed API with OThread. and reordered init calls
libraries/OpenThread/README.md Added native API docs, updated classes and methods
CMakeLists.txt Added OThread.cpp to OpenThread library sources
Comments suppressed due to low confidence (4)

libraries/OpenThread/examples/CLI/ThreadScan/ThreadScan.ino:30

  • [nitpick] The inline comment still refers to CLI auto-start behavior; update it to clarify that the true argument now applies to OThread.begin.
OThread.begin(true);      // For scanning, AutoStart must be active, any setup

libraries/OpenThread/README.md:239

  • [nitpick] This method description is duplicated under Console Management; consider consolidating to avoid confusion about which begin applies to CLI versus native API.
-- `begin(bool OThreadAutoStart = true)`: Initializes the OpenThread stack (optional auto-start).

libraries/OpenThread/README.md:165

  • The heading uses inline asterisks instead of a markdown heading; consider changing to ## Notes for consistency with other sections.
** Notes

CMakeLists.txt:168

  • If DataSet has its own .cpp implementation, it should also be added to the ARDUINO_LIBRARY_OpenThread_SRCS list to ensure it’s compiled.
  libraries/OpenThread/src/OThread.cpp

Copy link
Collaborator

@lucasssvaz lucasssvaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@me-no-dev me-no-dev added the Status: Pending Merge Pull Request is ready to be merged label Jun 16, 2025
@me-no-dev me-no-dev merged commit ef995b6 into espressif:master Jun 16, 2025
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: OpenThread Issues and Feature Request about OpenThread Protocol Status: Pending Merge Pull Request is ready to be merged
Projects
Development

Successfully merging this pull request may close these issues.

4 participants