nl::Weave::DeviceLayer::Internal::NRF5Config

#include <src/adaptations/device-layer/include/Weave/DeviceLayer/nRF5/nRF5Config.h>

Provides functions and definitions for accessing persisted device configuration on platforms based on the Nordic nRF5 SDK.

Summary

This implementation uses the Nordic Flash Data Storage (FDS) library as the underlying storage layer.

NOTE: This class is designed to be mixed-in to the concrete subclass of the GenericConfigurationManagerImpl<> template. When used this way, the class naturally provides implementations for the delegated members referenced by the template class (e.g. the ReadConfigValue() method).

Inheritance

Direct Known Subclasses:
  nl::Weave::DeviceLayer::ConfigurationManagerImpl
  nl::Weave::DeviceLayer::Internal::GroupKeyStoreImpl

Public types

Key using
uint32_t

Protected types

ForEachRecordFunct using
std::function< WEAVE_ERROR(const fds_flash_record_t &rec, bool &deleteRec)>

Public static attributes

kConfigKey_DeviceCert = NRF5ConfigKey(kFileId_WeaveFactory, 0x0003)
constexpr Key
kConfigKey_DeviceId = NRF5ConfigKey(kFileId_WeaveFactory, 0x0002)
constexpr Key
kConfigKey_DevicePrivateKey = NRF5ConfigKey(kFileId_WeaveFactory, 0x0004)
constexpr Key
kConfigKey_FabricId = NRF5ConfigKey(kFileId_WeaveConfig, 0x0007)
constexpr Key
kConfigKey_FabricSecret = NRF5ConfigKey(kFileId_WeaveConfig, 0x000B)
constexpr Key
kConfigKey_FailSafeArmed = NRF5ConfigKey(kFileId_WeaveConfig, 0x000D)
constexpr Key
kConfigKey_GroupKey = NRF5ConfigKey(kFileId_WeaveConfig, 0x000E)
constexpr Key
kConfigKey_LastUsedEpochKeyId = NRF5ConfigKey(kFileId_WeaveConfig, 0x000C)
constexpr Key
kConfigKey_ManufacturingDate = NRF5ConfigKey(kFileId_WeaveFactory, 0x0005)
constexpr Key
kConfigKey_PairedAccountId = NRF5ConfigKey(kFileId_WeaveConfig, 0x0009)
constexpr Key
kConfigKey_PairingCode = NRF5ConfigKey(kFileId_WeaveFactory, 0x0006)
constexpr Key
kConfigKey_ProductRevision = NRF5ConfigKey(kFileId_WeaveFactory, 0x000F)
constexpr Key
kConfigKey_SerialNum = NRF5ConfigKey(kFileId_WeaveFactory, 0x0001)
constexpr Key
kConfigKey_ServiceConfig = NRF5ConfigKey(kFileId_WeaveConfig, 0x0008)
constexpr Key
kConfigKey_ServiceId = NRF5ConfigKey(kFileId_WeaveConfig, 0x000A)
constexpr Key
kFDSFileIdMax = 0xBFFF
constexpr uint16_t
Maximum value that can be used for a FDS file id (per Nordic SDK)
kFDSFileIdMin = 0x0000
constexpr uint16_t
Minimum value that can be used for a FDS file id (per Nordic SDK)
kFDSRecordKeyMax = 0xBFFF
constexpr uint16_t
Maximum value that can be used for a FDS record key (per Nordic SDK)
kFDSRecordKeyMin = 0x0001
constexpr uint16_t
Minimum value that can be used for a FDS record key (per Nordic SDK)
kFileId_WeaveConfig = 0x235B
constexpr uint16_t
FDS file containing dynamic config values set at runtime.
kFileId_WeaveCounter = 0x235C
constexpr uint16_t
FDS file containing dynamic counter values set at runtime.
kFileId_WeaveFactory = 0x235A
constexpr uint16_t
FDS file containing persistent config values set at manufacturing time.
kPersistedCounterRecordKeyBase = kFDSRecordKeyMin
constexpr uint16_t
Base record key for records containing Weave persisted counter values.
kPersistedCounterRecordKeyMax = kFDSRecordKeyMax
constexpr uint16_t
Max record key for records containing Weave persisted counter values.

Protected static attributes

kFDSWordSize = 4
constexpr uint16_t
sActiveAsyncOp
FDSAsyncOp *volatile
sAsyncOpCompletionSem
SemaphoreHandle_t

