6 Replies Latest reply on Nov 9, 2015 7:42 PM by henryubnt

    NV Read/Write in APPLICATION_INIT()

      Hi,

      In system init we have a init code like below:

      APPLICATION_INIT()
      {
          bleapp_set_cfg((UINT8 *)hello_sensor_gatt_database,
                         sizeof(hello_sensor_gatt_database),
                         (void *)&hello_sensor_cfg,
                         (void *)&hello_sensor_puart_cfg,
                         (void *)&hello_sensor_gpio_cfg,
                         hello_sensor_create);
      }
      

       

      Is there any side effect if we want to read/write NV item in APPLICATION_INIT() ?

       

      Pseudo code like below:

      APPLICATION_INIT()
      {
        UINT8 databyte;
        databyte = bleprofile_ReadNVRAM(NVRAM_ID_HOST_LIST, sizeof(hello_sensor_hostinfo), (UINT8 *)&hello_sensor_hostinfo);
        if (databyte == 0) {
        //Write initial 0 to the NVs and use another data base
      ...............
        databyte = bleprofile_WriteNVRAM(NVRAM_ID_HOST_LIST, sizeof(hello_sensor_hostinfo), (UINT8 *)&hello_sensor_hostinfo);
        bleapp_set_cfg((UINT8 *)hello_sensor_gatt_database2,
          sizeof(hello_sensor_gatt_database2),
          (void *)&hello_sensor_cfg2,
          (void *)&hello_sensor_puart_cfg,
          (void *)&hello_sensor_gpio_cfg,
          hello_sensor_create);
        }
        else {
        bleapp_set_cfg((UINT8 *)hello_sensor_gatt_database,
          sizeof(hello_sensor_gatt_database),
          (void *)&hello_sensor_cfg,
          (void *)&hello_sensor_puart_cfg,
          (void *)&hello_sensor_gpio_cfg,
          hello_sensor_create);
          }
      }
      

       

      Please kindly give a suggestion, thanks.