Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[thread] Allow to specify dataset timestamp #4410

Merged
merged 2 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/lighting-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <platform/EFR32/ThreadStackManagerImpl.h>
#include <platform/OpenThread/OpenThreadUtils.h>
#include <platform/ThreadStackManager.h>
#include <platform/internal/DeviceNetworkInfo.h>
#endif

#define FACTORY_RESET_TRIGGER_TIMEOUT 3000
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/efr32/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <platform/EFR32/ThreadStackManagerImpl.h>
#include <platform/OpenThread/OpenThreadUtils.h>
#include <platform/ThreadStackManager.h>
#include <platform/internal/DeviceNetworkInfo.h>
#endif

#define FACTORY_RESET_TRIGGER_TIMEOUT 3000
Expand Down
1 change: 0 additions & 1 deletion examples/lock-app/qpg6100/src/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ using namespace chip::DeviceLayer;
#if CHIP_ENABLE_OPENTHREAD
#include <platform/OpenThread/OpenThreadUtils.h>
#include <platform/ThreadStackManager.h>
#include <platform/internal/DeviceNetworkInfo.h>
#include <platform/qpg6100/ThreadStackManagerImpl.h>
#define JOINER_START_TRIGGER_TIMEOUT 1500
#endif
Expand Down
23 changes: 12 additions & 11 deletions src/include/platform/internal/DeviceNetworkInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ enum
/**
* WiFi Security Modes.
*/
enum WiFiAuthSecurityType
enum WiFiAuthSecurityType : int8_t
{
kWiFiSecurityType_NotSpecified = -1,

Expand All @@ -77,6 +77,14 @@ class DeviceNetworkInfo
public:
uint32_t NetworkId; /**< The network id assigned to the network by the device. */

struct
{
bool NetworkId : 1; /**< True if the NetworkId field is present. */
bool ThreadExtendedPANId : 1; /**< True if the ThreadExtendedPANId field is present. */
bool ThreadMeshPrefix : 1; /**< True if the ThreadMeshPrefix field is present. */
bool ThreadPSKc : 1; /**< True if the ThreadPSKc field is present. */
} FieldPresent;

// ---- WiFi-specific Fields ----
char WiFiSSID[kMaxWiFiSSIDLength + 1]; /**< The WiFi SSID as a NULL-terminated string. */
uint8_t WiFiKey[kMaxWiFiKeyLength]; /**< The WiFi key (NOT NULL-terminated). */
Expand All @@ -94,16 +102,9 @@ class DeviceNetworkInfo
/**< The Thread master key (NOT NULL-terminated). */
uint8_t ThreadPSKc[kThreadPSKcLength];
/**< The Thread pre-shared commissioner key (NOT NULL-terminated). */
uint16_t ThreadPANId; /**< The 16-bit Thread PAN ID, or kThreadPANId_NotSpecified */
uint8_t ThreadChannel; /**< The Thread channel (currently [11..26]), or kThreadChannel_NotSpecified */

struct
{
bool NetworkId : 1; /**< True if the NetworkId field is present. */
bool ThreadExtendedPANId : 1; /**< True if the ThreadExtendedPANId field is present. */
bool ThreadMeshPrefix : 1; /**< True if the ThreadMeshPrefix field is present. */
bool ThreadPSKc : 1; /**< True if the ThreadPSKc field is present. */
} FieldPresent;
uint16_t ThreadPANId; /**< The 16-bit Thread PAN ID, or kThreadPANId_NotSpecified */
uint8_t ThreadChannel; /**< The Thread channel (currently [11..26]), or kThreadChannel_NotSpecified */
uint64_t ThreadDatasetTimestamp; /**< Thread active dataset timestamp */
};

} // namespace Internal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread<ImplClass>::_SetThreadProvis
newDataset.mComponents.mIsChannelPresent = true;
}

if (netInfo.ThreadDatasetTimestamp != 0)
{
newDataset.mActiveTimestamp = netInfo.ThreadDatasetTimestamp;
newDataset.mComponents.mIsActiveTimestampPresent = true;
}

// Set the dataset as the active dataset for the node.
Impl()->LockThreadStack();
otErr = otDatasetSetActive(mOTInst, &newDataset);
Expand Down