-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Persist and reload message counters on the controller (#7106)
* Persist and reload message counters on the controller * Refactor CHIPDevice storage into an API on CHIPDevice * Rename PersistentStorageUtils -> PersistentStorageMacros * Fix the cluster tests * Fix ordering of initializers * Update comment to describe why counters are being stored * Moved comments around * Fix typo * Address review comments * remove unnecessary semicolon Co-authored-by: Boris Zbarsky <[email protected]>
- Loading branch information
Showing
10 changed files
with
190 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* | ||
* Copyright (c) 2021 Project CHIP Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* @file | ||
* This file defines and implements some utlities for generating persistent storage keys | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <support/CodeUtils.h> | ||
|
||
namespace chip { | ||
|
||
constexpr const char kPairedDeviceListKeyPrefix[] = "ListPairedDevices"; | ||
constexpr const char kPairedDeviceKeyPrefix[] = "PairedDevice"; | ||
constexpr const char kNextAvailableKeyID[] = "StartKeyID"; | ||
|
||
// This macro generates a key for storage using a node ID and a key prefix, and performs the given action | ||
// on that key. | ||
#define PERSISTENT_KEY_OP(node, keyPrefix, key, action) \ | ||
do \ | ||
{ \ | ||
constexpr size_t len = std::extent<decltype(keyPrefix)>::value; \ | ||
nlSTATIC_ASSERT_PRINT(len > 0, "keyPrefix length must be known at compile time"); \ | ||
/* 2 * sizeof(NodeId) to accomodate 2 character for each byte in Node Id */ \ | ||
char key[len + 2 * sizeof(NodeId) + 1]; \ | ||
nlSTATIC_ASSERT_PRINT(sizeof(node) <= sizeof(uint64_t), "Node ID size is greater than expected"); \ | ||
snprintf(key, sizeof(key), "%s%" PRIx64, keyPrefix, node); \ | ||
action; \ | ||
} while (0) | ||
|
||
} // namespace chip |
Oops, something went wrong.