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:制作 z-stack 以支持制造商集群和制造商属性

Guru**** 2589275 points
Other Parts Discussed in Thread: Z-STACK, SIMPLELINK-CC13X2-26X2-SDK

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

https://e2e.ti.com/support/wireless-connectivity/zigbee-thread-group/zigbee-and-thread/f/zigbee-thread-forum/1021583/cc2652p-make-z-stack-to-support-manufacturer-clusters-and-manufacturer-attributes

器件型号:CC2652P
Thread 中讨论的其他器件:Z-stackSIMPLELINK-CC13X2-26X2-SDK

首先、制作 z-stack 以支持 Manufacturer 属性。

可以将制造商标志添加到"zclAttribute_t"的"accessControl"中、 因为一个器件只有一个制造商代码。 "access_control_command"标志未在 z-stack 中使用、我们可以使用它来标记"制造商代码"标志。

...
#define ACCESS_CONTROL_COMMAND                          0x08
...
// Access Control for manufacturer-specific attribute, fixed by luoyiming 2020-01-08
#define ACCESS_MANU_ATTR                                ACCESS_CONTROL_COMMAND
...

因此、z-stack 中的属性访问函数应固定为支持"access_manu_attr"。 在"zcl.h"和"zcl.c"中、将新函数"zclFindAttrRecEx"定义为"zclFindAttrRec"、而不是"zclFindAttrRec"

#define zclFindAttrRec(ep,cId,attr,rec)  zclFindAttrRecEx(ep,cId,0,0,attr,rec,NULL)

extern uint8_t zclFindAttrRecEx( uint8_t endpoint, uint16_t realClusterID, uint16_t manuCode, uint8_t direction,
                                 uint16_t attrId, zclAttrRec_t *pAttr, uint8_t *idx );

uint8_t zclFindAttrRecEx( uint8_t endpoint, uint16_t clusterID, uint16_t manuCode, uint8_t direction,
                          uint16_t attrId, zclAttrRec_t *pAttr, uint8_t *idx )
{
  uint8_t x;
  zclAttrRecsList *pRec = zclFindAttrRecsList( endpoint );
  uint8_t matchManuCode = FALSE;

  // match manufacturer-cluster, fixed by luoyiming 2020-01-08
  // don't execute for wildcard manufacturer ID, luoyiming add at 2020-01-09
  if ( ( clusterID < 0xFC00 ) && ( manuCode != 0 ) && ( manuCode != 0xFFFF ) )
  {
    matchManuCode = TRUE;
  }

  if ( pRec != NULL )
  {
    for ( x = 0; x < pRec->numAttributes; x++ )
    {
      // match manufacturer attribute at first, luoyiming 2020-01-08
      if ( ( pRec->attrs[x].attr.accessControl & ACCESS_MANU_ATTR ) && matchManuCode == FALSE )
      {
        continue;
      }
      if ( pRec->attrs[x].clusterID == clusterID && pRec->attrs[x].attr.attrId == attrId )
      {
        //match direction, fixed by luoyiming 2019-11-16
        if ( (pRec->attrs[x].attr.accessControl & ACCESS_GLOBAL) ||
             ( GET_BIT( &(pRec->attrs[x].attr.accessControl), ACCESS_CONTROL_MASK ) == direction ) )
        {
          *pAttr = pRec->attrs[x];
          // return the attribute's index, luoyiming 2021-07-04
          if( idx != NULL )
          {
            *idx = x;
          }
          return ( TRUE ); // EMBEDDED RETURN
        }
      }
    }
  }

  return ( FALSE );
}

还需要修复函数"zclFindNextAttrRec"以支持制造商代码