Public static functions

ClearConfigValue(Key key)
ConfigValueExists(Key key)
bool
FactoryResetConfig(void)
Init(void)
ReadConfigValue(Key key, bool & val)
ReadConfigValue(Key key, uint32_t & val)
ReadConfigValue(Key key, uint64_t & val)
ReadConfigValueBin(Key key, uint8_t *buf, size_t bufSize, size_t & outLen)
ReadConfigValueStr(Key key, char *buf, size_t bufSize, size_t & outLen)
RunConfigUnitTest(void)
void
WriteConfigValue(Key key, bool val)
WriteConfigValue(Key key, uint32_t val)
WriteConfigValue(Key key, uint64_t val)
WriteConfigValueBin(Key key, const uint8_t *data, size_t dataLen)
WriteConfigValueStr(Key key, const char *str)
WriteConfigValueStr(Key key, const char *str, size_t strLen)

Protected static functions

DoAsyncFDSOp(FDSAsyncOp & asyncOp)
FDSWords(size_t s)
constexpr uint16_t
Number of FDS words needed to hold a given size object.
ForEachRecord(uint16_t fileId, uint16_t recordKey, ForEachRecordFunct funct)
GetFileId(uint32_t key)
constexpr uint16_t
Extract an FDS file id from a Key value.
GetRecordKey(uint32_t key)
constexpr uint16_t
Extract an FDS record key from a Key value.
OpenRecord(NRF5Config::Key key, fds_record_desc_t & recDesc, fds_flash_record_t & rec)

Public types

Key

uint32_t Key

Protected types

ForEachRecordFunct

std::function< WEAVE_ERROR(const fds_flash_record_t &rec, bool &deleteRec)> ForEachRecordFunct

Public static attributes

kConfigKey_DeviceCert

constexpr Key kConfigKey_DeviceCert = NRF5ConfigKey(kFileId_WeaveFactory, 0x0003)

kConfigKey_DeviceId

constexpr Key kConfigKey_DeviceId = NRF5ConfigKey(kFileId_WeaveFactory, 0x0002)

kConfigKey_DevicePrivateKey

constexpr Key kConfigKey_DevicePrivateKey = NRF5ConfigKey(kFileId_WeaveFactory, 0x0004)

kConfigKey_FabricId

constexpr Key kConfigKey_FabricId = NRF5ConfigKey(kFileId_WeaveConfig,  0x0007)

kConfigKey_FabricSecret

constexpr Key kConfigKey_FabricSecret = NRF5ConfigKey(kFileId_WeaveConfig,  0x000B)

kConfigKey_FailSafeArmed

constexpr Key kConfigKey_FailSafeArmed = NRF5ConfigKey(kFileId_WeaveConfig,  0x000D)

kConfigKey_GroupKey

constexpr Key kConfigKey_GroupKey = NRF5ConfigKey(kFileId_WeaveConfig,  0x000E)

kConfigKey_LastUsedEpochKeyId

constexpr Key kConfigKey_LastUsedEpochKeyId = NRF5ConfigKey(kFileId_WeaveConfig,  0x000C)

kConfigKey_ManufacturingDate

constexpr Key kConfigKey_ManufacturingDate = NRF5ConfigKey(kFileId_WeaveFactory, 0x0005)

kConfigKey_PairedAccountId

constexpr Key kConfigKey_PairedAccountId = NRF5ConfigKey(kFileId_WeaveConfig,  0x0009)

kConfigKey_PairingCode

constexpr Key kConfigKey_PairingCode = NRF5ConfigKey(kFileId_WeaveFactory, 0x0006)

kConfigKey_ProductRevision

constexpr Key kConfigKey_ProductRevision = NRF5ConfigKey(kFileId_WeaveFactory, 0x000F)

kConfigKey_SerialNum

constexpr Key kConfigKey_SerialNum = NRF5ConfigKey(kFileId_WeaveFactory, 0x0001)

kConfigKey_ServiceConfig

constexpr Key kConfigKey_ServiceConfig = NRF5ConfigKey(kFileId_WeaveConfig,  0x0008)

kConfigKey_ServiceId

constexpr Key kConfigKey_ServiceId = NRF5ConfigKey(kFileId_WeaveConfig,  0x000A)

kFDSFileIdMax

constexpr uint16_t kFDSFileIdMax = 0xBFFF

Maximum value that can be used for a FDS file id (per Nordic SDK)

kFDSFileIdMin

