This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] CC2652P:在示例 ZC/ZED 应用中修改之后、通道掩码是否会保存到 NVS 中?

Guru**** 2457760 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/1304935/cc2652p-are-channel-masks-saved-into-nvs-after-being-modified-in-sample-zc-zed-applications

器件型号:CC2652P

您好!

我在浏览示例 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

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、ZL:

    在 NV 中存储有一个通道列表(来自 zcomdef.h 的 ZCD_NV_CHANLIST)、但默认示例中的 CUI 未更改。  要 实现此功能、您需要向 zcl_sampleapps_ui.c  中 ui_item_interceppe_stop uiActionProcessConfigurePriChannels 的 CUI 实例添加一个 Zstackapi_sysConfigWriteReq:

              zstack_sysConfigWriteReq_t writeReq = {0};
              // Update the config Channel List, defined in znwk_config.h
              writeReq.has_chanList = true;
              writeReq.chanList = channelMask;
              Zstackapi_sysConfigWriteReq(uiAppEntity, &writeReq);

    这只会影响主信道列表、因为 NV 存储器不考虑辅助信道列表。   如果您想将定制 NV 存储器项目添加到应用程序中、也可遵循应用程序非易失性存储器指令。

    此致、
    瑞安

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    虽然这可以将更改后的通道掩码保存到 NVS 中、但我认为在构建协调器网络以及加入路由器和终端设备上的网络之前、我们还需要从 NVS 中读取它们。 最好在哪里放置此类代码? 类似以下的东西?

    /*********************************************************************
     * @fn          uiActionStartComissioning
     *
     * @brief       action function to trigger commissioning
     *
     * @return      none
     */
    static void uiActionStartComissioning(const int32_t _itemEntry)
    {
      // reset network connection string before commissioning again
      uiCommissioningNetworkConnectionStr = NULL;
    
      if (*gpBdbCommisioningModes != 0)
      {
        zstack_bdbStartCommissioningReq_t zstack_bdbStartCommissioningReq;
    
        FBMatchesFound = 0;
    
        uiCommissioningIsInitializing = TRUE;
    
        zstack_bdbStartCommissioningReq.commissioning_mode = *gpBdbCommisioningModes;
    	
    	// TODO: read channel masks from NVS
    	// Pass channel masks to bdbAttributes before nwkFormation and commissioning
    
        Zstackapi_bdbStartCommissioningReq(uiAppEntity,&zstack_bdbStartCommissioningReq);
      }
    }

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    与 uiActionProcessConfigurePriChannels CUI_item_intercept 停止情况一样、您需要确定  为 bdbPrimaryChannelSet 调用 Zstackapi_BdbSetAttributeReq 的位置。  这可以来自 uiActionStartComissioning、但请记住、该函数仅针对 UART UI 调用、不用于其他调试方法、例如按钮或自定义自动启动。

    此致、
    瑞安