static uint8_t zclFindNextAttrRec( uint8_t endpoint, uint16_t clusterID, uint16_t manuCode, uint8_t direction,
                                   uint16_t *attrId, zclAttrRec_t *pAttr, uint8_t *startIdx, bool cmpAttr )
{
  zclAttrRecsList *pRec = zclFindAttrRecsList( endpoint );
  uint8_t attrDir;
  uint8_t matchManuCode = FALSE;

  //match manufacturer-cluster, fixed by luoyiming 2020-01-08
  if ( ( clusterID < 0xFC00 ) && ( manuCode != 0 ) )
  {
    matchManuCode = TRUE;
  }

  if ( pRec != NULL )
  {
    uint16_t x;

    for ( x = *startIdx; x < pRec->numAttributes; x++ )
    {
      // match manufacturer attribute at first, luoyiming 2020-01-08
      if ( ( pRec->attrs[x].attr.accessControl & ACCESS_MANU_ATTR ) && matchManuCode == FALSE )
      {
        continue;
      }
      if ( pRec->attrs[x].clusterID == clusterID )
      {
        // compare attrId or not, fixed by luoyiming 2021-07-04
        if( (pRec->attrs[x].attr.attrId >= *attrId) || (cmpAttr == false) )
        {
          // also make sure direction is right
          attrDir = (pRec->attrs[x].attr.accessControl & ACCESS_CLIENT) ? 1 : 0;
          if ( (attrDir == direction) || (pRec->attrs[x].attr.accessControl & ACCESS_GLOBAL) )
          {
            // return attribute and found attribute ID
            *pAttr = pRec->attrs[x];
            *attrId = pAttr->attr.attrId;
            *startIdx = x; // Update startIdx for next loop, luoyiming 2020-07-11

            return ( TRUE ); // EMBEDDED RETURN
          }
        }
      }
    }
  }

  return ( FALSE );
}

在"zcl.c" ti 支持制造商代码中定义新函数

uint8_t zcl_MatchClusterManuCode( uint16_t clusterID, uint16_t manuCode )
{
  uint16_t node_manuCode;

  // no manufacturer code processing
  if ( manuCode == 0 && clusterID < 0xFC00 )
  {
    return TRUE;
  }

  // get local manufacturer code for manufacturer-specific indication, luoyiming 2020-01-15
  node_manuCode = zcl_GetManuCode( clusterID );
  // manufacturer code is valid, match with node's manu-code or wildcard manu-code, luoyiming 2020-01-09
  if ( ( node_manuCode != 0 ) && ( node_manuCode == manuCode || 0xFFFF == manuCode ) )
  {
    return TRUE;
  }

  return FALSE;
}

在"zcl_ProcessMessageMSG"中添加制造商代码处理