constexpr uint16_t kFDSFileIdMin = 0x0000

Minimum value that can be used for a FDS file id (per Nordic SDK)

kFDSRecordKeyMax

constexpr uint16_t kFDSRecordKeyMax = 0xBFFF

Maximum value that can be used for a FDS record key (per Nordic SDK)

kFDSRecordKeyMin

constexpr uint16_t kFDSRecordKeyMin = 0x0001

Minimum value that can be used for a FDS record key (per Nordic SDK)

kFileId_WeaveConfig

constexpr uint16_t kFileId_WeaveConfig = 0x235B

FDS file containing dynamic config values set at runtime.

Cleared during factory reset.

kFileId_WeaveCounter

constexpr uint16_t kFileId_WeaveCounter = 0x235C

FDS file containing dynamic counter values set at runtime.

Retained during factory reset.

kFileId_WeaveFactory

constexpr uint16_t kFileId_WeaveFactory = 0x235A

FDS file containing persistent config values set at manufacturing time.

Retained during factory reset.

kPersistedCounterRecordKeyBase

constexpr uint16_t kPersistedCounterRecordKeyBase = kFDSRecordKeyMin

Base record key for records containing Weave persisted counter values.

The Weave counter id is added to this value to form the FDS record key.

kPersistedCounterRecordKeyMax

constexpr uint16_t kPersistedCounterRecordKeyMax = kFDSRecordKeyMax

Max record key for records containing Weave persisted counter values.

Protected static attributes

kFDSWordSize

constexpr uint16_t kFDSWordSize = 4

sActiveAsyncOp

FDSAsyncOp *volatile sActiveAsyncOp

sAsyncOpCompletionSem

SemaphoreHandle_t sAsyncOpCompletionSem

Public static functions

ClearConfigValue

WEAVE_ERROR ClearConfigValue(
  Key key
)

ConfigValueExists

bool ConfigValueExists(
  Key key
)

FactoryResetConfig

WEAVE_ERROR FactoryResetConfig(
  void
)

Init

WEAVE_ERROR Init(
  void
)

ReadConfigValue

WEAVE_ERROR ReadConfigValue(
  Key key,
  bool & val
)

ReadConfigValue

WEAVE_ERROR ReadConfigValue(
  Key key,
  uint32_t & val
)

ReadConfigValue

WEAVE_ERROR ReadConfigValue(
  Key key,
  uint64_t & val
)

ReadConfigValueBin

WEAVE_ERROR ReadConfigValueBin(
  Key key,
  uint8_t *buf,
  size_t bufSize,
  size_t & outLen
)

ReadConfigValueStr

WEAVE_ERROR ReadConfigValueStr(
  Key key,
  char *buf,
  size_t bufSize,
  size_t & outLen
)

RunConfigUnitTest

void RunConfigUnitTest(
  void
)

WriteConfigValue

WEAVE_ERROR WriteConfigValue(
  Key key,
  bool val
)

WriteConfigValue

WEAVE_ERROR WriteConfigValue(
  Key key,
  uint32_t val
)

WriteConfigValue

WEAVE_ERROR WriteConfigValue(
  Key key,
  uint64_t val
)

WriteConfigValueBin

WEAVE_ERROR WriteConfigValueBin(
  Key key,
  const uint8_t *data,
  size_t dataLen
)

WriteConfigValueStr

WEAVE_ERROR WriteConfigValueStr(
  Key key,
  const char *str
)

WriteConfigValueStr

WEAVE_ERROR WriteConfigValueStr(
  Key key,
  const char *str,
  size_t strLen
)

Protected static functions

DoAsyncFDSOp

WEAVE_ERROR DoAsyncFDSOp(
  FDSAsyncOp & asyncOp
)

FDSWords

constexpr uint16_t FDSWords(
  size_t s
)

Number of FDS words needed to hold a given size object.

ForEachRecord

WEAVE_ERROR ForEachRecord(
  uint16_t fileId,
  uint16_t recordKey,
  ForEachRecordFunct funct
)

GetFileId

constexpr uint16_t GetFileId(
  uint32_t key
)

Extract an FDS file id from a Key value.

GetRecordKey

constexpr uint16_t GetRecordKey(
  uint32_t key
)

Extract an FDS record key from a Key value.

OpenRecord

WEAVE_ERROR OpenRecord(
  NRF5Config::Key key,
  fds_record_desc_t & recDesc,
  fds_flash_record_t & rec
)