This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Adding a second model to the example: Publish adress handle not set.

Hi guys,

I'm adding my own 'hello world' model to the example on element 0.

For this i've implemented a simple model;

Client sends 'Set Unreliable' with char[20] value.

Server receives and outputs this in the terminal (Segger embedded studio).

I've however encounterd a problem, i get a MESH_ASSERT and traced the problem to the following;

static bool check_tx_params(access_model_handle_t handle, const access_message_tx_t * p_tx_message, const access_message_rx_t * p_rx_message, uint32_t * p_status)
{
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "check_tx_params publish Adress_handle: %x, model_id: %d", m_model_pool[handle].model_info.publish_address_handle, m_model_pool[handle].model_info.model_id);
    NRF_MESH_ASSERT(NULL != p_status);
    if (p_tx_message->length >= ACCESS_MESSAGE_LENGTH_MAX)
    {
        *p_status = NRF_ERROR_INVALID_LENGTH;
    }
    else if (!model_handle_valid_and_allocated(handle) ||
             m_model_pool[handle].model_info.element_index >= ACCESS_ELEMENT_COUNT)
    {
        *p_status = NRF_ERROR_NOT_FOUND;
    }
    else if ((p_rx_message == NULL &&
              (m_model_pool[handle].model_info.publish_appkey_handle  == DSM_HANDLE_INVALID ||
               m_model_pool[handle].model_info.publish_address_handle == DSM_HANDLE_INVALID)) ||
             !is_valid_opcode(p_tx_message->opcode))
    {
        *p_status = NRF_ERROR_INVALID_PARAM;
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, (p_rx_message == NULL ? "<TRUE && \n" : "<FALSE && \n"));        
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, (m_model_pool[handle].model_info.publish_appkey_handle  == DSM_HANDLE_INVALID ? "TRUE || \n" : "FALSE || \n"));        
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, (m_model_pool[handle].model_info.publish_address_handle == DSM_HANDLE_INVALID ? "TRUE> || \n" : "FALSE> || \n"));
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, (!is_valid_opcode(p_tx_message->opcode) ? "TRUE\n" : "FALSE\n"));
    }

the output shows;

<t:     483632>, XXX.c,  109, XXX_client_set_unreliable
<t:     483635>, XXX.c,  126, XXX_client_set_unreliable In loop b4 publish
<t:     483638>, access.c, 1034, acces_model_publish()
<t:     483640>, access.c,  371, packet_tx
<t:     483642>, access.c,  351, <TRUE && 
<t:     483644>, access.c,  352, FALSE || 
<t:     483646>, access.c,  353, TRUE> || 
<t:     483648>, access.c,  354, FALSE
<t:     483650>, access.c,  375, Invalid param
<t:     483652>, nrf_mesh_sdk.c,   72, APP_ERROR: XXX\nrf5_SDK_for_Mesh_v1.0.1_src\examples\light_switch - Copy\client\src\main.c:448 code 7

Which tells me that m_model_pool[handle].model_info.publish_address_handle Is not being set.

Something in my client/server configuration is off...

Any ideas on where this is set exactly or where this could go wrong?

My first gues is it doesn't receive the publish addr from the server correctly, the infocenter saids:

NRF_ERROR_INVALID_PARAM Model not bound to appkey, publish address not set or wrong opcode format.

Also the infocenter has no articles (or i haven't found them) on how to setup the configuration - a small tutorial on how to set a model's configuration correctly would be usefull.

Parents
  • Hi,

     

    Did you follow this howto in the mesh docs when creating your own model?

    http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.meshsdk.v1.0.1/md_doc_getting_started_how_to_models.html?cp=4_1_0_3_4

     

    When you updated your code with the configuration from on/off server, did you get different behavior?

     

    Best regards,

    Håkon

  • Hi, thanks for your response!

    I did, however nowhere is described how to properly use the provisioner/configuration in the example.

    The example itself is still working fine.

    The on/off example uses a mechanism to add several servers to the clients and im now trying to figure out how to add my own model properly.

    Basically it comes down to the fact that i don't know how to do these parts;

    void provisioner_config_successful_cb(void)
    {
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Configuration of device %u successful\n", m_configured_devices);
    
        /* Set publish address for the client to the corresponding server. */
        ERROR_CHECK(access_model_publish_address_set(m_clients[m_configured_devices].model_handle,
                                                     m_server_handles[m_configured_devices]));
        
        //@TODO add own model here
    
        access_flash_config_store();
    
        hal_led_pin_set(BSP_LED_0 + m_configured_devices, false);
        m_configured_devices++;
    
        if (m_configured_devices < SERVER_COUNT)
        {
            provisioner_wait_for_unprov(UNPROV_START_ADDRESS + m_provisioned_devices);
            hal_led_pin_set(BSP_LED_0 + m_configured_devices, true);
        }
        else
        {
            __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "All servers provisioned\n");
            hal_led_blink_ms(LEDS_MASK, 100, 4);
        }
    }
    
    void provisioner_prov_complete_cb(const nrf_mesh_prov_evt_complete_t * p_prov_data)
    {
        /* We should not get here if all servers are provisioned. */
        NRF_MESH_ASSERT(m_configured_devices < SERVER_COUNT);
    
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Provisioning complete. Adding address 0x%04x.\n", p_prov_data->address);
    
        /* Add to local storage. */
        ERROR_CHECK(dsm_address_publish_add(p_prov_data->address, &m_server_handles[m_provisioned_devices]));
        ERROR_CHECK(dsm_devkey_add(p_prov_data->address, m_netkey_handle, p_prov_data->p_devkey, &m_devkey_handles[m_provisioned_devices]));
    
        //@TODO add own model to local storage and bind client/config.
    
        /* Bind the device key to the configuration server and set the new node as the active server. */
        ERROR_CHECK(config_client_server_bind(m_devkey_handles[m_provisioned_devices]));
        ERROR_CHECK(config_client_server_set(m_devkey_handles[m_provisioned_devices],
                                             m_server_handles[m_provisioned_devices]));
    
        m_provisioned_devices++;
    
        /* Move on to the configuration step. */
        provisioner_configure(UNPROV_START_ADDRESS + m_configured_devices);
    }

    I bound my client/server to element 0.

    I can publish server -> client fine, but a client -> server publish gives the invalid param error.

  • @sommmen I have the same problem. Code is written as in your example above. How did fix this?

  • at the time i was using the mesh sdk v1.0.1 and my answer fixed it - the config wasn't right. are you using the sdk v2.0.1? anyways - make sure that you configure the model correctly

  • also; if you open a second ticket with more information Nordic staff will help you out (they're quire responsive) and if you linkit here i'll also take a look.

  • config? You mean the do_config_step() method?

  • no in main.c. also please open a new issue.

Reply Children
No Data
Related