diff --git a/examples/apps/cli/README.md b/examples/apps/cli/README.md index 47de7df59..8ba05bc2a 100644 --- a/examples/apps/cli/README.md +++ b/examples/apps/cli/README.md @@ -82,13 +82,11 @@ $ cd /output//bin $ ./ot-cli-ftd 2 ``` -Configure Thread Master Key and PAN ID from Node 1's Active Operational Dataset: +Configure Thread Master Key from Node 1's Active Operational Dataset: ```bash > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done -> dataset panid 0x8f28 -Done > dataset commit active Done ``` diff --git a/examples/platforms/efr32mg12/README.md b/examples/platforms/efr32mg12/README.md index 8042119ec..f8f659e6c 100644 --- a/examples/platforms/efr32mg12/README.md +++ b/examples/platforms/efr32mg12/README.md @@ -210,8 +210,6 @@ Click the Flash button located under the Browse... button. ```bash > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done - > dataset panid 0x8f28 - Done > dataset commit active Done > routerselectionjitter 1 diff --git a/examples/platforms/kw41z/README.md b/examples/platforms/kw41z/README.md index fec9d88e1..78f71f2b6 100644 --- a/examples/platforms/kw41z/README.md +++ b/examples/platforms/kw41z/README.md @@ -97,8 +97,6 @@ The [NXP(Freescale) Test Tool][test-tool] provides a convenient method for flash ```bash > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done - > dataset panid 0x8f28 - Done > dataset commit active Done > ifconfig up diff --git a/examples/platforms/nrf52811/README.md b/examples/platforms/nrf52811/README.md index 578f6ac42..2b6aa8f24 100644 --- a/examples/platforms/nrf52811/README.md +++ b/examples/platforms/nrf52811/README.md @@ -205,8 +205,6 @@ To test the example: ```bash > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done - > dataset panid 0x8f28 - Done > dataset commit active Done > ifconfig up diff --git a/examples/platforms/nrf52840/README.md b/examples/platforms/nrf52840/README.md index 8ba9f0280..c9c541be8 100644 --- a/examples/platforms/nrf52840/README.md +++ b/examples/platforms/nrf52840/README.md @@ -235,8 +235,6 @@ To test the example: ```bash > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done - > dataset panid 0x8f28 - Done > dataset commit active Done > ifconfig up diff --git a/examples/platforms/samr21/README.md b/examples/platforms/samr21/README.md index 9af469e22..a7635db27 100644 --- a/examples/platforms/samr21/README.md +++ b/examples/platforms/samr21/README.md @@ -158,8 +158,6 @@ $ (gdb) c ```bash > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done - > dataset panid 0x8f28 - Done > dataset commit active Done > routerselectionjitter 1 diff --git a/include/openthread/dataset.h b/include/openthread/dataset.h index c78133656..3ab8fa026 100644 --- a/include/openthread/dataset.h +++ b/include/openthread/dataset.h @@ -309,8 +309,8 @@ otError otDatasetGetActive(otInstance *aInstance, otOperationalDataset *aDataset * If the dataset does not include an Active Timestamp, the dataset is only partially complete. * * If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to - * an existing Thread network using any existing information in the dataset. The minimum set of information needed to - * attach is the PAN ID and Thread Master Key. + * an existing Thread network using any existing information in the dataset. Only the Thread Master Key is needed to + * attach to a network. * * If channel is not included in the dataset, the device will send MLE Announce messages across different channels to * find neighbors on other channels. diff --git a/src/cli/README_DATASET.md b/src/cli/README_DATASET.md index 53e800cf2..a72dd91df 100644 --- a/src/cli/README_DATASET.md +++ b/src/cli/README_DATASET.md @@ -66,10 +66,7 @@ The Pending Operational Dataset is used to communicate changes to the Active Ope ### Attach to Existing Network -The minimum set of parameters required for a device to attach a Thread network are: - -* Master Key -* PAN ID +Only the Master Key is required for a device to attach to a Thread network. While not required, specifying the channel avoids the need to search across multiple channels, improving both latency and efficiency of the attach process. @@ -78,8 +75,6 @@ After the device successfully attaches to a Thread network, the device will retr 1. Create a partial Active Operational Dataset. ```bash - > dataset panid 0x8f28 - Done > dataset masterkey dfd34f0f05cad978ec4e32b0413038ff Done > dataset commit active diff --git a/src/core/api/thread_api.cpp b/src/core/api/thread_api.cpp index ac8f8ade9..92bc5c578 100644 --- a/src/core/api/thread_api.cpp +++ b/src/core/api/thread_api.cpp @@ -405,7 +405,6 @@ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled) if (aEnabled) { - VerifyOrExit(instance.Get().GetPanId() != Mac::kPanIdBroadcast, error = OT_ERROR_INVALID_STATE); error = instance.Get().Start(/* aAnnounceAttach */ false); } else @@ -413,7 +412,6 @@ otError otThreadSetEnabled(otInstance *aInstance, bool aEnabled) instance.Get().Stop(true); } -exit: return error; } diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index ee6aafa85..4ac230491 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -243,6 +243,20 @@ otError Mle::Start(bool aAnnounceAttach) VerifyOrExit(!otPlatRadioGetPromiscuous(&GetInstance()), error = OT_ERROR_INVALID_STATE); VerifyOrExit(Get().IsUp(), error = OT_ERROR_INVALID_STATE); + if (Get().GetPanId() == Mac::kPanIdBroadcast) + { + // if PAN ID is not configured, pick a random one to start + + uint16_t panid; + + do + { + panid = Random::NonCrypto::GetUint16(); + } while (panid == Mac::kPanIdBroadcast); + + Get().SetPanId(panid); + } + SetStateDetached(); ApplyMeshLocalPrefix();