Skip to content

Commit 198e6e8

Browse files
authored
feat(openthread): helper functions documentation
Create helper_functions.md for ESP32 Arduino OpenThread API
1 parent 001ae42 commit 198e6e8

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed
+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# OpenThread Helper Functions and Types
2+
3+
The following helper functions and types are designed to simplify writing Arduino sketches for OpenThread. They provide useful utilities for managing OpenThread stack behavior and interacting with the Thread network.
4+
5+
## Enumerated Type: `ot_device_role_t`
6+
7+
This enumeration defines the possible roles of a Thread device within the network:
8+
9+
- `OT_ROLE_DISABLED`: The Thread stack is disabled.
10+
- `OT_ROLE_DETACHED`: The device is not currently participating in a Thread network/partition.
11+
- `OT_ROLE_CHILD`: The device operates as a Thread Child.
12+
- `OT_ROLE_ROUTER`: The device operates as a Thread Router.
13+
- `OT_ROLE_LEADER`: The device operates as a Thread Leader.
14+
15+
## Struct: `ot_cmd_return_t`
16+
17+
This structure represents the return status of an OpenThread CLI command:
18+
19+
- `errorCode`: An integer representing the error code (if any).
20+
- `errorMessage`: A string containing an error message (if applicable).
21+
22+
## Function: `otGetDeviceRole()`
23+
24+
- Returns the current role of the device as an `ot_device_role_t` value.
25+
26+
## Function: `otGetStringDeviceRole()`
27+
28+
- Returns a human-readable string representation of the device role (e.g., "Child," "Router," etc.).
29+
30+
## Function: `otGetRespCmd(const char* cmd, char* resp = NULL, uint32_t respTimeout = 5000)`
31+
32+
- Executes an OpenThread CLI command and retrieves the response.
33+
- Parameters:
34+
- `cmd`: The OpenThread CLI command to execute.
35+
- `resp`: Optional buffer to store the response (if provided).
36+
- `respTimeout`: Timeout (in milliseconds) for waiting for the response.
37+
38+
## Function: `otExecCommand(const char* cmd, const char* arg, ot_cmd_return_t* returnCode = NULL)`
39+
40+
- Executes an OpenThread CLI command with an argument.
41+
- Parameters:
42+
- `cmd`: The OpenThread CLI command to execute.
43+
- `arg`: The argument for the command.
44+
- `returnCode`: Optional pointer to an `ot_cmd_return_t` structure to store the return status.
45+
46+
## Function: `otPrintRespCLI(const char* cmd, Stream& output, uint32_t respTimeout)`
47+
48+
- Executes an OpenThread CLI command and prints the response to the specified output stream.
49+
- Parameters:
50+
- `cmd`: The OpenThread CLI command to execute.
51+
- `output`: The output stream (e.g., Serial) to print the response.
52+
- `respTimeout`: Timeout (in milliseconds) for waiting for the response.
53+
54+
## Function: `otPrintNetworkInformation(Stream& output)`
55+
56+
- Prints information about the current Thread network to the specified output stream.
57+
- Parameters:
58+
- `output`: The output stream (e.g., Serial) to print the network information.

0 commit comments

Comments
 (0)