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.

Z -Stack Lighting AddScene: SceneRecall bug fix

Other Parts Discussed in Thread: PMP

Dear TI,

As we know for addscene command and enhancedAddScene command we use the below structure

  uint16 groupID;                   // The group ID for which this scene applies  

   uint8 ID;                         // Scene ID  

   uint16 transTime;                 // Time to take to transition to this scene  

   uint16 transTime100ms;            // Together with transTime, this allows transition time to be specified in 1/10s  

   uint8 name[ZCL_GEN_SCENE_NAME_LEN]; // Scene name

   uint8 extLen;                     // Length of extension fields  

   uint8 extField[ZCL_GEN_SCENE_EXT_LEN]; // Extension fields

 

There is a difference between the AddScene and EnhancedAddScene.

In the AddScene, the extLen will be

   // The length of the extension field(s) is 17:    

//   2 + 1 + 1 for On/Off cluster (onOff attibute)    

//   2 + 1 + 1 for Level Control cluster (currentLevel attribute)    

 //   2 + 1 + 6 for Color Control cluster (CurrentHue/CurrentSaturation/currentX/currentY

In the EnhancedAddScene, the extLen will be

// The length of the extension field(s) is 23:    

//   2 + 1 + 1 for On/Off cluster (onOff attibute)    

//   2 + 1 + 1 for Level Control cluster (currentLevel attribute)   

//   2 + 1 + 12 for Color Control cluster (CurrentHue/CurrentSaturation/currentX/currentY/EnhancedCurrentHue/colorLoopActive/colorLoopDirection/colorLoopTime attributes)

Once we send the AddScene Command (after assigning Groupid ,sceneid,hue value ,saturation value ,current x and current y value) and press scene recall command in the remote. we wont be able to see the change in the sample light color.

when we step thru the sample light code. we find that the

static void zllSampleLight_SceneRecallCB( zclSceneReq_t *pReq )

 {

.........

.....

else if ( clusterID == ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL )    

{

    if ( len == 12 )// Update currentX and currentY attributes with the recalled values      

{

#ifdef ZCL_COLOR_CTRL        

uint8  newCurrentHue, newCurrentSaturation;        

uint16 newCurrentX, newCurrentY, newEnhancedCurrentHue;        

 zclCCColorLoopSet_t newColorLoopSetCmd = {0};

        newCurrentHue = *pExt++;        

       newCurrentSaturation = *pExt++;        

        newCurrentX = BUILD_UINT16( pExt[0], pExt[1] );        

        pExt += 2;        

        newCurrentY = BUILD_UINT16( pExt[0], pExt[1] );        

         pExt += 2;

.....

 ......

}

 The above code only works for enhancedAddScene. It wont work for AddScene.

we need to check for len == 6  to cover the AddScene scenario

static void zllSampleLight_SceneRecallCB( zclSceneReq_t *pReq )

{

...........

.......

 else if ( clusterID == ZCL_CLUSTER_ID_LIGHTING_COLOR_CONTROL )    

{      

                   if( len == 6)//--laksh bug fix TI for add_scene extension field.      

                    {  

#ifdef ZCL_COLOR_CTRL        

                      uint8  newCurrentHue, newCurrentSaturation;        

                      uint16 newCurrentX, newCurrentY;        

                                newCurrentHue = *pExt++;        

                               newCurrentSaturation = *pExt++;        

                                newCurrentX = BUILD_UINT16( pExt[0], pExt[1] );        

                                   pExt += 2;        

                                newCurrentY = BUILD_UINT16( pExt[0], pExt[1] );        

                                 pExt += 2;        

                    if ( zclColor_ColorMode == COLOR_MODE_CURRENT_HUE_SATURATION )        

                    {              

                                zclCCMoveToHueAndSaturation_t cmd;                

                                cmd.hue = newCurrentHue;                

                               cmd.saturation = newCurrentSaturation;                

                               cmd.transitionTime = 0; //0 for now, need to use transition time                

                               zclColor_MoveToHueAndSaturationCB( &cmd );                           

                               //restore x,y attributes values              

                               zclColor_CurrentX = newCurrentX;              

                               zclColor_CurrentY = newCurrentY;        

                    }        

                    else        

                   {              

                               zclCCMoveToColor_t colorCmd;                  

                               colorCmd.colorX = newCurrentX;              

                               colorCmd.colorY = newCurrentY;              

                                colorCmd.transitionTime = 0; //0 for now, need to use transition time                  

                                zclColor_MoveToColorCB( &colorCmd );               //restore hue,sat attributes values              

                                zclColor_CurrentHue = newCurrentHue;              

                               zclColor_CurrentSaturation = newCurrentSaturation;        

                       }

#endif              

               }      

                    else if ( len == 12 )// Update currentX and currentY attributes with the recalled values      

                          {

 #ifdef ZCL_COLOR_CTRL        

                                 uint8  newCurrentHue, newCurrentSaturation; 

                                 uint16 newCurrentX, newCurrentY, newEnhancedCurrentHue;        

                                 zclCCColorLoopSet_t newColorLoopSetCmd = {0};

                                  newCurrentHue = *pExt++;        

                                  newCurrentSaturation = *pExt++;        

                                  newCurrentX = BUILD_UINT16( pExt[0], pExt[1] );        

                                    pExt += 2;        

                                  newCurrentY = BUILD_UINT16( pExt[0], pExt[1] );       

                                  .................................

                                  ...................................

                                }

}

 

}//static void zllSampleLight_SceneRecallCB( zclSceneReq_t *pReq )

 

Even this fix is applicable only for Addscene with  2 + 1 + 6 for Color Control cluster (CurrentHue/CurrentSaturation/currentX/currentY.

but according to the spec . we may get

   2 + 1 + 1 for Color Control cluster (CurrentHue)

    2 + 1 + 2 for Color Control cluster (CurrentHue/CurrentSaturation)

    2 + 1 + 4 for Color Control cluster (CurrentHue/CurrentSaturation/currentX/)

Need to cover all the scenario's in recallscene something like

 switch(len)      

{      

case 1:       //CurrentHue 

break;      

case 2:    //CurrentHue/CurrentSaturation    

break;      

case 4:// CurrentHue/CurrentSaturation/currentX       

break;      

case 6://CurrentHue/CurrentSaturation/currentX/currentY        

break;      

case 8:        

break;

case 10:

break

case 12://CurrentHue/CurrentSaturation/currentX/currentY/colorLoopActive/colorLoopDirection/colorLoopTime attributes

break;

}

From the cluster library spec "

Extension field sets = {{ClusterID 1, length 1, {extension field set 1}}, {ClusterID 2, length 2, {extension field set 2}}, ... }. The attributes included in the extension field set for each cluster are defined in the specification for that cluster in this document (the ZigBee Cluster Library). The field set consists of values for these attributes concatenated together, in the order given in the cluster specification, with no attribute identifiers or data type indicators. For forward compatibility, reception of this command shall allow for the possible future addition of other attributes to the trailing ends of the lists given in the cluster specifications (by ignoring them). Similarly, it shall allow for one or more attributes to be omitted from the trailing ends of these lists (see 3.7.2.4.6.2).

"

 

Please correct me if i am wrong. kindly confirm the fix.

 

Thanks and Regards

Lakshman,PMP,PMI-RMP