mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-26 20:29:29 +01:00
feat(openthread): add mesh local prefix configuration
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
#include "openthread/tasklet.h"
|
||||
#include "openthread/thread.h"
|
||||
|
||||
#if CONFIG_OPENTHREAD_FTD
|
||||
#include "openthread/dataset_ftd.h"
|
||||
#endif
|
||||
|
||||
static int hex_digit_to_int(char hex)
|
||||
{
|
||||
if ('A' <= hex && hex <= 'F') {
|
||||
@@ -87,13 +91,14 @@ esp_err_t esp_openthread_auto_start(otOperationalDatasetTlvs *datasetTlvs)
|
||||
if (datasetTlvs) {
|
||||
ESP_RETURN_ON_FALSE(otDatasetSetActiveTlvs(instance, datasetTlvs) == OT_ERROR_NONE, ESP_FAIL, OT_PLAT_LOG_TAG,
|
||||
"Failed to set OpenThread active dataset");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
otOperationalDataset dataset;
|
||||
size_t len = 0;
|
||||
|
||||
#if CONFIG_OPENTHREAD_FTD
|
||||
otDatasetCreateNewNetwork(instance, &dataset);
|
||||
#else
|
||||
memset(&dataset, 0, sizeof(otOperationalDataset));
|
||||
|
||||
#endif
|
||||
// Active timestamp
|
||||
dataset.mActiveTimestamp.mSeconds = 1;
|
||||
dataset.mActiveTimestamp.mTicks = 0;
|
||||
@@ -117,6 +122,16 @@ esp_err_t esp_openthread_auto_start(otOperationalDatasetTlvs *datasetTlvs)
|
||||
"Cannot convert OpenThread extended pan id");
|
||||
dataset.mComponents.mIsExtendedPanIdPresent = true;
|
||||
|
||||
// Mesh Local Prefix
|
||||
otIp6Prefix prefix;
|
||||
memset(&prefix, 0, sizeof(otIp6Prefix));
|
||||
if (otIp6PrefixFromString(CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX, &prefix) == OT_ERROR_NONE) {
|
||||
memcpy(dataset.mMeshLocalPrefix.m8, prefix.mPrefix.mFields.m8, sizeof(dataset.mMeshLocalPrefix.m8));
|
||||
dataset.mComponents.mIsMeshLocalPrefixPresent = true;
|
||||
} else {
|
||||
ESP_LOGE("Falied to parse mesh local prefix", CONFIG_OPENTHREAD_MESH_LOCAL_PREFIX);
|
||||
}
|
||||
|
||||
// Network Key
|
||||
len = hex_string_to_binary(CONFIG_OPENTHREAD_NETWORK_MASTERKEY, dataset.mNetworkKey.m8,
|
||||
sizeof(dataset.mNetworkKey.m8));
|
||||
|
||||
Reference in New Issue
Block a user