Implementing vSaveScenesNVM() saving scences to PDM for a multi endpoint device

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Implementing vSaveScenesNVM() saving scences to PDM for a multi endpoint device

457 次查看
dmsherazi
Contributor IV

I am working with JN5189. Using the JN-AN-1247 as my base device. I have added 3 more endpoints with LightOn/Off devices on it. I might also add temp and humidity sensor related clusters on it as well in near future.

In order to implement scenes on it I have followed JN-AN-1244 for the file of app_scene .c/.h.  I am a bit confused here as all over I am seeing implementation of this for one endpoint. What I need is to implemnet it for multiple endpoints

 

How to Implemnet the code below to handle the saving of the scene to the PDM for all endponints and all devices. For example I have 5 endpoints , 1 having a controlBridge device and an on_off_light and 3 other on_off_lighst on endpoint 2,3 and 4

 

/****************************************************************************
*
* NAME: vSaveScenesNVM
*
* DESCRIPTION:
* To save scenes data to EEPROM
*
* RETURNS:
* void
*
****************************************************************************/
PUBLIC void vSaveScenesNVM(void)
{
    uint8 i=0, j=0;
    tsCLD_ScenesTableEntry *psTableEntry;

    /* Before saving data again clear off the earlier entries and recopy all the scenes */
    memset(&sScenesCustomData,0,sizeof(tsAPP_ScenesCustomData));
    
    psTableEntry = (tsCLD_ScenesTableEntry*)psDLISTgetHead(&sOnOFFLight1.sScenesServerCustomDataStructure.lScenesAllocList);
    
    for(i = 0; i < iDLISTnumberOfNodes(&sOnOFFLight1.sScenesServerCustomDataStructure.lScenesAllocList); i++)
    {
        if(psTableEntry != NULL)
        {
             sScenesCustomData.asScenesCustomTableEntry[j].bIsSceneValid = TRUE;
              sScenesCustomData.asScenesCustomTableEntry[j].u16GroupId = psTableEntry->u16GroupId;
              sScenesCustomData.asScenesCustomTableEntry[j].u8SceneId = psTableEntry->u8SceneId;
             sScenesCustomData.asScenesCustomTableEntry[j].u16TransitionTime = psTableEntry->u16TransitionTime;
             sScenesCustomData.asScenesCustomTableEntry[j].u16SceneDataLength = psTableEntry->u16SceneDataLength;
             memcpy(sScenesCustomData.asScenesCustomTableEntry[j].au8SceneData,psTableEntry->au8SceneData,psTableEntry->u16SceneDataLength);
              #ifdef CLD_SCENES_TABLE_SUPPORT_TRANSITION_TIME_IN_MS
                     sScenesCustomData.asScenesCustomTableEntry[j].u8TransitionTime100ms = psTableEntry->u8TransitionTime100ms;
              #endif
              j++;
        }
        psTableEntry = (tsCLD_ScenesTableEntry*)psDLISTgetNext((DNODE*)psTableEntry);
    }

    PDM_eSaveRecordData(PDM_ID_APP_SCENES_DATA,&sScenesCustomData,sizeof(tsAPP_ScenesCustomData));
}

 

 

0 项奖励
回复
1 回复

413 次查看
EduardoZamora
NXP TechSupport
NXP TechSupport

Hello @dmsherazi,

Function vSaveScenesNVM() should extract the scenes from the endpoint structure and copy them into NVM; you should be able to do a custom implementation to provide this function a device/endpoint at a time. For more information, please consult JN-UG-3133-Core-Utilities, Chapter 6 PDM API.

Regards,
Eduardo.

0 项奖励
回复