zclProcMsgStatus_t zcl_ProcessMessageMSG( afIncomingMSGPacket_t *pkt )
{
 

  // Is this a foundation type message
  if ( !interPanMsg && zcl_ProfileCmd( inMsg.hdr.fc.type ) )
  {
    if ( CMD_REQ_IND( inMsg.hdr.commandID ) &&
         ( inMsg.hdr.fc.manuSpecific ) && // add by luoyiming 2019-5-19
         ( !zcl_MatchClusterManuCode( inMsg.msg->clusterId, inMsg.hdr.manuCode )) ) // manu code match cluster fail, fix at 2019-10-20
    {
      // We don't support any manufacturer specific command
      status = ZCL_STATUS_UNSUP_MANU_GENERAL_COMMAND;
    }

...
  }

}

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

    将"bdb_reporting.c"设为支持制造商代码。  

    在 "bdb_reporting.c"中为每个具有"cluster"和"attrID"的结构添加结构成员"manuCode"和"direction "

    typedef struct
    {
      uint8_t endpoint;
      uint8_t direction;  //add by luoyiming, 2020-01-07
      uint16_t cluster;
      uint16_t manuCode;  //add by luoyiming, 2019-10-21
      uint16_t attrID;
      uint16_t minReportInt;
      uint16_t maxReportInt;
      uint16_t defaultMinReportInt;
      uint16_t defaultMaxReportInt;
      uint8_t  reportableChange[BDBREPORTING_MAX_ANALOG_ATTR_SIZE];
      uint8_t  defaultReportableChange[BDBREPORTING_MAX_ANALOG_ATTR_SIZE];
    } bdbReportAttrCfgData_t;
    
    typedef struct
    {
      uint8_t flags;
      uint8_t  endpoint;             // status field
      uint8_t  direction;         //add by luoyiming, 2020-01-07
      uint16_t  cluster;          // to send or receive reports of the attribute
      uint16_t  manuCode;         //add by luoyiming, 2019-10-21
      uint16_t  consolidatedMinReportInt;             // attribute ID
      uint16_t  consolidatedMaxReportInt;           // attribute data type
      uint16_t  timeSinceLastReport;
      bdbAttrLinkedListAttr_t attrLinkedList;
    } bdbReportAttrClusterEndpoint_t;
    
    typedef struct
    {
      uint8_t flags;
      uint8_t  endpoint;
      uint8_t  direction;  //add by luoyiming, 2020-01-07
      uint16_t  cluster;
      uint16_t  manuCode;  //add by luoyiming, 2019-10-21
    } bdbReportFlagsHolder_t;
    
    typedef struct
    {
      uint8_t endpoint;
      uint8_t direction;  //add by luoyiming, 2020-01-07
      uint16_t cluster;
      uint16_t manuCode;  //add by luoyiming, 2019-10-21
      uint16_t attrID;
      uint16_t minReportInt;
      uint16_t maxReportInt;
      uint8_t  reportableChange[BDBREPORTING_MAX_ANALOG_ATTR_SIZE];
    } bdbReportAttrDefaultCfgData_t;
    
    

    然后 、在 "bdb_reporting.c"中具有"cluster"和"attrID"的每个函数中添加参数"direction "和"manuCode"。

    static uint8_t bdb_clusterEndpointArrayAdd( uint8_t endpoint, uint16_t cluster, uint16_t manuCode, uint8_t direction, uint16_t consolidatedMinReportInt, uint16_t consolidatedMaxReportInt, uint16_t timeSinceLastReport );
    static uint8_t bdb_clusterEndpointArraySearch( uint8_t endpoint, uint16_t cluster, uint16_t manuCode, uint8_t direction );
    static uint8_t bdb_repAttrCfgRecordsArrayAdd( uint8_t endpoint, uint16_t cluster, uint16_t manuCode, uint8_t direction, uint16_t attrID, uint16_t minReportInt,
                                                  uint16_t maxReportInt, uint8_t  reportableChange[], uint16_t defMinReportInt, uint16_t defMaxReportInt, uint8_t defReportChange[] );
                                                  static uint8_t bdb_repAttrCfgRecordsArraySearch( uint8_t endpoint, uint16_t cluster, uint16_t manuCode, uint8_t direction, uint16_t attrID ); //add manuCode, fixed by luoyiming 2019-10-20
    static uint8_t bdb_repAttrCfgRecordsArrayConsolidateValues( uint8_t endpoint, uint16_t cluster, uint16_t manuCode, uint8_t direction, uint16_t* consolidatedMinReportInt, uint16_t* consolidatedMaxReportInt );
    static uint8_t bdb_RepFindAttrEntry( uint8_t endpoint, uint16_t cluster, uint16_t manuCode, uint8_t direction, uint16_t attrID, zclAttribute_t* attrRes );

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

    修复程序太多、因此我必须更新固定文件。

    e2e.ti.com/.../zcl.zip

    e2e.ti.com/.../bdb_5F00_reporting.zip

    完整的修复程序可从 gitee.com/.../simplelink_zstack_sdk.git 下载

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

    嘿、Aries、

    感谢您提供更改的详细说明以及指向完整解决方案的链接。  我假设已在 SIMPLELINK-CC13X2-26X2-SDK v5.20上验证过这一点?

    此致、
    Ryan

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

    是的、所有这些 都已在  SIMPLELINK-CC13X2-26X2-SDK v5.20上进行验证。 我们设计了一款光电平传感器器件、可从其他光传感器读取照度测量值并向其他光源发送电平命令