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.

[FAQ] CC2652R: CC13x2 CC26x2 SDK Zigbee Known Issues and Fixes

Guru 94620 points

Replies: 1

Views: 556

Part Number: CC2652R

simplelink_cc13x2_26x2_sdk_3_30_00_03

1. When more than one group is added (with unique group IDs), they are not restored correctly after a reset.

Apply the following code changes:

uint8 osal_nv_write( uint16 id, uint16 ndx, uint16 len, void *buf )
{
    // Fix added
    #include "aps_groups.h"

    extern uint8_t restoreInProgress_NLME;
    extern apsGroupItem_t *apsGroupTable;
    struct apsGroupNVItem {
        uint8_t                endpoint;
        aps_Group_t          group;
    };

    apsGroupItem_t *pLoop = apsGroupTable;
    struct apsGroupNVItem item;

    if (id == ZCD_NV_GROUP_TABLE)
    {
        if (restoreInProgress_NLME)
            return; // don't write to NV group table while a restore is in progress

        // write correctly to NV group table
        uint16_t i = 0;
        while ( pLoop )
        {
          // Build the record
          item.endpoint = pLoop->endpoint;
          OsalPort_memcpy( &(item.group), &(pLoop->group), sizeof ( aps_Group_t ) );

          OsalPort_memcpy(buf + (uint16_t)((sizeof(uint16_t)) + (i * sizeof ( struct apsGroupNVItem ))),  &item, sizeof ( struct apsGroupNVItem ));

          pLoop = pLoop->next;
          i += 1;
        }
    }
    // End of fix

  // Legacy items use ZCD_NV_EX_LEGACY as the ID and the id as the sub-id.
  return ( osal_nv_write_ex( ZCD_NV_EX_LEGACY, id, ndx, len, buf ) );
}
uint8_t restoreInProgress_NLME = FALSE; // Fix added
uint8_t ZDApp_RestoreNetworkState( void )
{
  uint8_t nvStat;

  // Initialize NWK NV items
  nvStat = NLME_InitNV();

  if ( nvStat == SUCCESS )
  {
      restoreInProgress_NLME = TRUE; // Fix added

    if ( NLME_RestoreFromNV() )
    {
      // Are we a coordinator
      ZDAppNwkAddr.addr.shortAddr = NLME_GetShortAddr();
      if ( ZDAppNwkAddr.addr.shortAddr == 0 )
      {
        ZDO_Config_Node_Descriptor.LogicalType = NODETYPE_COORDINATOR;
      }
      if(ZG_DEVICE_ENDDEVICE_TYPE)
      {
        devStartMode = MODE_REJOIN;
        _NIB.nwkState = NWK_INIT;
      }
      else
      {
        devStartMode = MODE_RESUME;
      }
      osal_cpyExtAddr( ZDO_UseExtendedPANID, _NIB.extendedPANID );
    }
    else
      nvStat = NV_ITEM_UNINIT;

    restoreInProgress_NLME = FALSE; // Fix added


    nwkFrameCounterChanges = 0;

    if ( ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE )
    {
      ZDApp_RestoreNwkKey( TRUE );
    }

    // The default for RxOnWhenIdle is true for Routers and false for end devices
    // [setup in the NLME_RestoreFromNV()].  Change it here if you want something
    // other than default.
  }

  if ( nvStat == ZSUCCESS )
    return ( ZDO_INITDEV_RESTORED_NETWORK_STATE );
  else
    return ( ZDO_INITDEV_NEW_NETWORK_STATE );
}
#endif // NV_RESTORE

2. Project initialization asserts if HEAPMGR_ASSERT is defined.

Make the following code changes:

void HEAPMGR_INIT(void)
{   initInProgress = 1;
// ...

   initInProgress = 0;
}
void *HEAPMGR_MALLOC(hmU32_t size)
{// ...
    if (!initInProgress)
        HEAPMGR_ASSERT(size);
// ...
}

3. *zclParseInConfigReportCmd assumes the reportable attribute field will always be at least one, causing parse issues when multiple attributes are reported

Remove the else {pBuf++;} statement from *zclParseInConfigReportCmd

