Skip to content

Commit

Permalink
[thread] Allow to specify dataset timestamp (#4410)
Browse files Browse the repository at this point in the history
* [thread] Allow to specify dataset timestamp

* Restyled by clang-format

Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
Damian-Nordic and restyled-commits authored Jan 19, 2021
1 parent aca6540 commit b9e09f0
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 14 deletions.
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

0 comments on commit b9e09f0

Please sign in to comment.