Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

Z-stack Zigbee Light Link Copy Scene(all scenes) Bug Fix

$
0
0

Dear TI/TopCAT,

According to the ZLL spec 6.5.1.3.4 Copy scene command,The copy all scenes subfield is 1-bit in length and indicates whether all scenes are to be copied. This functionlity is not working in zcl_general.c -->zclGeneral_ProcessInScenesServer()

The fix is shown below in red line.

case COMMAND_SCENE_COPY:      

{

    uint8 mode;        

    uint16 groupIDTo;        

   uint8 sceneIDTo;        

   uint16 tmpgroupIDFrom;//bug fix

   pData = pInMsg->pData; // different payload format

   mode = *pData++;        

   scene.groupID = BUILD_UINT16( pData[0], pData[1] ); // from group ID        

  pData += 2;        

  scene.ID = *pData++; // from scene ID        

  groupIDTo = BUILD_UINT16( pData[0], pData[1] ); // to group ID        

  pData += 2;        

  if ( (mode & SCENE_COPY_MODE_ALL_BIT) == 0 )        

  {          

        sceneIDTo = *pData++; // to scene ID        

  }

        // Make sure the groups exist        

if ( ( aps_FindGroup( pInMsg->msg->endPoint, scene.groupID ) != NULL ) &&              ( aps_FindGroup( pInMsg->msg->endPoint, groupIDTo ) != NULL ) )        

   {           // Allocate space for the scene list          

        sceneList = osal_mem_alloc( (mode & SCENE_COPY_MODE_ALL_BIT) ? ZCL_GEN_MAX_SCENES : 1 );          

        if ( sceneList == NULL )          

           {            

                    status = ZCL_STATUS_INSUFFICIENT_SPACE; // Couldn't allocate space for the scene list!          

           }          

          else          

            {       

                    status = ZCL_STATUS_SUCCESS;            

                   if ( mode & SCENE_COPY_MODE_ALL_BIT ) // Copy all scenes            

                       {              

                                sceneCnt = zclGeneral_FindAllScenesForGroup( pInMsg->msg->endPoint,scene.groupID, sceneList );                          

                         }            

                      else // Copy single scene            

                      {               // Make sure the scene exists              

                                    pScene = zclGeneral_FindScene( pInMsg->msg->endPoint, scene.groupID, scene.ID );              

                                      if ( pScene != NULL )              

                                     {                

                                           sceneList[0] = scene.ID;                

                                            sceneCnt = 1;              

                                    }              

                                    else              

                                   {                

                                           status = ZCL_STATUS_INVALID_FIELD; // Scene not found              

                                   }            

                    }          

           }

          if ( status == ZCL_STATUS_SUCCESS )         

             {            

                        uint8 numScenesToAdd = 0;            

                         uint8 i;            

                        for ( i = 0; i < sceneCnt; i++ )            

                        {              

                            if ( zclGeneral_FindScene( pInMsg->msg->endPoint, groupIDTo, sceneList[i] ) == NULL )              

                                 {                

                                             numScenesToAdd++;              

                                  }            

                      }            

                     if ( zclGeneral_ScenesRemaingCapacity() >= numScenesToAdd )            

                    {               // Copy the scenes              

                              for ( i = 0; i < sceneCnt; i++ )              

                            {                 // Ignore scene ID from and scene ID to fields                

                                     pScene = zclGeneral_FindScene( pInMsg->msg->endPoint, scene.groupID, sceneList[i] );                

                                    if ( pScene != NULL )                

                                   {                  

                                             zclGeneral_Scene_t *pToScene;                 

                                              scene = *pScene;       

                                     //bug fix

                                       if ( mode & SCENE_COPY_MODE_ALL_BIT )//store the groupid from temperory                       

                                                  tmpgroupIDFrom = scene.groupID;                                    

                                       scene.groupID = groupIDTo;                                    

                                       scene.ID = ( (mode & SCENE_COPY_MODE_ALL_BIT) ? sceneList[i] : sceneIDTo );

                                      pToScene = zclGeneral_FindScene( pInMsg->msg->endPoint, groupIDTo, scene.ID );                  

                                    if( pToScene != NULL )                  

                                    {                    

                                             zclGeneral_RemoveScene( pInMsg->msg->endPoint, groupIDTo, scene.ID );                  

                                     }                  

                                   // Add the scene                  

                              zclGeneral_AddScene( pInMsg->msg->endPoint, &scene );    

                                 //bug fix               

                                if ( mode & SCENE_COPY_MODE_ALL_BIT )//restore the groupid from                         

                                        scene.groupID = tmpgroupIDFrom;                

                             }              

              }            

}            

else

.......

........

}

 

Kindly confirm the bug fix.

 

Thanks and Regards

Lakshman,PMP,PMI-RMP


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>