#include <src/utils/thread_helper.hpp>
|
using | DeviceRoleHandler = std::function< void(otDeviceRole)> |
|
using | ScanHandler = std::function< void(otError, const std::vector< otActiveScanResult > &)> |
|
using | EnergyScanHandler = std::function< void(otError, const std::vector< otEnergyScanResult > &)> |
|
using | ResultHandler = std::function< void(otError)> |
|
using | AttachHandler = std::function< void(otError, int64_t)> |
|
using | UpdateMeshCopTxtHandler = std::function< void(std::map< std::string, std::vector< uint8_t > >)> |
|
using | DatasetChangeHandler = std::function< void(const otOperationalDatasetTlvs &)> |
|
|
| ThreadHelper (otInstance *aInstance, otbr::Ncp::ControllerOpenThread *aNcp) |
|
void | AddDeviceRoleHandler (DeviceRoleHandler aHandler) |
|
void | AddActiveDatasetChangeHandler (DatasetChangeHandler aHandler) |
|
otError | PermitUnsecureJoin (uint16_t aPort, uint32_t aSeconds) |
|
void | Scan (ScanHandler aHandler) |
|
void | EnergyScan (uint32_t aScanDuration, EnergyScanHandler aHandler) |
|
void | Attach (const std::string &aNetworkName, uint16_t aPanId, uint64_t aExtPanId, const std::vector< uint8_t > &aNetworkKey, const std::vector< uint8_t > &aPSKc, uint32_t aChannelMask, AttachHandler aHandler) |
|
otError | Detach (void) |
|
void | Attach (AttachHandler aHandler) |
|
void | AttachAllNodesTo (const std::vector< uint8_t > &aDatasetTlvs, AttachHandler aHandler) |
|
otError | Reset (void) |
|
void | JoinerStart (const std::string &aPskd, const std::string &aProvisioningUrl, const std::string &aVendorName, const std::string &aVendorModel, const std::string &aVendorSwVersion, const std::string &aVendorData, ResultHandler aHandler) |
|
otError | TryResumeNetwork (void) |
|
otInstance * | GetInstance (void) |
|
void | StateChangedCallback (otChangedFlags aFlags) |
|
void | DetachGracefully (ResultHandler aHandler) |
|
This class implements Thread helper.
◆ ThreadHelper()
The constructor of a Thread helper.
- Parameters
-
[in] | aInstance | The Thread instance. |
[in] | aNcp | The ncp controller. |
◆ AddActiveDatasetChangeHandler()
void otbr::agent::ThreadHelper::AddActiveDatasetChangeHandler |
( |
DatasetChangeHandler |
aHandler | ) |
|
This method adds a callback for active dataset change.
- Parameters
-
[in] | aHandler | The active dataset change handler. |
◆ AddDeviceRoleHandler()
void otbr::agent::ThreadHelper::AddDeviceRoleHandler |
( |
DeviceRoleHandler |
aHandler | ) |
|
This method adds a callback for device role change.
- Parameters
-
[in] | aHandler | The device role handler. |
◆ Attach() [1/2]
void otbr::agent::ThreadHelper::Attach |
( |
AttachHandler |
aHandler | ) |
|
This method attaches the device to the Thread network.
- Note
- The joiner start and the attach proccesses are exclusive, and the network parameter will be set through the active dataset.
- Parameters
-
[in] | aHandler | The attach result handler. |
◆ Attach() [2/2]
void otbr::agent::ThreadHelper::Attach |
( |
const std::string & |
aNetworkName, |
|
|
uint16_t |
aPanId, |
|
|
uint64_t |
aExtPanId, |
|
|
const std::vector< uint8_t > & |
aNetworkKey, |
|
|
const std::vector< uint8_t > & |
aPSKc, |
|
|
uint32_t |
aChannelMask, |
|
|
AttachHandler |
aHandler |
|
) |
| |
This method attaches the device to the Thread network.
- Note
- The joiner start and the attach proccesses are exclusive
- Parameters
-
[in] | aNetworkName | The network name. |
[in] | aPanId | The pan id, UINT16_MAX for random. |
[in] | aExtPanId | The extended pan id, UINT64_MAX for random. |
[in] | aNetworkKey | The network key, empty for random. |
[in] | aPSKc | The pre-shared commissioner key, empty for random. |
[in] | aChannelMask | A bitmask for valid channels, will random select one. |
[in] | aHandler | The attach result handler. |
◆ AttachAllNodesTo()
void otbr::agent::ThreadHelper::AttachAllNodesTo |
( |
const std::vector< uint8_t > & |
aDatasetTlvs, |
|
|
AttachHandler |
aHandler |
|
) |
| |
This method makes all nodes in the current network attach to the network specified by the dataset TLVs.
- Parameters
-
[in] | aDatasetTlvs | The dataset TLVs. |
[in] | aHandler | The result handler. |
◆ Detach()
otError otbr::agent::ThreadHelper::Detach |
( |
void |
| ) |
|
This method detaches the device from the Thread network.
- Returns
- The error value of underlying OpenThread API calls.
◆ EnergyScan()
void otbr::agent::ThreadHelper::EnergyScan |
( |
uint32_t |
aScanDuration, |
|
|
EnergyScanHandler |
aHandler |
|
) |
| |
This method performs an IEEE 802.15.4 Energy Scan.
- Parameters
-
[in] | aScanDuration | The duration for the scan, in milliseconds. |
[in] | aHandler | The scan result handler. |
◆ GetInstance()
otInstance* otbr::agent::ThreadHelper::GetInstance |
( |
void |
| ) |
|
|
inline |
This method returns the underlying OpenThread instance.
- Returns
- The underlying instance.
◆ JoinerStart()
void otbr::agent::ThreadHelper::JoinerStart |
( |
const std::string & |
aPskd, |
|
|
const std::string & |
aProvisioningUrl, |
|
|
const std::string & |
aVendorName, |
|
|
const std::string & |
aVendorModel, |
|
|
const std::string & |
aVendorSwVersion, |
|
|
const std::string & |
aVendorData, |
|
|
ResultHandler |
aHandler |
|
) |
| |
This method triggers a thread join process.
- Note
- The joiner start and the attach proccesses are exclusive
- Parameters
-
[in] | aPskd | The pre-shared key for device. |
[in] | aProvisioningUrl | The provision url. |
[in] | aVendorName | The vendor name. |
[in] | aVendorModel | The vendor model. |
[in] | aVendorSwVersion | The vendor software version. |
[in] | aVendorData | The vendor custom data. |
[in] | aHandler | The join result handler. |
◆ LogOpenThreadResult()
void otbr::agent::ThreadHelper::LogOpenThreadResult |
( |
const char * |
aAction, |
|
|
otError |
aError |
|
) |
| |
|
static |
This method logs OpenThread action result.
- Parameters
-
[in] | aAction | The action OpenThread performs. |
[in] | aError | The action result. |
◆ PermitUnsecureJoin()
otError otbr::agent::ThreadHelper::PermitUnsecureJoin |
( |
uint16_t |
aPort, |
|
|
uint32_t |
aSeconds |
|
) |
| |
This method permits unsecure join on port.
- Parameters
-
[in] | aPort | The port number. |
[in] | aSeconds | The timeout to close the port, 0 for never close. |
- Returns
- The error value of underlying OpenThread api calls.
◆ Reset()
otError otbr::agent::ThreadHelper::Reset |
( |
void |
| ) |
|
This method resets the OpenThread stack.
- Returns
- The error value of underlying OpenThread api calls.
◆ Scan()
void otbr::agent::ThreadHelper::Scan |
( |
ScanHandler |
aHandler | ) |
|
This method performs a Thread network scan.
- Parameters
-
[in] | aHandler | The scan result handler. |
◆ StateChangedCallback()
void otbr::agent::ThreadHelper::StateChangedCallback |
( |
otChangedFlags |
aFlags | ) |
|
This method handles OpenThread state changed notification.
- Parameters
-
[in] | aFlags | A bit-field indicating specific state that has changed. See OT_CHANGED_* definitions. |
◆ TryResumeNetwork()
otError otbr::agent::ThreadHelper::TryResumeNetwork |
( |
void |
| ) |
|
This method tries to restore the network after reboot
- Returns
- The error value of underlying OpenThread api calls.
The documentation for this class was generated from the following files: