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

Send uint8_t array over bluetooth mesh (beginner)

hello

Im trying to send a small array with two integers over bluetooth mesh

    uint32_t error_code;
    uint8_t var1 = 0;
    uint8_t var2 = 0;
    
    const uint8_t payload[2] = {var1, var2};
    
    simple_on_off_server_t * p_server = p_args;
    access_message_tx_t reply;
    reply.opcode.opcode = RECEIVE_RESPONSE;
    reply.opcode.company_id = ACCESS_COMPANY_ID_NORDIC;
    reply.p_buffer =(const uint8_t *)&payload;
 
    reply.force_segmented = false;
    reply.length = sizeof(payload);
    error_code = access_model_publish(p_server->model_handle, &reply);

but Im getting error code 7 invalid params..

how should I send an array like this? and why is this way wrong?

thanks in advance

  • Hi,

    It may be because not all the fields of the access_message_tx_t reply is set. You miss access_token (which is not important, you could set it to 0) and transmic_size (for which NRF_MESH_TRANSMIC_SIZE_DEFAULT should do.)

    See the access_model_publish() documentation for other reasons why the return value may be NRF_INVALID_PARAM.

    Regards,
    Terje

  • I dont know...sending an array with chars like this:

    uint32_t error_code;
        
        uint8_t array[8];
        sprintf(array, "%u", nbr_of_packets);
        simple_on_off_server_t * p_server = p_args;
        access_message_tx_t reply;
        reply.opcode.opcode = RECEIVE_RESPONSE;
        reply.opcode.company_id = ACCESS_COMPANY_ID_NORDIC;
        reply.p_buffer =(const uint8_t *)&array;
     
        reply.force_segmented = false;
        reply.length = sizeof(array);
        error_code = access_model_publish(p_server->model_handle, &reply);
        __LOG(LOG_SRC_APP, LOG_LEVEL_INFO,"ERROR CODE: 0x%0x Message sent: %s \n",error_code, reply.p_buffer);

    works fine, no need to set other params here..

    the nbr_of_packets is an uint16_t by the way

  • Hi,

    I must admit I cannot imagine what would be the difference between those two, apart from the length of the reply message, and a shorter one should not really differ.

    Do you have a minimal example that I can use to reproduce this? I.e. either a full project, or a main file that replaces that of an existing example, that includes the offending code (so that I can try a debug session here.) If I am able to reproduce it here then I can do some debugging.

    I also encourage you to do a debug session in your end, putting breakpoints and perhaps debug log messages in the call to access_model_publish() and deeper down the call chain, for locating what check fails (and then why).

    Regards,
    Terje

Related