0.01.00
thread.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, The OpenThread Authors.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * 3. Neither the name of the copyright holder nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
35 #ifndef OPENTHREAD_THREAD_H_
36 #define OPENTHREAD_THREAD_H_
37 
38 #include <openthread/link.h>
39 #include <openthread/message.h>
40 #include <openthread/types.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
65 OTAPI otError OTCALL otThreadSetEnabled(otInstance *aInstance, bool aEnabled);
66 
77 
86 OTAPI otError OTCALL otThreadSetAutoStart(otInstance *aInstance, bool aStartAutomatically);
87 
98 
115 OTAPI otError OTCALL otThreadDiscover(otInstance *aInstance, uint32_t aScanChannels, uint16_t aPanId, bool aJoiner,
116  bool aEnableEui64Filtering, otHandleActiveScanResult aCallback,
117  void *aCallbackContext);
118 
126 
136 OTAPI uint32_t OTCALL otThreadGetChildTimeout(otInstance *aInstance);
137 
147 OTAPI void OTCALL otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeout);
148 
158 OTAPI const uint8_t *OTCALL otThreadGetExtendedPanId(otInstance *aInstance);
159 
175 OTAPI otError OTCALL otThreadSetExtendedPanId(otInstance *aInstance, const uint8_t *aExtendedPanId);
176 
189 
200 
212 
223 
241 
251 
260 OTAPI const uint8_t *OTCALL otThreadGetMeshLocalPrefix(otInstance *aInstance);
261 
276 OTAPI otError OTCALL otThreadSetMeshLocalPrefix(otInstance *aInstance, const uint8_t *aMeshLocalPrefix);
277 
288 
298 OTAPI const char *OTCALL otThreadGetNetworkName(otInstance *aInstance);
299 
315 OTAPI otError OTCALL otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName);
316 
327 
336 OTAPI void OTCALL otThreadSetKeySequenceCounter(otInstance *aInstance, uint32_t aKeySequenceCounter);
337 
348 
357 OTAPI void OTCALL otThreadSetKeySwitchGuardTime(otInstance *aInstance, uint32_t aKeySwitchGuardTime);
358 
368 
378 
394  otNeighborInfo *aInfo);
395 
408 
421 
430 
438 OTAPI uint8_t OTCALL otThreadGetLeaderWeight(otInstance *aInstance);
439 
447 OTAPI uint32_t OTCALL otThreadGetPartitionId(otInstance *aInstance);
448 
456 OTAPI uint16_t OTCALL otThreadGetRloc16(otInstance *aInstance);
457 
466 
474 OTAPI otError OTCALL otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi);
475 
486 OTAPI otError OTCALL otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi);
487 
497 typedef void (*otReceiveDiagnosticGetCallback)(otMessage *aMessage, const otMessageInfo *aMessageInfo,
498  void *aContext);
499 
510  void *aCallbackContext);
511 
521 OTAPI otError OTCALL otThreadSendDiagnosticGet(otInstance *aInstance, const otIp6Address *aDestination,
522  const uint8_t aTlvTypes[], uint8_t aCount);
523 
534  const uint8_t aTlvTypes[], uint8_t aCount);
535 
545 
551 #ifdef __cplusplus
552 } // extern "C"
553 #endif
554 
555 #endif // OPENTHREAD_THREAD_H_
This structure represents an IPv6 address.
Definition: types.h:417
This type represents all the static / global variables used by OpenThread allocated in one place...
Definition: openthread-instance.h:59
This structure represents the IP level counters.
Definition: types.h:1050
otDeviceRole
Represents a Thread device role.
Definition: types.h:910
This file defines the types and structures used in the OpenThread library API.
OTAPI otError OTCALL otThreadBecomeChild(otInstance *aInstance)
Attempt to reattach as a child.
Definition: thread_api.cpp:250
void(* otReceiveDiagnosticGetCallback)(otMessage *aMessage, const otMessageInfo *aMessageInfo, void *aContext)
This function pointer is called when Network Diagnostic Get response is received. ...
Definition: thread.h:497
OTAPI void OTCALL otThreadSetChildTimeout(otInstance *aInstance, uint32_t aTimeout)
Set the Thread Child Timeout used when operating in the Child role.
Definition: thread_api.cpp:52
OTAPI otError OTCALL otThreadSetMeshLocalPrefix(otInstance *aInstance, const uint8_t *aMeshLocalPrefix)
This function sets the Mesh Local Prefix.
Definition: thread_api.cpp:185
This structure holds diagnostic information for a Thread Router.
Definition: types.h:970
OTAPI otError OTCALL otThreadGetParentInfo(otInstance *aInstance, otRouterInfo *aParentInfo)
The function retrieves diagnostic information for a Thread Router as parent.
Definition: thread_api.cpp:304
OTAPI bool OTCALL otThreadGetAutoStart(otInstance *aInstance)
This function queries if the Thread stack is configured to automatically start on reinitialization...
Definition: thread_api.cpp:445
This structure represents an MLE Link Mode configuration.
Definition: types.h:646
OTAPI void OTCALL otThreadSetKeySequenceCounter(otInstance *aInstance, uint32_t aKeySequenceCounter)
Set the thrKeySequenceCounter.
Definition: thread_api.cpp:230
OTAPI otError OTCALL otThreadSetExtendedPanId(otInstance *aInstance, const uint8_t *aExtendedPanId)
Set the IEEE 802.15.4 Extended PAN ID.
Definition: thread_api.cpp:62
This file defines the top-level OpenThread APIs related to message buffer and queues.
void otThreadSetReceiveDiagnosticGetCallback(otInstance *aInstance, otReceiveDiagnosticGetCallback aCallback, void *aCallbackContext)
This function registers a callback to provide received raw Network Diagnostic Get response payload...
OTAPI otError OTCALL otThreadSetNetworkName(otInstance *aInstance, const char *aNetworkName)
Set the Thread Network Name.
Definition: thread_api.cpp:210
This type points to an OpenThread message buffer.
Definition: types.h:479
OTAPI uint8_t OTCALL otThreadGetLeaderWeight(otInstance *aInstance)
Get the Leader&#39;s Weight.
Definition: thread_api.cpp:289
OTAPI otError OTCALL otThreadSendDiagnosticGet(otInstance *aInstance, const otIp6Address *aDestination, const uint8_t aTlvTypes[], uint8_t aCount)
Send a Network Diagnostic Get request.
OTAPI otError OTCALL otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig)
Set the MLE Link Mode configuration.
Definition: thread_api.cpp:127
OTAPI uint32_t OTCALL otThreadGetKeySequenceCounter(otInstance *aInstance)
Get the thrKeySequenceCounter.
Definition: thread_api.cpp:225
OTAPI uint16_t OTCALL otThreadGetRloc16(otInstance *aInstance)
Get the RLOC16.
Definition: thread_api.cpp:299
OTAPI otError OTCALL otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey)
Set the thrMasterKey.
Definition: thread_api.cpp:159
This structure holds diagnostic information for a neighboring Thread node.
Definition: types.h:923
OTAPI otError OTCALL otThreadGetLeaderRloc(otInstance *aInstance, otIp6Address *aLeaderRloc)
This function returns a pointer to the Leader&#39;s RLOC.
Definition: thread_api.cpp:85
OTAPI bool OTCALL otThreadIsSingleton(otInstance *aInstance)
This function indicates whether a node is the only router on the network.
Definition: thread_api.cpp:476
OTAPI uint32_t OTCALL otThreadGetPartitionId(otInstance *aInstance)
Get the Partition ID.
Definition: thread_api.cpp:294
This structure represents the Thread Leader Data.
Definition: types.h:999
OTAPI const otIpCounters *OTCALL otThreadGetIp6Counters(otInstance *aInstance)
Get the IPv6 counters.
Definition: thread_api.cpp:493
OTAPI otDeviceRole OTCALL otThreadGetDeviceRole(otInstance *aInstance)
Get the device role.
Definition: thread_api.cpp:267
OTAPI otError OTCALL otThreadGetParentAverageRssi(otInstance *aInstance, int8_t *aParentRssi)
The function retrieves the average RSSI for the Thread Parent.
Definition: thread_api.cpp:329
OTAPI uint8_t OTCALL otThreadGetLeaderRouterId(otInstance *aInstance)
Get the Leader&#39;s Router ID.
Definition: thread_api.cpp:284
OTAPI otLinkModeConfig OTCALL otThreadGetLinkMode(otInstance *aInstance)
Get the MLE Link Mode configuration.
Definition: thread_api.cpp:97
OTAPI otError OTCALL otThreadSetAutoStart(otInstance *aInstance, bool aStartAutomatically)
This function configures the Thread stack to automatically start on reinitialization.
Definition: thread_api.cpp:464
OTAPI otError OTCALL otThreadGetLeaderData(otInstance *aInstance, otLeaderData *aLeaderData)
This function get the Thread Leader Data.
Definition: thread_api.cpp:272
OTAPI uint32_t OTCALL otThreadGetKeySwitchGuardTime(otInstance *aInstance)
Get the thrKeySwitchGuardTime.
Definition: thread_api.cpp:235
This structure represents the local and peer IPv6 socket addresses.
Definition: types.h:436
OTAPI otError OTCALL otThreadSendDiagnosticReset(otInstance *aInstance, const otIp6Address *aDestination, const uint8_t aTlvTypes[], uint8_t aCount)
Send a Network Diagnostic Reset request.
OTAPI otError OTCALL otThreadSetEnabled(otInstance *aInstance, bool aEnabled)
This function starts Thread protocol operation.
Definition: thread_api.cpp:423
OTAPI const otIp6Address *OTCALL otThreadGetMeshLocalEid(otInstance *aInstance)
This function returns a pointer to the Mesh Local EID.
Definition: thread_api.cpp:175
OTAPI otError OTCALL otThreadGetParentLastRssi(otInstance *aInstance, int8_t *aLastRssi)
The function retrieves the RSSI of the last packet from the Thread Parent.
Definition: thread_api.cpp:345
OTAPI otError OTCALL otThreadBecomeDetached(otInstance *aInstance)
Detach from the Thread network.
Definition: thread_api.cpp:245
int16_t otNeighborInfoIterator
Used to iterate through neighbor table.
Definition: types.h:942
#define OTCALL
Compiler-specific modifier to export functions in a DLL.
Definition: toolchain.h:217
OTAPI const uint8_t *OTCALL otThreadGetMeshLocalPrefix(otInstance *aInstance)
This function returns a pointer to the Mesh Local Prefix.
Definition: thread_api.cpp:180
#define OTAPI
Compiler-specific modifier for public API declarations.
Definition: toolchain.h:216
OTAPI otError OTCALL otThreadGetNextNeighborInfo(otInstance *aInstance, otNeighborInfoIterator *aIterator, otNeighborInfo *aInfo)
This function gets the next neighbor information.
Definition: thread_api.cpp:255
OTAPI const otMasterKey *OTCALL otThreadGetMasterKey(otInstance *aInstance)
Get the thrMasterKey.
Definition: thread_api.cpp:154
OTAPI bool OTCALL otThreadIsDiscoverInProgress(otInstance *aInstance)
This function determines if an MLE Thread Discovery is currently in progress.
Definition: thread_api.cpp:488
OTAPI uint32_t OTCALL otThreadGetChildTimeout(otInstance *aInstance)
Get the Thread Child Timeout used when operating in the Child role.
Definition: thread_api.cpp:47
OTAPI const char *OTCALL otThreadGetNetworkName(otInstance *aInstance)
Get the Thread Network Name.
Definition: thread_api.cpp:205
otError
This enumeration represents error codes used throughout OpenThread.
Definition: types.h:107
OTAPI const uint8_t *OTCALL otThreadGetExtendedPanId(otInstance *aInstance)
Get the IEEE 802.15.4 Extended PAN ID.
Definition: thread_api.cpp:57
OTAPI void OTCALL otThreadSetKeySwitchGuardTime(otInstance *aInstance, uint32_t aKeySwitchGuardTime)
Set the thrKeySwitchGuardTime.
Definition: thread_api.cpp:240
This structure represents a Thread Master Key.
Definition: types.h:297
OTAPI otError OTCALL otThreadDiscover(otInstance *aInstance, uint32_t aScanChannels, uint16_t aPanId, bool aJoiner, bool aEnableEui64Filtering, otHandleActiveScanResult aCallback, void *aCallbackContext)
This function starts a Thread Discovery scan.
Definition: thread_api.cpp:481
const otIp6Address * otThreadGetLinkLocalIp6Address(otInstance *aInstance)
This function returns the Thread link-local IPv6 address.
Definition: thread_api.cpp:200