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

Proprietary rf communication between nRF52810 and nRF52840.

Hello,

I tried the basic proprietary rf code that is esb_prx and esb_ptx on the boards and the communication is very fine. The default set of data that is 0x00 to 0xFF is being transmitted and received correctly on both ends and the LEDs are also blinking accordingly.

Now I want to modify this data and put in my set of code for transmit and receive. I tried to dig in but I am not getting where to change the data part of the defined struct. 

I tried to make changes as far as I understood in nrf_esb.c file but I am not understanding where exactly does the code needs to  be modified so that I an put in my required data for transmission. And also if there is anything that I'll need to change in the receiver side of the code to receive the exact same modified  data transmited.

Regards

Pooja

Parents
  • Hi,

    look at esb_ptx\main.c,  tx data is passed to nrf_esb_write_payload() function

    static nrf_esb_payload_t tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);
    
    ...
    
        tx_payload.noack = false;
        if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
        {

    In esb_prx\main.c, data is received in nrf_esb_event_handler with nrf_esb_read_rx_payload(&rx_payload).

Reply
  • Hi,

    look at esb_ptx\main.c,  tx data is passed to nrf_esb_write_payload() function

    static nrf_esb_payload_t tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);
    
    ...
    
        tx_payload.noack = false;
        if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
        {

    In esb_prx\main.c, data is received in nrf_esb_event_handler with nrf_esb_read_rx_payload(&rx_payload).

Children
  • Hi,

    Thank you for your response

    tx_payload defined here has 9 values

     NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);

    whereas in the definition of create payload

    #define NRF_ESB_CREATE_PAYLOAD(_pipe, ...) 
    {.pipe = _pipe, .length =NUM_VA_ARGS(__VA_ARGS__), .data = {__VA_ARGS__}}; 
    STATIC_ASSERT(NUM_VA_ARGS(__VA_ARGS__) > 0 && NUM_VA_ARGS(__VA_ARGS__) <= 63)

    as far as I understood .pipe .length and .data are the only 3 arguments that I can see. I also could not find their code to transmit 0x00 to 0xFF. 

    Although I did try to change the .length and .data from NUM_VA_ARGS(__VA_ARGS__) to 2 and  {__VA_ARGS__} to 0xAA respectively and expected the transmitted data to be 0xAA continuous. But that did not happen.

    Can you please elaborate a bit more on where exactly should I write my data?

    Waiting for response .

    Thanks and Regards,

    Pooja

  • Hi,

    if you change NUM_VA_ARGS(__VA_ARGS__) to 2 then you should pass two bytes as data. To transmit just one byte (0xaa), define tx_payload this way:

    static nrf_esb_payload_t tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0xaa);

    Then if you need to transmit different values, change tx_payload.data[0] before calling nrf_esb_write_payload().

Related