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
  • Update:

    I copied the configuration code from the on/off server:

            case PROV_STATE_CONFIG_PUBLICATION_XXX:
            {
                /* also configure XXX @TODO move to own state */
                config_publication_state_t pubstate2 = {0};
                pubstate2.element_address = m_target_address;
                pubstate2.publish_address.type = NRF_MESH_ADDRESS_TYPE_UNICAST;
                pubstate2.publish_address.value = PROVISIONER_ADDRESS;//PROVISIONER_ADDRESS + m_target_address - UNPROV_START_ADDRESS; //@TODO what should this be?
                pubstate2.appkey_index = 0;
                pubstate2.frendship_credential_flag = false;
                pubstate2.publish_ttl = SERVER_COUNT;
                pubstate2.publish_period.step_num = 0;
                pubstate2.publish_period.step_res = ACCESS_PUBLISH_RESOLUTION_100MS;
                pubstate2.retransmit_count = 1;
                pubstate2.retransmit_interval = 0;
                pubstate2.model_id.company_id = ACCESS_COMPANY_ID_NORDIC;
                pubstate2.model_id.model_id = XXX_SERVER_MODEL_ID;
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting publication address for the XXX server to 0x%04x\n", pubstate2.publish_address.value);
    
                ERROR_CHECK(config_client_model_publication_set(&pubstate2));          
    
                break;
            }

Reply
  • Update:

    I copied the configuration code from the on/off server:

            case PROV_STATE_CONFIG_PUBLICATION_XXX:
            {
                /* also configure XXX @TODO move to own state */
                config_publication_state_t pubstate2 = {0};
                pubstate2.element_address = m_target_address;
                pubstate2.publish_address.type = NRF_MESH_ADDRESS_TYPE_UNICAST;
                pubstate2.publish_address.value = PROVISIONER_ADDRESS;//PROVISIONER_ADDRESS + m_target_address - UNPROV_START_ADDRESS; //@TODO what should this be?
                pubstate2.appkey_index = 0;
                pubstate2.frendship_credential_flag = false;
                pubstate2.publish_ttl = SERVER_COUNT;
                pubstate2.publish_period.step_num = 0;
                pubstate2.publish_period.step_res = ACCESS_PUBLISH_RESOLUTION_100MS;
                pubstate2.retransmit_count = 1;
                pubstate2.retransmit_interval = 0;
                pubstate2.model_id.company_id = ACCESS_COMPANY_ID_NORDIC;
                pubstate2.model_id.model_id = XXX_SERVER_MODEL_ID;
                __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Setting publication address for the XXX server to 0x%04x\n", pubstate2.publish_address.value);
    
                ERROR_CHECK(config_client_model_publication_set(&pubstate2));          
    
                break;
            }

Children
No Data
Related