How to set TTL value for a model from the application

How set TTL value for a model from the application?
According to the documentation we can use access_model_publish_ttl_set() and access_model_publish_ttl_get().

Whenever I use access_model_publish_ttl_get(), the TTL value reutrun by this function is 255.

From the Mesh Application I have set this to 10. I should this get value instead of this I am getting 255.

I am using Sensor server example.

This is how I use it in the application:

access_model_handle_t p_handle;
uint8_t ttl;

access_model_publish_ttl_get(p_handle,&ttl);

__LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "TTL value is : %d\n",ttl);

This how I set the TTL value value from the Mesh Application:

One thing I am little confuse about it is that:
Is my p_handle parameter is correct ? 
How would I know which model I am referring to.

Or there is any other public APIs available for the application to use to change the TTL value for the server node?
Thanks

  • Hi,

    Is my p_handle parameter is correct ? 

    The way you've initialized the access_model_handle_t p_handle seems to be wrong. Doing it this way, you will most likely get NRF_ERROR_NOT_FOUND as the return value and that p_ttl points to 0xFF (i.e access_model_publish_ttl_get() returns 255 / 0xFF). 

    You will need to store the model_handler from when you create the model. You can see how this is done in the Sensor server-example in nRF5 SDK for Mesh v5.0.0. Here the model handler for the sensor server is in a global variable in main.c (a struct within a struct), so you can use it in main() as "m_sensor_server0.server.model_handle" (which should be what you can use in your sample as well)

    See infocenter.nordicsemi.com/index.jsp
    Nordic Semiconductor Infocenter

    Let me know if this ansewers your question

    Kind regards,
    Andreas

  • Thanks for the reply.

            access_model_handle_t p_handle;
            p_handle = m_sensor_server_0.server.sensor_srv.model_handle;
            uint8_t ttl;
            
            error_coe = access_model_publish_ttl_get(p_handle,&ttl);
    
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "TTL value is : %d\n",ttl);
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Button Even't Expired\n");


    This worked for me.
    To Check the TTL value set from the Mesh Application.

    Thanks

Related