xref: /aosp_15_r20/external/openthread/include/openthread/instance.h (revision cfb92d1480a9e65faed56933e9c12405f45898b4)
1*cfb92d14SAndroid Build Coastguard Worker /*
2*cfb92d14SAndroid Build Coastguard Worker  *  Copyright (c) 2016, The OpenThread Authors.
3*cfb92d14SAndroid Build Coastguard Worker  *  All rights reserved.
4*cfb92d14SAndroid Build Coastguard Worker  *
5*cfb92d14SAndroid Build Coastguard Worker  *  Redistribution and use in source and binary forms, with or without
6*cfb92d14SAndroid Build Coastguard Worker  *  modification, are permitted provided that the following conditions are met:
7*cfb92d14SAndroid Build Coastguard Worker  *  1. Redistributions of source code must retain the above copyright
8*cfb92d14SAndroid Build Coastguard Worker  *     notice, this list of conditions and the following disclaimer.
9*cfb92d14SAndroid Build Coastguard Worker  *  2. Redistributions in binary form must reproduce the above copyright
10*cfb92d14SAndroid Build Coastguard Worker  *     notice, this list of conditions and the following disclaimer in the
11*cfb92d14SAndroid Build Coastguard Worker  *     documentation and/or other materials provided with the distribution.
12*cfb92d14SAndroid Build Coastguard Worker  *  3. Neither the name of the copyright holder nor the
13*cfb92d14SAndroid Build Coastguard Worker  *     names of its contributors may be used to endorse or promote products
14*cfb92d14SAndroid Build Coastguard Worker  *     derived from this software without specific prior written permission.
15*cfb92d14SAndroid Build Coastguard Worker  *
16*cfb92d14SAndroid Build Coastguard Worker  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17*cfb92d14SAndroid Build Coastguard Worker  *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18*cfb92d14SAndroid Build Coastguard Worker  *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19*cfb92d14SAndroid Build Coastguard Worker  *  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20*cfb92d14SAndroid Build Coastguard Worker  *  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21*cfb92d14SAndroid Build Coastguard Worker  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22*cfb92d14SAndroid Build Coastguard Worker  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23*cfb92d14SAndroid Build Coastguard Worker  *  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24*cfb92d14SAndroid Build Coastguard Worker  *  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25*cfb92d14SAndroid Build Coastguard Worker  *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26*cfb92d14SAndroid Build Coastguard Worker  *  POSSIBILITY OF SUCH DAMAGE.
27*cfb92d14SAndroid Build Coastguard Worker  */
28*cfb92d14SAndroid Build Coastguard Worker 
29*cfb92d14SAndroid Build Coastguard Worker /**
30*cfb92d14SAndroid Build Coastguard Worker  * @file
31*cfb92d14SAndroid Build Coastguard Worker  * @brief
32*cfb92d14SAndroid Build Coastguard Worker  *  This file defines the OpenThread Instance API.
33*cfb92d14SAndroid Build Coastguard Worker  */
34*cfb92d14SAndroid Build Coastguard Worker 
35*cfb92d14SAndroid Build Coastguard Worker #ifndef OPENTHREAD_INSTANCE_H_
36*cfb92d14SAndroid Build Coastguard Worker #define OPENTHREAD_INSTANCE_H_
37*cfb92d14SAndroid Build Coastguard Worker 
38*cfb92d14SAndroid Build Coastguard Worker #include <stdlib.h>
39*cfb92d14SAndroid Build Coastguard Worker 
40*cfb92d14SAndroid Build Coastguard Worker #include <openthread/error.h>
41*cfb92d14SAndroid Build Coastguard Worker #include <openthread/platform/logging.h>
42*cfb92d14SAndroid Build Coastguard Worker #include <openthread/platform/toolchain.h>
43*cfb92d14SAndroid Build Coastguard Worker 
44*cfb92d14SAndroid Build Coastguard Worker #ifdef __cplusplus
45*cfb92d14SAndroid Build Coastguard Worker extern "C" {
46*cfb92d14SAndroid Build Coastguard Worker #endif
47*cfb92d14SAndroid Build Coastguard Worker 
48*cfb92d14SAndroid Build Coastguard Worker /**
49*cfb92d14SAndroid Build Coastguard Worker  * The OpenThread API monotonic version number.
50*cfb92d14SAndroid Build Coastguard Worker  *
51*cfb92d14SAndroid Build Coastguard Worker  * This number MUST increase by one each time the contents of public OpenThread API include headers change.
52*cfb92d14SAndroid Build Coastguard Worker  *
53*cfb92d14SAndroid Build Coastguard Worker  * @note This number versions both OpenThread platform and user APIs.
54*cfb92d14SAndroid Build Coastguard Worker  *
55*cfb92d14SAndroid Build Coastguard Worker  */
56*cfb92d14SAndroid Build Coastguard Worker #define OPENTHREAD_API_VERSION (460)
57*cfb92d14SAndroid Build Coastguard Worker 
58*cfb92d14SAndroid Build Coastguard Worker /**
59*cfb92d14SAndroid Build Coastguard Worker  * @addtogroup api-instance
60*cfb92d14SAndroid Build Coastguard Worker  *
61*cfb92d14SAndroid Build Coastguard Worker  * @brief
62*cfb92d14SAndroid Build Coastguard Worker  *   This module includes functions that control the OpenThread Instance.
63*cfb92d14SAndroid Build Coastguard Worker  *
64*cfb92d14SAndroid Build Coastguard Worker  * @{
65*cfb92d14SAndroid Build Coastguard Worker  *
66*cfb92d14SAndroid Build Coastguard Worker  */
67*cfb92d14SAndroid Build Coastguard Worker 
68*cfb92d14SAndroid Build Coastguard Worker /**
69*cfb92d14SAndroid Build Coastguard Worker  * Represents the OpenThread instance structure.
70*cfb92d14SAndroid Build Coastguard Worker  */
71*cfb92d14SAndroid Build Coastguard Worker typedef struct otInstance otInstance;
72*cfb92d14SAndroid Build Coastguard Worker 
73*cfb92d14SAndroid Build Coastguard Worker /**
74*cfb92d14SAndroid Build Coastguard Worker  * Initializes the OpenThread library.
75*cfb92d14SAndroid Build Coastguard Worker  *
76*cfb92d14SAndroid Build Coastguard Worker  * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
77*cfb92d14SAndroid Build Coastguard Worker  * called before any other calls to OpenThread.
78*cfb92d14SAndroid Build Coastguard Worker  *
79*cfb92d14SAndroid Build Coastguard Worker  * Is available and can only be used when support for multiple OpenThread instances is enabled.
80*cfb92d14SAndroid Build Coastguard Worker  *
81*cfb92d14SAndroid Build Coastguard Worker  * @param[in]     aInstanceBuffer      The buffer for OpenThread to use for allocating the otInstance structure.
82*cfb92d14SAndroid Build Coastguard Worker  * @param[in,out] aInstanceBufferSize  On input, the size of aInstanceBuffer. On output, if not enough space for
83*cfb92d14SAndroid Build Coastguard Worker  *                                     otInstance, the number of bytes required for otInstance.
84*cfb92d14SAndroid Build Coastguard Worker  *
85*cfb92d14SAndroid Build Coastguard Worker  * @returns  A pointer to the new OpenThread instance.
86*cfb92d14SAndroid Build Coastguard Worker  *
87*cfb92d14SAndroid Build Coastguard Worker  * @sa otInstanceFinalize
88*cfb92d14SAndroid Build Coastguard Worker  *
89*cfb92d14SAndroid Build Coastguard Worker  */
90*cfb92d14SAndroid Build Coastguard Worker otInstance *otInstanceInit(void *aInstanceBuffer, size_t *aInstanceBufferSize);
91*cfb92d14SAndroid Build Coastguard Worker 
92*cfb92d14SAndroid Build Coastguard Worker /**
93*cfb92d14SAndroid Build Coastguard Worker  * Initializes the static single instance of the OpenThread library.
94*cfb92d14SAndroid Build Coastguard Worker  *
95*cfb92d14SAndroid Build Coastguard Worker  * Initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
96*cfb92d14SAndroid Build Coastguard Worker  * called before any other calls to OpenThread.
97*cfb92d14SAndroid Build Coastguard Worker  *
98*cfb92d14SAndroid Build Coastguard Worker  * Is available and can only be used when support for multiple OpenThread instances is disabled.
99*cfb92d14SAndroid Build Coastguard Worker  *
100*cfb92d14SAndroid Build Coastguard Worker  * @returns A pointer to the single OpenThread instance.
101*cfb92d14SAndroid Build Coastguard Worker  *
102*cfb92d14SAndroid Build Coastguard Worker  */
103*cfb92d14SAndroid Build Coastguard Worker otInstance *otInstanceInitSingle(void);
104*cfb92d14SAndroid Build Coastguard Worker 
105*cfb92d14SAndroid Build Coastguard Worker /**
106*cfb92d14SAndroid Build Coastguard Worker  * Initializes the OpenThread instance.
107*cfb92d14SAndroid Build Coastguard Worker  *
108*cfb92d14SAndroid Build Coastguard Worker  * This function initializes OpenThread and prepares it for subsequent OpenThread API calls. This function must be
109*cfb92d14SAndroid Build Coastguard Worker  * called before any other calls to OpenThread. This method utilizes static buffer to initialize the OpenThread
110*cfb92d14SAndroid Build Coastguard Worker  * instance.
111*cfb92d14SAndroid Build Coastguard Worker  *
112*cfb92d14SAndroid Build Coastguard Worker  * This function is available and can only be used when support for multiple OpenThread static instances is
113*cfb92d14SAndroid Build Coastguard Worker  * enabled (`OPENTHREAD_CONFIG_MULTIPLE_STATIC_INSTANCE_ENABLE`)
114*cfb92d14SAndroid Build Coastguard Worker  *
115*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aIdx The index of the OpenThread instance to initialize.
116*cfb92d14SAndroid Build Coastguard Worker  *
117*cfb92d14SAndroid Build Coastguard Worker  * @returns  A pointer to the new OpenThread instance.
118*cfb92d14SAndroid Build Coastguard Worker  *
119*cfb92d14SAndroid Build Coastguard Worker  */
120*cfb92d14SAndroid Build Coastguard Worker otInstance *otInstanceInitMultiple(uint8_t aIdx);
121*cfb92d14SAndroid Build Coastguard Worker 
122*cfb92d14SAndroid Build Coastguard Worker /**
123*cfb92d14SAndroid Build Coastguard Worker  * Gets the instance identifier.
124*cfb92d14SAndroid Build Coastguard Worker  *
125*cfb92d14SAndroid Build Coastguard Worker  * The instance identifier is set to a random value when the instance is constructed, and then its value will not
126*cfb92d14SAndroid Build Coastguard Worker  * change after initialization.
127*cfb92d14SAndroid Build Coastguard Worker  *
128*cfb92d14SAndroid Build Coastguard Worker  * @returns The instance identifier.
129*cfb92d14SAndroid Build Coastguard Worker  *
130*cfb92d14SAndroid Build Coastguard Worker  */
131*cfb92d14SAndroid Build Coastguard Worker uint32_t otInstanceGetId(otInstance *aInstance);
132*cfb92d14SAndroid Build Coastguard Worker 
133*cfb92d14SAndroid Build Coastguard Worker /**
134*cfb92d14SAndroid Build Coastguard Worker  * Indicates whether or not the instance is valid/initialized.
135*cfb92d14SAndroid Build Coastguard Worker  *
136*cfb92d14SAndroid Build Coastguard Worker  * The instance is considered valid if it is acquired and initialized using either `otInstanceInitSingle()` (in single
137*cfb92d14SAndroid Build Coastguard Worker  * instance case) or `otInstanceInit()` (in multi instance case). A subsequent call to `otInstanceFinalize()` causes
138*cfb92d14SAndroid Build Coastguard Worker  * the instance to be considered as uninitialized.
139*cfb92d14SAndroid Build Coastguard Worker  *
140*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aInstance A pointer to an OpenThread instance.
141*cfb92d14SAndroid Build Coastguard Worker  *
142*cfb92d14SAndroid Build Coastguard Worker  * @returns TRUE if the given instance is valid/initialized, FALSE otherwise.
143*cfb92d14SAndroid Build Coastguard Worker  *
144*cfb92d14SAndroid Build Coastguard Worker  */
145*cfb92d14SAndroid Build Coastguard Worker bool otInstanceIsInitialized(otInstance *aInstance);
146*cfb92d14SAndroid Build Coastguard Worker 
147*cfb92d14SAndroid Build Coastguard Worker /**
148*cfb92d14SAndroid Build Coastguard Worker  * Disables the OpenThread library.
149*cfb92d14SAndroid Build Coastguard Worker  *
150*cfb92d14SAndroid Build Coastguard Worker  * Call this function when OpenThread is no longer in use.
151*cfb92d14SAndroid Build Coastguard Worker  *
152*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aInstance A pointer to an OpenThread instance.
153*cfb92d14SAndroid Build Coastguard Worker  *
154*cfb92d14SAndroid Build Coastguard Worker  */
155*cfb92d14SAndroid Build Coastguard Worker void otInstanceFinalize(otInstance *aInstance);
156*cfb92d14SAndroid Build Coastguard Worker 
157*cfb92d14SAndroid Build Coastguard Worker /**
158*cfb92d14SAndroid Build Coastguard Worker  * Returns the current instance uptime (in msec).
159*cfb92d14SAndroid Build Coastguard Worker  *
160*cfb92d14SAndroid Build Coastguard Worker  * Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled.
161*cfb92d14SAndroid Build Coastguard Worker  *
162*cfb92d14SAndroid Build Coastguard Worker  * The uptime is given as number of milliseconds since OpenThread instance was initialized.
163*cfb92d14SAndroid Build Coastguard Worker  *
164*cfb92d14SAndroid Build Coastguard Worker  * @param[in] aInstance A pointer to an OpenThread instance.
165*cfb92d14SAndroid Build Coastguard Worker  *
166*cfb92d14SAndroid Build Coastguard Worker  * @returns The uptime (number of milliseconds).
167*cfb92d14SAndroid Build Coastguard Worker  *
168*cfb92d14SAndroid Build Coastguard Worker  */
169*cfb92d14SAndroid Build Coastguard Worker uint64_t otInstanceGetUptime(otInstance *aInstance);
170*cfb92d14SAndroid Build Coastguard Worker 
171*cfb92d14SAndroid Build Coastguard Worker #define OT_UPTIME_STRING_SIZE 24 ///< Recommended size for string representation of uptime.
172*cfb92d14SAndroid Build Coastguard Worker 
173*cfb92d14SAndroid Build Coastguard Worker /**
174*cfb92d14SAndroid Build Coastguard Worker  * Returns the current instance uptime as a human-readable string.
175*cfb92d14SAndroid Build Coastguard Worker  *
176*cfb92d14SAndroid Build Coastguard Worker  * Requires `OPENTHREAD_CONFIG_UPTIME_ENABLE` to be enabled.
177*cfb92d14SAndroid Build Coastguard Worker  *
178*cfb92d14SAndroid Build Coastguard Worker  * The string follows the format "<hh>:<mm>:<ss>.<mmmm>" for hours, minutes, seconds and millisecond (if uptime is
179*cfb92d14SAndroid Build Coastguard Worker  * shorter than one day) or "<dd>d.<hh>:<mm>:<ss>.<mmmm>" (if longer than a day).
180*cfb92d14SAndroid Build Coastguard Worker  *
181*cfb92d14SAndroid Build Coastguard Worker  * If the resulting string does not fit in @p aBuffer (within its @p aSize characters), the string will be truncated
182*cfb92d14SAndroid Build Coastguard Worker  * but the outputted string is always null-terminated.
183*cfb92d14SAndroid Build Coastguard Worker  *
184*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance A pointer to an OpenThread instance.
185*cfb92d14SAndroid Build Coastguard Worker  * @param[out] aBuffer   A pointer to a char array to output the string.
186*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aSize     The size of @p aBuffer (in bytes). Recommended to use `OT_UPTIME_STRING_SIZE`.
187*cfb92d14SAndroid Build Coastguard Worker  *
188*cfb92d14SAndroid Build Coastguard Worker  */
189*cfb92d14SAndroid Build Coastguard Worker void otInstanceGetUptimeAsString(otInstance *aInstance, char *aBuffer, uint16_t aSize);
190*cfb92d14SAndroid Build Coastguard Worker 
191*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_IP6_ADDRESS_ADDED (1U << 0)             ///< IPv6 address was added
192*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_IP6_ADDRESS_REMOVED (1U << 1)           ///< IPv6 address was removed
193*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_ROLE (1U << 2)                   ///< Role (disabled, detached, child, router, leader) changed
194*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_LL_ADDR (1U << 3)                ///< The link-local address changed
195*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_ML_ADDR (1U << 4)                ///< The mesh-local address changed
196*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_RLOC_ADDED (1U << 5)             ///< RLOC was added
197*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_RLOC_REMOVED (1U << 6)           ///< RLOC was removed
198*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_PARTITION_ID (1U << 7)           ///< Partition ID changed
199*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_KEY_SEQUENCE_COUNTER (1U << 8)   ///< Thread Key Sequence changed
200*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_NETDATA (1U << 9)                ///< Thread Network Data changed
201*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_CHILD_ADDED (1U << 10)           ///< Child was added
202*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_CHILD_REMOVED (1U << 11)         ///< Child was removed
203*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_IP6_MULTICAST_SUBSCRIBED (1U << 12)     ///< Subscribed to a IPv6 multicast address
204*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_IP6_MULTICAST_UNSUBSCRIBED (1U << 13)   ///< Unsubscribed from a IPv6 multicast address
205*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_CHANNEL (1U << 14)               ///< Thread network channel changed
206*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_PANID (1U << 15)                 ///< Thread network PAN Id changed
207*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_NETWORK_NAME (1U << 16)          ///< Thread network name changed
208*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_EXT_PANID (1U << 17)             ///< Thread network extended PAN ID changed
209*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_NETWORK_KEY (1U << 18)                  ///< Network key changed
210*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_PSKC (1U << 19)                         ///< PSKc changed
211*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_SECURITY_POLICY (1U << 20)              ///< Security Policy changed
212*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL (1U << 21)  ///< Channel Manager new pending Thread channel changed
213*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_SUPPORTED_CHANNEL_MASK (1U << 22)       ///< Supported channel mask changed
214*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_COMMISSIONER_STATE (1U << 23)           ///< Commissioner state changed
215*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_NETIF_STATE (1U << 24)           ///< Thread network interface state changed
216*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_BACKBONE_ROUTER_STATE (1U << 25) ///< Backbone Router state changed
217*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_THREAD_BACKBONE_ROUTER_LOCAL (1U << 26) ///< Local Backbone Router configuration changed
218*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_JOINER_STATE (1U << 27)                 ///< Joiner state changed
219*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_ACTIVE_DATASET (1U << 28)               ///< Active Operational Dataset changed
220*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_PENDING_DATASET (1U << 29)              ///< Pending Operational Dataset changed
221*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_NAT64_TRANSLATOR_STATE (1U << 30)       ///< The state of NAT64 translator changed
222*cfb92d14SAndroid Build Coastguard Worker #define OT_CHANGED_PARENT_LINK_QUALITY (1U << 31)          ///< Parent link quality changed
223*cfb92d14SAndroid Build Coastguard Worker 
224*cfb92d14SAndroid Build Coastguard Worker /**
225*cfb92d14SAndroid Build Coastguard Worker  * Represents a bit-field indicating specific state/configuration that has changed. See `OT_CHANGED_*`
226*cfb92d14SAndroid Build Coastguard Worker  * definitions.
227*cfb92d14SAndroid Build Coastguard Worker  *
228*cfb92d14SAndroid Build Coastguard Worker  */
229*cfb92d14SAndroid Build Coastguard Worker typedef uint32_t otChangedFlags;
230*cfb92d14SAndroid Build Coastguard Worker 
231*cfb92d14SAndroid Build Coastguard Worker /**
232*cfb92d14SAndroid Build Coastguard Worker  * Pointer is called to notify certain configuration or state changes within OpenThread.
233*cfb92d14SAndroid Build Coastguard Worker  *
234*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aFlags    A bit-field indicating specific state that has changed.  See `OT_CHANGED_*` definitions.
235*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aContext  A pointer to application-specific context.
236*cfb92d14SAndroid Build Coastguard Worker  *
237*cfb92d14SAndroid Build Coastguard Worker  */
238*cfb92d14SAndroid Build Coastguard Worker typedef void (*otStateChangedCallback)(otChangedFlags aFlags, void *aContext);
239*cfb92d14SAndroid Build Coastguard Worker 
240*cfb92d14SAndroid Build Coastguard Worker /**
241*cfb92d14SAndroid Build Coastguard Worker  * Registers a callback to indicate when certain configuration or state changes within OpenThread.
242*cfb92d14SAndroid Build Coastguard Worker  *
243*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance  A pointer to an OpenThread instance.
244*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aCallback  A pointer to a function that is called with certain configuration or state changes.
245*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aContext   A pointer to application-specific context.
246*cfb92d14SAndroid Build Coastguard Worker  *
247*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NONE     Added the callback to the list of callbacks.
248*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_ALREADY  The callback was already registered.
249*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NO_BUFS  Could not add the callback due to resource constraints.
250*cfb92d14SAndroid Build Coastguard Worker  *
251*cfb92d14SAndroid Build Coastguard Worker  */
252*cfb92d14SAndroid Build Coastguard Worker otError otSetStateChangedCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext);
253*cfb92d14SAndroid Build Coastguard Worker 
254*cfb92d14SAndroid Build Coastguard Worker /**
255*cfb92d14SAndroid Build Coastguard Worker  * Removes a callback to indicate when certain configuration or state changes within OpenThread.
256*cfb92d14SAndroid Build Coastguard Worker  *
257*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance   A pointer to an OpenThread instance.
258*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aCallback   A pointer to a function that is called with certain configuration or state changes.
259*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aContext    A pointer to application-specific context.
260*cfb92d14SAndroid Build Coastguard Worker  *
261*cfb92d14SAndroid Build Coastguard Worker  */
262*cfb92d14SAndroid Build Coastguard Worker void otRemoveStateChangeCallback(otInstance *aInstance, otStateChangedCallback aCallback, void *aContext);
263*cfb92d14SAndroid Build Coastguard Worker 
264*cfb92d14SAndroid Build Coastguard Worker /**
265*cfb92d14SAndroid Build Coastguard Worker  * Triggers a platform reset.
266*cfb92d14SAndroid Build Coastguard Worker  *
267*cfb92d14SAndroid Build Coastguard Worker  * The reset process ensures that all the OpenThread state/info (stored in volatile memory) is erased. Note that the
268*cfb92d14SAndroid Build Coastguard Worker  * `otPlatformReset` does not erase any persistent state/info saved in non-volatile memory.
269*cfb92d14SAndroid Build Coastguard Worker  *
270*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance  A pointer to an OpenThread instance.
271*cfb92d14SAndroid Build Coastguard Worker  *
272*cfb92d14SAndroid Build Coastguard Worker  */
273*cfb92d14SAndroid Build Coastguard Worker void otInstanceReset(otInstance *aInstance);
274*cfb92d14SAndroid Build Coastguard Worker 
275*cfb92d14SAndroid Build Coastguard Worker /**
276*cfb92d14SAndroid Build Coastguard Worker  * Triggers a platform reset to bootloader mode, if supported.
277*cfb92d14SAndroid Build Coastguard Worker  *
278*cfb92d14SAndroid Build Coastguard Worker  * Requires `OPENTHREAD_CONFIG_PLATFORM_BOOTLOADER_MODE_ENABLE`.
279*cfb92d14SAndroid Build Coastguard Worker  *
280*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance  A pointer to an OpenThread instance.
281*cfb92d14SAndroid Build Coastguard Worker  *
282*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NONE         Reset to bootloader successfully.
283*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_BUSY         Failed due to another operation is ongoing.
284*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NOT_CAPABLE  Not capable of resetting to bootloader.
285*cfb92d14SAndroid Build Coastguard Worker  *
286*cfb92d14SAndroid Build Coastguard Worker  */
287*cfb92d14SAndroid Build Coastguard Worker otError otInstanceResetToBootloader(otInstance *aInstance);
288*cfb92d14SAndroid Build Coastguard Worker 
289*cfb92d14SAndroid Build Coastguard Worker /**
290*cfb92d14SAndroid Build Coastguard Worker  * Deletes all the settings stored on non-volatile memory, and then triggers a platform reset.
291*cfb92d14SAndroid Build Coastguard Worker  *
292*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance  A pointer to an OpenThread instance.
293*cfb92d14SAndroid Build Coastguard Worker  *
294*cfb92d14SAndroid Build Coastguard Worker  */
295*cfb92d14SAndroid Build Coastguard Worker void otInstanceFactoryReset(otInstance *aInstance);
296*cfb92d14SAndroid Build Coastguard Worker 
297*cfb92d14SAndroid Build Coastguard Worker /**
298*cfb92d14SAndroid Build Coastguard Worker  * Resets the internal states of the OpenThread radio stack.
299*cfb92d14SAndroid Build Coastguard Worker  *
300*cfb92d14SAndroid Build Coastguard Worker  * Callbacks and configurations are preserved.
301*cfb92d14SAndroid Build Coastguard Worker  *
302*cfb92d14SAndroid Build Coastguard Worker  * This API is only available under radio builds (`OPENTHREAD_RADIO = 1`).
303*cfb92d14SAndroid Build Coastguard Worker  *
304*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance  A pointer to an OpenThread instance.
305*cfb92d14SAndroid Build Coastguard Worker  *
306*cfb92d14SAndroid Build Coastguard Worker  */
307*cfb92d14SAndroid Build Coastguard Worker void otInstanceResetRadioStack(otInstance *aInstance);
308*cfb92d14SAndroid Build Coastguard Worker 
309*cfb92d14SAndroid Build Coastguard Worker /**
310*cfb92d14SAndroid Build Coastguard Worker  * Erases all the OpenThread persistent info (network settings) stored on non-volatile memory.
311*cfb92d14SAndroid Build Coastguard Worker  * Erase is successful only if the device is in `disabled` state/role.
312*cfb92d14SAndroid Build Coastguard Worker  *
313*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance A pointer to an OpenThread instance.
314*cfb92d14SAndroid Build Coastguard Worker  *
315*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_NONE           All persistent info/state was erased successfully.
316*cfb92d14SAndroid Build Coastguard Worker  * @retval OT_ERROR_INVALID_STATE  Device is not in `disabled` state/role.
317*cfb92d14SAndroid Build Coastguard Worker  *
318*cfb92d14SAndroid Build Coastguard Worker  */
319*cfb92d14SAndroid Build Coastguard Worker otError otInstanceErasePersistentInfo(otInstance *aInstance);
320*cfb92d14SAndroid Build Coastguard Worker 
321*cfb92d14SAndroid Build Coastguard Worker /**
322*cfb92d14SAndroid Build Coastguard Worker  * Gets the OpenThread version string.
323*cfb92d14SAndroid Build Coastguard Worker  *
324*cfb92d14SAndroid Build Coastguard Worker  * @returns A pointer to the OpenThread version.
325*cfb92d14SAndroid Build Coastguard Worker  *
326*cfb92d14SAndroid Build Coastguard Worker  */
327*cfb92d14SAndroid Build Coastguard Worker const char *otGetVersionString(void);
328*cfb92d14SAndroid Build Coastguard Worker 
329*cfb92d14SAndroid Build Coastguard Worker /**
330*cfb92d14SAndroid Build Coastguard Worker  * Gets the OpenThread radio version string.
331*cfb92d14SAndroid Build Coastguard Worker  *
332*cfb92d14SAndroid Build Coastguard Worker  * @param[in]  aInstance A pointer to an OpenThread instance.
333*cfb92d14SAndroid Build Coastguard Worker  *
334*cfb92d14SAndroid Build Coastguard Worker  * @returns A pointer to the OpenThread radio version.
335*cfb92d14SAndroid Build Coastguard Worker  *
336*cfb92d14SAndroid Build Coastguard Worker  */
337*cfb92d14SAndroid Build Coastguard Worker const char *otGetRadioVersionString(otInstance *aInstance);
338*cfb92d14SAndroid Build Coastguard Worker 
339*cfb92d14SAndroid Build Coastguard Worker /**
340*cfb92d14SAndroid Build Coastguard Worker  * @}
341*cfb92d14SAndroid Build Coastguard Worker  *
342*cfb92d14SAndroid Build Coastguard Worker  */
343*cfb92d14SAndroid Build Coastguard Worker 
344*cfb92d14SAndroid Build Coastguard Worker #ifdef __cplusplus
345*cfb92d14SAndroid Build Coastguard Worker } // extern "C"
346*cfb92d14SAndroid Build Coastguard Worker #endif
347*cfb92d14SAndroid Build Coastguard Worker 
348*cfb92d14SAndroid Build Coastguard Worker #endif // OPENTHREAD_INSTANCE_H_
349