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.

LAUNCHXL-CC26X2R1: Save Req.maxReportInt in nv

Part Number: LAUNCHXL-CC26X2R1
Other Parts Discussed in Thread: SYSCONFIG

Hello,

I want when I change the max report, to save it in the nv memory so I can restore it in the case my device resets

I tried this in the zclSampleLight_Init(  ):

osal_nv_item_init(ZCD_NV_BDBREPORTINGCONFIG, 2, NULL);
osal_nv_read(ZCD_NV_BDBREPORTINGCONFIG, 0, 2, &Req.maxReportInt);
if(Req.maxReportInt == 0x0000){
    Req.maxReportInt = 20;
}
Zstackapi_bdbRepAddAttrCfgRecordDefaultToListReq(appServiceTaskId,&Req);

but for some reason sometimes maxReportInt decreases by 1

  • Hello Panagiotis,

    I do not recommend initializing ZCD_NV_BDBREPORTINGCONFIG with a length of two as this is not the size of bdbReportAttrCfgData_t.  Please follow the example of bdb_RepInitAttrCfgRecords/bdb_RepLoadCfgRecords or consider using a custom NV item to store the max reporting interval.

    Regards,
    Ryan

  • I have created a custom nv item: ZCD_NV_MAX_REPORT = 0x0401 in zcomdef.h, and have added an osal_nv_write in bdb_RepProcessEvent( ) but it returns NV_ITEM_UNINIT.

    osal_nv_item_init and osal_nv_read return success.

    void bdb_RepProcessEvent( void )
    {
      bdb_clusterEndpointArrayIncrementAll( bdb_reportingNextEventTimeout, BDBREPORTING_FALSE );
      uint8_t minIndex =  bdb_clusterEndpointArrayGetMin( );
      if( minIndex == BDBREPORTING_INVALIDINDEX )
      {
        return;
      }
     
      osal_nv_write(ZCD_NV_MAX_REPORT, 2, &bdb_reportingClusterEndpointArray[minIndex].consolidatedMaxReportInt); //added line
    
       uint16_t minVal = bdb_reportingClusterEndpointArray[minIndex].consolidatedMaxReportInt - bdb_reportingClusterEndpointArray[minIndex].timeSinceLastReport;
       if( minVal>0 )
       ........

  • I want to make a correction on the previous post. When I defined ZCD_NV_MAX_REPORT as 0x0401, the osal_nv_write returned NV_OPER_FAILED. When I defined it as 0x0005 it returned NV_ITEM_UNINIT

  • You will need to create the custom NV memory before writing/reading.  Please refer to the Application Non-Volatile Memory section of the Z-Stack User's Guide for further instructions.

    Regards,
    Ryan

  • I changed from osal_nv_.... to zclport_initializeNVItem/readNV/writeNV I also followed the instructions to increase the NVOCMP_NVPAGES size to 3 which should cover my custom nv item id, but now I cannot join a network. I haven't made any other changes and I made a new project to make sure that I didn't do anything else. In debug the read and write of the nv is successfull

  • You should not need to increase NVOCMP_NVPAGES just for the custom ID, but if done then you must also make sure to modify the Region Base and Size inside of SysConfig -> NVS -> CONFIG_NVSINTERNAL.  You must also make sure to erase all NV memory before reprogramming.  You may want to check with a new example and closely follow the doorlock example as it also uses custom NV IDs and has been verified to operate as expected.

    Regards,
    Ryan

  • I reverted the nv pages back to two and noticed that osal_nv_init() wasn't used, so I put in main and now everything works with the osal_nv commands.

    Thank you for your help!!