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.

CC2652R: Last group added using aps_AddGroup can never be deleted

Part Number: CC2652R
Other Parts Discussed in Thread: SIMPLELINK-CC13X2-26X2-SDK, Z-STACK

Hi,

We recently updated from SDK 4.40 to SDK 6.10 for Zstack projects, probably might happen in recent stacks as well

While testing I observed that the last group added to the aps_GroupsTable using aps_AddGroup always exists after powercycle even if removed using aps_RemoveGroup or aps_RemoveAllGroup.
Infact, using aps_RemoveAllGroups removes devices temporarily but the groups are still present after powercycle

Not sure why this could be happening, wasn't happening in SDK 4.40

Steps to reproduce

1. Add a group
2. Get group, verify it exists
3. Remove group
4. Get group, verify it not longer exists
5. Power cycle
6. Get group, observe that the group added exists. Also, please note this happens irrespective of number of groups in the table.

Any advise would be greatly helpful.

Thanks
Akhilesh

P.S.
These issues maybe linked to the Groups NV id migration which happened somewhere between 4.40 and 6.10

  • Hi Akhilesh,

    You could be referring to ZIGBEE-872: Optimized ZCL Group table NV implementation from SIMPLELINK-CC13X2-26X2-SDK v5.10, see the Z-Stack Release Notes.  Please confirm that you are using the Zstackapi_ApsAddGroupReq() and other Z-Stack API related to groups, there is an example available from the Overview section of the Z-Stack User's Guide.  Also make sure to erase all NV memory before re-programming.  If the issue persists then please provide code excerpts which should be implemented to recreate the issue.

    Regards,
    Ryan

  • Hi Ryan,

    I am not using Zstackapi_ApsAddGroupReq() , but instead calling the aps_AddGroup function directly, this is what I have been using all along.
    I have custom zcl commands to add and delete groups which basically does the same as the ZStackapi, so I think the issue would persist even if the API was called.

    This is a slightly edited code snippet for adding/removing groups

    void k_addGroups(uint16_t *groupIds, uint8_t numGroups, uint8_t *addStatus)
    {
        for (uint8_t i = 0; i < numGroups; i++)
        {
            //Adding group
            aps_Group_t group = {
                groupIds[i]
                {1, 2, 3}
            };
            addStatus[i] = aps_AddGroup(15, &group, true);
        }
    }
    
    void k_removeGroups(uint16_t *groupIds, uint8_t numGroups, uint8_t *removeStatus)
    {
        for (uint8_t i = 0; i < numGroups; i++)
        {
            //Removing group
            removeStatus[i] = aps_RemoveGroup(15, groupIds[i]);
        }
    }

  • Hi Ryan,

    This is a more appropriate snippet

        Zstackapi_bdbStartCommissioningReq(appServiceTaskId,
                                           &zstack_bdbStartCommissioningReq);
    
        uint8_t existingGroupCount = aps_CountGroups(15);
        uint16_t allGroups[APS_MAX_GROUPS] = {0};
        if(existingGroupCount)
        {
            //aps_RemoveAllGroup(15);
    
            //alternatively
            aps_FindAllGroupsForEndpoint(15, allGroups);
            for(uint8_t i = 0; i < existingGroupCount; i++)
            {
                aps_RemoveGroup(15, allGroups[i]);
            }
        }
        else
        {
            //Adding group
            aps_Group_t group = {100, {1, 2, 3}};
            aps_AddGroup(15, &group, true);
        }

    Please add to the zclInit for zigbee task.

    This code should switch between adding and removing zigbee groups. But after the first iteration, the code always flows into remove groups. Also the apsGroupsTable shows the entries which were deleted as still present.

    Thanks
    Akhilesh

  • Thanks for the code snippet, I placed it into the CONFIG_BTN_RIGHT handling of zcl_samplelight.c to ensure proper observations each time the process was called from my debugger.  I followed your same reproduction steps and yet the group added would no longer exist after the removal and power cycle.  The status of each operation returns successfully.  How are you implementing a power cycle and observing the group states from your system to ensure that you have not missed any operations?  Note that entering/exiting a debugger could cause unexpected power cycles that are not being accounted for.

            if(key == CONFIG_BTN_RIGHT)
            {
                uint8_t existingGroupCount = aps_CountGroups(SAMPLELIGHT_ENDPOINT);
                uint16_t allGroups[APS_MAX_GROUPS] = {0};
                uint8_t status;
                if(existingGroupCount)
                {
                    //aps_RemoveAllGroup(15);
    
                    //alternatively
                    aps_FindAllGroupsForEndpoint(SAMPLELIGHT_ENDPOINT, allGroups);
                    for(uint8_t i = 0; i < existingGroupCount; i++)
                    {
                        status = aps_RemoveGroup(SAMPLELIGHT_ENDPOINT, allGroups[i]);
                    }
                }
                else
                {
                    //Adding group
                    aps_Group_t group = {100, {1, 2, 3}};
                    status = aps_AddGroup(SAMPLELIGHT_ENDPOINT, &group, true);
                }
    
            }

    Regards,
    Ryan

  • Hi Ryan,

    We validated this same code on our launchpad and this issue still reproduces. These are the steps that have been followed.

    1. Added your code snippet to CONFIG_BTN_RIGHT in zcl_samplelight,c of project zr_light.
    a. 4.40, CCS compiler -> Issue was not reproducible
    b. 6.10, CCS compiler -> Issue was reproducible
    c. 6.30, Clang compiler -> Issue was reproducible.

    The groups do not persist if the device is not paired anyways, so we have paired this device(router) to a zigbee hub.

    The power cycle in a live device is being done with SysCtrlSystemReset();
    While debugging, I am using the Board Reset option from debugger.

    Another observation is the that when aps_removeGroup(or Zstackapi_ApsRemoveGroupReq) is called, the group that has this problem returns status as FALSE, and but is removed from the apsGroupTable.
    However if I do perform aps_GroupsRestoreFromNV, the group returns. This seems like that delete of group item is succeeding but the NV write for the same is failing causing the status to return as false.

    Please could you share what are the possibilities for aps_removeGroup to return false, because it returns true for both group present and absent, so some other case seems to failing for me

    Thanks
    Akhilesh

  • Hi Akhilesh,

    Thank you for providing this additional information concerning how to replicate the problem.  I have confirmed that it is an issue from the pre-built Z-Stack libraries and have submitted a bug ticket so that the Software Development can address it for an upcoming SDK release.  I will contact you through private message for next steps.

    Regards,
    Ryan