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

vendor-specific model parameter size

Hey, can I use a complex structure (for example byte array ) as a message parameter instead of one byte like it is done in http://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.meshsdk.v2.0.1%2Fmd_scripts_interactive_pyaci_doc_demo_configuration.html&cp=4_1_0_2_0_2  ?

what is allowed to use as a message parameter in vendor specific model ?

  • Hi, 

    Which function are you asking about ? Is it the set command of the simple on off client ? 

  • no my Idea is that the server has an array of numbers for example unit16_t [] list;  and i what with the client get this list via get command from the server.  The server replies with a "statis-list" . Which size is allowed for this replay message ?

    I changed the simple OnOFF model to be able to send an array, but don't know whether it is allowed.

    static void handle_get_cb(access_model_handle_t handle, const access_message_rx_t * p_message, void * p_args)
    {
        neighbours_server_t * p_server = p_args;
        NRF_MESH_ASSERT(p_server->get_cb != NULL);
        reply_status(p_server, p_message, p_server->get_cb(p_server));
    }
    
    
    static void reply_status(const neighbours_server_t * p_server,
                             const access_message_rx_t * p_message,
                             uint16_t [] present_neighbours)
    {
        neighbours_msg_status_t status;
        status.present_neighbours = present_neighbours;
        access_message_tx_t reply;
        reply.opcode.opcode = NEIGHBOURS_OPCODE_STATUS;
        reply.opcode.company_id = NEIGHBOURS_COMPANY_ID;
        reply.p_buffer = (const uint8_t *) &status;
        reply.length = sizeof(status);
        reply.force_segmented = false;
        reply.transmic_size = NRF_MESH_TRANSMIC_SIZE_DEFAULT;
        reply.access_token = nrf_mesh_unique_token_get();
    
        (void) access_model_reply(p_server->model_handle, p_message, &reply);
    }

  • Hi, 

    You need to define exactly how big your uint16 array is. It's allowed to have more than 1 byte. You just need to state the correct length (reply.length)  of the data and the pointer to the data (reply.p_buffer). If the packet is less than 11 bytes, the stack will send in one packet. If it's more than 11 bytes the stack will automatically split it in to several segmented packet. 

    Make sure on the client side you also can handle more than 1 byte. (This should be done in the model)

Related