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

sending ASCII bytes through Mesh between a nrf52840 development kit and two dongle

Hello everyone,

I am new and tried some example on the nrf52840 devkit and dongle, including light switch example. 

I am now going to send some ASCII bytes through the mesh between three boards and receive a verification message in the client side.

Actually I thought this is done by adding  sent and receive functions in the switch light example (server and client) inside the main.c. But after searching the devzone I was completely confused.

I read these discussions but I could not modify the code correctly.

https://devzone.nordicsemi.com/f/nordic-q-a/29836/send-and-receive-a-string-via-access-layer

https://devzone.nordicsemi.com/f/nordic-q-a/31256/receiving-simple-message-mesh/123576

https://devzone.nordicsemi.com/f/nordic-q-a/39629/how-to-send-data-to-all-node-over-mesh

https://devzone.nordicsemi.com/f/nordic-q-a/47611/sending-data-over-the-mesh-network

https://devzone.nordicsemi.com/f/nordic-q-a/46092/send-string-in-a-mesh-with-nrf52dk/

I have error on 

simple_message_OPCODE_SEND
and
the address_set function
and also in the server side:
status= access_model_publish(m_server.model_handle, &msg);

I think there are some different in the new version of the nRF52 SDK for mesh V.5 I used.

Could you please help me on this topic.

Thank you,

Sama

Parents
  • Hi, 

    There have been made a lot of changes and improvements from Mesh SDK v1.0.0 to v5.0.0. Unfortunately, we don't have any official examples for sending strings over mesh. The links you are referring to is a great starting point and gives you an idea of how you can do this. 

    When it comes to the error you get, can you get more details? What function gives which errors? What kinda error do you get? Can you provide some debug logs?

  • Hi,

    What I did is:

    copy the simple message model inside the vendor folder where there is the simple on-off model.

    add a new folder in the project file in the switch light client SES and add simple on-off and simple message models.

    add ../../../../../../models\vendor\simple_message\include and ../../../../../../models\vendor\simple_on_off\include to the User Include Directories field.

    add this code in the main.c in line 248 (switch(button_number)
    {
    case 1:
    case 3:
    set_params.on_off = APP_STATE_ON;)

    void send_my_message (void)
    {
    uint32_t status=0;
    uint8_t buffer[5]="Hello";
    uint8_t length;
    uint16_t address;
    access_message_tx_t msg;
    length= sizeof(buffer);
    if (length)
    {
    msg.opcode.opcode = simple_message_OPCODE_SEND;
    msg.opcode.company_id = 0x0059; // Nordic's company ID

    msg.p_buffer = (const uint8_t *) &buffer[0];
    msg.length =length;
    address = 0xCAFE;
    address_set(address);
    SEGGER_RTT_printf(0,"Sending to group address 0x%04x\n", address);
    status= access_model_publish(m_clients[3].model_handle, &msg);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Status : %u \n", status);

    if (status == NRF_ERROR_INVALID_STATE ||
    status == NRF_ERROR_BUSY||status == NRF_ERROR_NO_MEM)
    {
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Cannot send. Device is busy.\n");
    hal_led_blink_ms(LEDS_MASK, 50, 4);
    }
    else
    {
    ERROR_CHECK(status);
    }
    }
    }

    After running I get this

    Rebuilding ‘light_switch_client_nrf52840_xxAA_s140_7.2.0’ from solution ‘light_switch_client_nrf52840_xxAA_s140_7.2.0’ in configuration ‘Debug’
    Compiling ‘main.c’
    'simple_message_OPCODE_SEND' undeclared (first use in this function)
    each undeclared identifier is reported only once for each function it appears in
    implicit declaration of function 'address_set'; did you mean 'dsm_address_get'? [-Wimplicit-function-declaration]
    implicit declaration of function 'SEGGER_RTT_printf' [-Wimplicit-function-declaration]
    Compiling ‘mesh_provisionee.c’
    Compiling ‘rtt_input.c’
    Compiling ‘simple_hal.c’
    Build failed

    In addition to this, I do not know where I should add the void address_set(uint16_t addr) which is stated in the mentioned links.

    I am a beginner and I confuse when I deal with the names of different functions I do not know where they are and what they did. 

    Thank you,

    Sama

Reply
  • Hi,

    What I did is:

    copy the simple message model inside the vendor folder where there is the simple on-off model.

    add a new folder in the project file in the switch light client SES and add simple on-off and simple message models.

    add ../../../../../../models\vendor\simple_message\include and ../../../../../../models\vendor\simple_on_off\include to the User Include Directories field.

    add this code in the main.c in line 248 (switch(button_number)
    {
    case 1:
    case 3:
    set_params.on_off = APP_STATE_ON;)

    void send_my_message (void)
    {
    uint32_t status=0;
    uint8_t buffer[5]="Hello";
    uint8_t length;
    uint16_t address;
    access_message_tx_t msg;
    length= sizeof(buffer);
    if (length)
    {
    msg.opcode.opcode = simple_message_OPCODE_SEND;
    msg.opcode.company_id = 0x0059; // Nordic's company ID

    msg.p_buffer = (const uint8_t *) &buffer[0];
    msg.length =length;
    address = 0xCAFE;
    address_set(address);
    SEGGER_RTT_printf(0,"Sending to group address 0x%04x\n", address);
    status= access_model_publish(m_clients[3].model_handle, &msg);
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Status : %u \n", status);

    if (status == NRF_ERROR_INVALID_STATE ||
    status == NRF_ERROR_BUSY||status == NRF_ERROR_NO_MEM)
    {
    __LOG(LOG_SRC_APP, LOG_LEVEL_INFO, "Cannot send. Device is busy.\n");
    hal_led_blink_ms(LEDS_MASK, 50, 4);
    }
    else
    {
    ERROR_CHECK(status);
    }
    }
    }

    After running I get this

    Rebuilding ‘light_switch_client_nrf52840_xxAA_s140_7.2.0’ from solution ‘light_switch_client_nrf52840_xxAA_s140_7.2.0’ in configuration ‘Debug’
    Compiling ‘main.c’
    'simple_message_OPCODE_SEND' undeclared (first use in this function)
    each undeclared identifier is reported only once for each function it appears in
    implicit declaration of function 'address_set'; did you mean 'dsm_address_get'? [-Wimplicit-function-declaration]
    implicit declaration of function 'SEGGER_RTT_printf' [-Wimplicit-function-declaration]
    Compiling ‘mesh_provisionee.c’
    Compiling ‘rtt_input.c’
    Compiling ‘simple_hal.c’
    Build failed

    In addition to this, I do not know where I should add the void address_set(uint16_t addr) which is stated in the mentioned links.

    I am a beginner and I confuse when I deal with the names of different functions I do not know where they are and what they did. 

    Thank you,

    Sama

Children
No Data
Related