<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>mesh_config_entry_get()/mesh_config_entry_set() are not working as expected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58545/mesh_config_entry_get-mesh_config_entry_set-are-not-working-as-expected</link><description>Hi all, 
 I am developing on nRF Mesh SDK 4.0.0 with nRF52833 DK (PCA10100). 
 To save/restore persistent model state to flash, I added the code using mesh_config_entry_get()/mesh_config_set() functions as below. 
 
 1. I added mesh_config_entry_get(</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Mar 2020 04:32:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58545/mesh_config_entry_get-mesh_config_entry_set-are-not-working-as-expected" /><item><title>RE: mesh_config_entry_get()/mesh_config_entry_set() are not working as expected</title><link>https://devzone.nordicsemi.com/thread/237594?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2020 04:32:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bcdf868-96f1-4812-bcfe-4e28253534c6</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;I found what is the problem.&lt;/p&gt;
&lt;p&gt;my model_config_load() call is too early in model_init_cb(), so it failed.&lt;/p&gt;
&lt;p&gt;And also I figured out that mesh_config_load() automatically includes loading each of my custom entries.&lt;/p&gt;
&lt;p&gt;So, because mesh_config_load(0 will call getter/setter for my entries, I added memcpy() inside getter/setter, even it seems to be redundant.&lt;/p&gt;
&lt;p&gt;After then, it works fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: mesh_config_entry_get()/mesh_config_entry_set() are not working as expected</title><link>https://devzone.nordicsemi.com/thread/237538?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2020 16:56:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:436b71b0-c750-4d2a-9d7f-74a9d1e0e291</guid><dc:creator>choehyunho</dc:creator><description>&lt;p&gt;I followed the emocean example.&lt;/p&gt;
&lt;p&gt;Below is my code for declaring &amp;amp; getting entries.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#define LOCATION_FILE_ID                (0x0010)
#define GLOBAL_LOCATION_RECORD          (0x0001)
#define LOCAL_LOCATION_RECORD           (0x0002)
#define GLOBAL_LOCATION_ENTRY_ID        MESH_CONFIG_ENTRY_ID(LOCATION_FILE_ID, GLOBAL_LOCATION_RECORD)
#define LOCAL_LOCATION_ENTRY_ID         MESH_CONFIG_ENTRY_ID(LOCATION_FILE_ID, LOCAL_LOCATION_RECORD)

MESH_CONFIG_FILE(m_location_file, LOCATION_FILE_ID, MESH_CONFIG_STRATEGY_CONTINUOUS);

static uint32_t global_location_setter(mesh_config_entry_id_t id, const void * p_entry);
static void global_location_getter(mesh_config_entry_id_t id, void * p_entry);
static void global_location_deleter(mesh_config_entry_id_t id);
static uint32_t local_location_setter(mesh_config_entry_id_t id, const void * p_entry);
static void local_location_getter(mesh_config_entry_id_t id, void * p_entry);
static void local_location_deleter(mesh_config_entry_id_t id);

MESH_CONFIG_ENTRY(global_location,
                  GLOBAL_LOCATION_ENTRY_ID,
                  1,
                  sizeof(generic_location_global_status_params_t),
                  global_location_setter,
                  global_location_getter,
                  global_location_deleter,
                  false);

MESH_CONFIG_ENTRY(local_location,
                  LOCAL_LOCATION_ENTRY_ID,
                  1,
                  sizeof(generic_location_local_status_params_t),
                  local_location_setter,
                  local_location_getter,
                  local_location_deleter,
                  false);

static generic_location_global_status_params_t m_location_global =
{
    .global_latitude = 0x80000000,
    .global_longitude = 0x80000000,
    .global_altitude = 0x7FFF,
};

static generic_location_local_status_params_t m_location_local =
{
    .local_north = 0x8000,
    .local_east = 0x8000,
    .local_altitude = 0x7FFF,
    .floor_number = 0xFF,
    .uncertainty = 0x0000,
};

static uint32_t global_location_setter(mesh_config_entry_id_t id, const void * p_entry)
{
    return NRF_SUCCESS;
}

static void global_location_getter(mesh_config_entry_id_t id, void * p_entry)
{
}

static void global_location_deleter(mesh_config_entry_id_t id)
{
    m_location_global.global_latitude = 0x80000000;
    m_location_global.global_longitude = 0x80000000;
    m_location_global.global_altitude = 0x7FFF;
}

static uint32_t local_location_setter(mesh_config_entry_id_t id, const void * p_entry)
{
    return NRF_SUCCESS;
}

static void local_location_getter(mesh_config_entry_id_t id, void * p_entry)
{
}

static void local_location_deleter(mesh_config_entry_id_t id)
{
    m_location_local.local_north = 0x8000;
    m_location_local.local_east = 0x8000;
    m_location_local.local_altitude = 0x7FFF;
    m_location_local.floor_number = 0xFF;
    m_location_local.uncertainty = 0x0000;
}

static void model_config_load(void)
{
    mesh_config_entry_id_t idx = GLOBAL_LOCATION_ENTRY_ID;
    uint32_t status = mesh_config_entry_get(idx, &amp;amp;m_location_global);
    if (status == NRF_SUCCESS)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Load global location: 0x%08X,0x%08X,0x%04X\n&amp;quot;,
              m_location_global.global_latitude, m_location_global.global_longitude, m_location_global.global_altitude);
    }
    idx = LOCAL_LOCATION_ENTRY_ID;
    status = mesh_config_entry_get(idx, &amp;amp;m_location_local);
    if (status == NRF_SUCCESS)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Load local location: 0x%04X,0x%04X,0x%04X,0x%02X,0x%04X\n&amp;quot;,
              m_location_local.local_north, m_location_local.local_east, m_location_local.local_altitude,
              m_location_local.floor_number, m_location_local.uncertainty);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And used the following code to set entries.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    // Save to configuration entry
    {
        mesh_config_entry_id_t entry_id = GLOBAL_LOCATION_ENTRY_ID;
        uint32_t status = mesh_config_entry_set(entry_id, &amp;amp;m_location_global);
        if (status == NRF_SUCCESS)
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Save global location: 0x%08X,0x%08X,0x%04X\n&amp;quot;,
                  m_location_global.global_latitude, m_location_global.global_longitude, m_location_global.global_altitude);
        }
    }
...
    // Save to configuration entry
    {
        mesh_config_entry_id_t entry_id = LOCAL_LOCATION_ENTRY_ID;
        uint32_t status = mesh_config_entry_set(entry_id, &amp;amp;m_location_local);
        if (status == NRF_SUCCESS)
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, &amp;quot;Save local location: 0x%04X,0x%04X,0x%04X,0x%02X,0x%04X\n&amp;quot;,
                  m_location_local.local_north, m_location_local.local_east, m_location_local.local_altitude,
                  m_location_local.floor_number, m_location_local.uncertainty);
        }
    }
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I am a little bit suspicious of using getter/setter code.&lt;/p&gt;
&lt;p&gt;Because I just already have static module variable and try to share it between functions, no code is used inside getter/setter function.&lt;/p&gt;
&lt;p&gt;Can it be problem?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: mesh_config_entry_get()/mesh_config_entry_set() are not working as expected</title><link>https://devzone.nordicsemi.com/thread/237514?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2020 15:15:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5dca556-1fd0-4186-a866-cc0699d8d8bf</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Choe,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you let me know&amp;nbsp;how you define your config ID , have you followed what we did, for example in mesh_opt_provisioner.h in the light switch provisioner example ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You need to define config file using&amp;nbsp;MESH_CONFIG_FILE().&lt;/p&gt;
&lt;p&gt;Please note that you can store your data using the flash library directly by creating your own flash area outside of the mesh config area. You can call this:&amp;nbsp;mesh_stack_persistence_flash_usage() to know the mesh stack flash usage and allocate your own flash area outside of the mesh stack.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>