您好!
我在浏览示例 zc-恒温器应用时注意到、主通道和辅助通道掩码在通过 CUI 进行更改后似乎没有保存到 NVS 中。 在下电上电后、它们始终会恢复到 syscfg 中定义的默认信道掩码。 作为比较、PAN ID 在更改后似乎被写入 NVS 并可继续下电上电。 截获开始后、更新的平移 ID 将显示在 CUI 中。
根据代码判断、两个通道掩码都应持久存在:
// zcl_sampleApps_ui.c
/*********************************************************************
* @fn uiActionProcessConfigureSecChannels
*
* @brief State-machine action for configuring channel masks
*
* @param _input - uart key or uart notification
* _pLines - pointers to the buffers to be displayed
* _pCurInfo - pointer to the cursor position. The position is given
* by the length of _pLines and the number of lines.
* If -1,-1 is provided, no pointer is displayed
*
* @return none
*/
static void uiActionProcessConfigureSecChannels(const char _input, char* _pLines[3], CUI_cursorInfo_t* _pCurInfo)
{
static uint32_t channelMask = SECONDARY_CHANLIST;
if (_input == CUI_ITEM_INTERCEPT_START) {
zstack_bdbGetAttributesRsp_t rsp;
Zstackapi_bdbGetAttributesReq(uiAppEntity, &rsp);
channelMask = rsp.bdbSecondaryChannelSet;
}
uiActionProcessConfigureChannels(_input, _pLines, _pCurInfo, &channelMask);
if (_input == CUI_ITEM_INTERCEPT_STOP) {
zstack_bdbSetAttributesReq_t req = {0};
req.bdbSecondaryChannelSet = channelMask;
req.has_bdbSecondaryChannelSet = true;
Zstackapi_bdbSetAttributesReq(uiAppEntity, &req);
}
if (_input != CUI_ITEM_PREVIEW)
strcpy(_pLines[2], " SEC CHANL MASK");
}
我做了更深入的解释、似乎信道掩码被视为 bdbAttributes 的一部分、处理方式有所不同。 bdbAttributes 始终在启动时从默认值加载,更改时不会写入 NVS。
// bdb.c bdbAttributes_t bdbAttributes = BDB_ATTRIBUTES_DEFAULT_CONFIG;
// zstacktask.c
/**************************************************************************************************
* @fn processBdbSetAttributesReq
*
* @brief Process BDB Set attributes Request
*
* @param srcServiceTaskId - Source Task ID
* @param pMsg - pointer to message
*
* @return TRUE to send the response back
*/
static bool processBdbSetAttributesReq( uint8_t srcServiceTaskId, void *pMsg )
{
zstackmsg_bdbSetAttributesReq_t *pPtr = (zstackmsg_bdbSetAttributesReq_t *)pMsg;
if ( pPtr->pReq )
{
pPtr->hdr.status = zstack_ZStatusValues_ZSuccess;
#if (ZG_BUILD_JOINING_TYPE)
if ( pPtr->pReq->has_bdbTCLinkKeyExchangeAttemptsMax )
{
bdbAttributes.bdbTCLinkKeyExchangeAttemptsMax = pPtr->pReq->bdbTCLinkKeyExchangeAttemptsMax;
}
if ( pPtr->pReq->has_bdbTCLinkKeyExchangeMethod )
{
bdbAttributes.bdbTCLinkKeyExchangeMethod = pPtr->pReq->bdbTCLinkKeyExchangeMethod;
}
#endif
if ( pPtr->pReq->has_bdbCommissioningGroupID )
{
bdbAttributes.bdbCommissioningGroupID = pPtr->pReq->bdbCommissioningGroupID;
}
if ( pPtr->pReq->has_bdbPrimaryChannelSet )
{
bdbAttributes.bdbPrimaryChannelSet = pPtr->pReq->bdbPrimaryChannelSet;
}
if ( pPtr->pReq->has_bdbScanDuration )
{
bdbAttributes.bdbScanDuration = pPtr->pReq->bdbScanDuration;
}
if ( pPtr->pReq->has_bdbSecondaryChannelSet )
{
bdbAttributes.bdbSecondaryChannelSet = pPtr->pReq->bdbSecondaryChannelSet;
}
#if (ZG_BUILD_COORDINATOR_TYPE)
if ( pPtr->pReq->has_bdbJoinUsesInstallCodeKey )
{
bdbAttributes.bdbJoinUsesInstallCodeKey = pPtr->pReq->bdbJoinUsesInstallCodeKey;
}
if ( pPtr->pReq->has_bdbTrustCenterNodeJoinTimeout )
{
bdbAttributes.bdbTrustCenterNodeJoinTimeout = pPtr->pReq->bdbTrustCenterNodeJoinTimeout;
}
if ( pPtr->pReq->has_bdbTrustCenterRequireKeyExchange )
{
bdbAttributes.bdbTrustCenterRequireKeyExchange = pPtr->pReq->bdbTrustCenterRequireKeyExchange;
}
#endif
}
else
{
pPtr->hdr.status = zstack_ZStatusValues_ZInvalidParameter;
}
return (TRUE);
}
如果作为用户、我们希望为每次安装设置频道掩码、我们该如何操作? 将通道掩码保存为自定义 NV 项目并使用它们 在系统启动时覆盖 bdbAttributes 或将全部或部分 bdbAttributes 保存到 NVS 中?
请提前告知、并表示感谢。
ZL