4. ZCD_NV_EX_DEVICE_LIST is not updated for all necessary instances

Force an association device update through the ZDApp_SaveNetworkStateEvt:

  for( n = 0; n < gNWK_MAX_DEVICE_LIST; n++ )
  {
    uint16_t shortAddr;
    osal_nv_read_ex( ZCD_NV_EX_DEVICE_LIST, n, 0, sizeof(shortAddr), &shortAddr );
    if( (AssociatedDevList[n].shortAddr == 0xFFFF) && ( shortAddr != 0xFFFF ) )
    {
      //not delete NVID, fixed by luoyiming 2019-10-16
      uint8_t tmpBuf[16];
      memset( tmpBuf, 0xFF, sizeof(tmpBuf) );
      osal_nv_write_ex( ZCD_NV_EX_DEVICE_LIST, n, sizeof(tmpBuf), tmpBuf );
    }
  }

5. Duplicate TCLK entries after a device performs a second network join

Make the following corrections to zd_app.c:

ZStatus_t ZDO_JoinIndicationCB(uint16_t ShortAddress, uint8_t *ExtendedAddress,
                                uint8_t CapabilityFlags, uint8_t type)
{
  (void)ExtendedAddress;
  //check if the device is leaving before responding to rejoin request
  if( OsalPortTimers_getTimerTimeout( ZDAppTaskID , ZDO_DEVICE_RESET) )
  {
    return ZFailure; // device leaving , hence do not allow rejoin
  }

#if ZDO_NV_SAVE_RFDs
    (void)CapabilityFlags;

#else  // if !ZDO_NV_SAVE_RFDs
    if (CapabilityFlags & CAPINFO_DEVICETYPE_FFD)
#endif
    {
      ZDApp_NVUpdate();  // Notify to save info into NV.
    }


    // toby added

    // if previously joined device has cleared its NV,
    // it will have entry in TCLK table, and
    // send an Association Request when it attempts commissioning.
    // if so, clear its entry in TCLK table.
    if (type == NWK_ASSOC_JOIN && ( ZG_BUILD_COORDINATOR_TYPE && ZG_DEVICE_COORDINATOR_TYPE ))
    {
        uint16_t i;
        APSME_TCLinkKeyNVEntry_t TCLK_Entry;
        for (i = 0; i < ZDSECMGR_TC_DEVICE_MAX; i++)
        {
            memset(&TCLK_Entry, 0x00, sizeof(APSME_TCLinkKeyNVEntry_t));

            if (TCLinkKeyRAMEntry[i].entryUsed == TRUE)
            {
                osal_nv_read_ex( ZCD_NV_EX_TCLK_TABLE, i, 0,
                                       sizeof(APSME_TCLinkKeyNVEntry_t),
                                       &TCLK_Entry );

                // if extended address in NV matches this joining device's extended address AND the device key was verified before...
                if (!memcmp(TCLK_Entry.extAddr, ExtendedAddress, Z_EXTADDR_LEN) && TCLK_Entry.keyAttributes == ZG_VERIFIED_KEY)
                {
                    // then clear this entry
                    TCLinkKeyRAMEntry[i].entryUsed = FALSE;
                    memset(&TCLK_Entry, 0x00, sizeof(APSME_TCLinkKeyNVEntry_t));
                    TCLK_Entry.keyAttributes = ZG_DEFAULT_KEY;
                    osal_nv_write_ex(ZCD_NV_EX_TCLK_TABLE, i,
                                               sizeof(APSME_TCLinkKeyNVEntry_t),
                                               &TCLK_Entry);
                    break;
                }
            }
        }
    }

    // end added

// ...

6. *zclParseInDiscCmdsRspCmd causes stack failure

Add pDiscoverRspCmd->pCmdID = (uint8_t*)( pDiscoverRspCmd + 1 ); after pDiscoverRspCmd->numCmd = numCmds;

Regards,
Ryan

To better aid the community, please click on the "This Resolved my issue" button whenever a post answers your question!

1 Reply

  • Good to know, thanks!

    Regards,
    Toby

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.