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

Enhanced ShockBurst (ESB) Payload handling issue

Hi.

I'm using nrf52832 with SDK-17, and the ESB example       (esb_tx      and      esb_rx)

I'm not much experience in nrf development recently I have a project related to ESB to transmit and receiver data, here is my problem and some questions.

The payload of ESb  transmitter and receiver is buffer is shared as when the after Ack occur ?

Like I make a logic to send different intergers on button press so I use a payload which is initialized at top

//static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x01, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);


static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 1, 2,3,4,5);

static nrf_esb_payload_t        tx_payload;
  

i try to send a specific data on button press I make a logic for button using button handler when ever I send the data using the function below the data is send nicely

   if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
        {
      static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(7,8);
          
     tx_payload.data[1];  ///the index 1
 NRF_LOG_INFO("Transmitting packet %d", tx_payload.data[1]);
        }
          else
        {         
         NRF_LOG_INFO("Sending packet failed");
        }

The problem on the Receiver side !!

 how can I get only the exact number on the receiver side in the buffer the whole buffer I don't wanna share? 

Reciever side to get the payload.. I get the payload but not the way i want please help me about this     

 if (nrf_esb_read_rx_payload(&rx_payload) == NRF_SUCCESS)
            {

    

         
     // NRF_LOG_INFO("Receiving pa
                  if(rx_payload.data[1] == 7)
                  {
                     NRF_LOG_INFO("Receiving packet 6");
                     NRF_LOG_INFO("Receiving packet: %d", rx_payload.data[0]);
             
                  }
 

on the Reciever side, I don't want the buffer index to be the same as cause it does not make my logic right...

i hope the problem is justified well if someone have question asked me about it ,

Parents
  • Hi 

    I am not quite sure I understand the question. 

    You don't want to use the same buffer index on the receiver side as you do on the transmitter side?

    The only way I can see of fixing this is to reorder the bytes in the buffer after you have called nrf_esb_read_rx_payload(&rx_payload), but before you start to process the data. 

    An easier way would be to just read out the bytes you are interested in, and store them in temporary variables:

    if (nrf_esb_read_rx_payload(&rx_payload) == NRF_SUCCESS)
    {
        // Use variable names that makes sense for your application, 
        // these are just example names
        uint8_t packet_type = rx_payload.data[1];
        uint8_t packet_data = rx_payload.data[0];
        
        if(packet_type == 7)
        {
            NRF_LOG_INFO("Receiving packet 6");
            NRF_LOG_INFO("Receiving packet: %d", packet_data);
        }
    
        .
        .
    }

    Best regards
    Torbjørn

  • thanks for your answer ...

    But there is a problem ... if want want to read the different number at the same time like .

    button1 send ---> 7   

    button2 send ----> 8

    and same as an increment on others.

    when I put check on what number is received on rx_buffer for example 

    if (nrf_esb_read_rx_payload(&rx_payload) == NRF_SUCCESS)
    {

    uint8_t packet_data1 = rx_payload.data[4];
    uint8_t packet_data2 = rx_payload.data[3];
    uint8_t packet_data3 = rx_payload.data[2];
    uint8_t packet_data4 = rx_payload.data[1];
    uint8_t packet_data5 = rx_payload.data[0];

    //if(packet_type == 7)
    //{
    // NRF_LOG_INFO("Receiving packet 7");
    // NRF_LOG_INFO("Receiving packet: %d", packet_data);
    //}

    if ( packet_data1 == 6)
    {
    //flag enable
    NRF_LOG_INFO("Receiving packet ");
    NRF_LOG_INFO("Receiving packet: %d", packet_data1);
    }

    if ( packet_data2 == 7)
    {
    //flag enable
    NRF_LOG_INFO("Receiving packet ");
    NRF_LOG_INFO("Receiving packet: %d", packet_data2);

    }
    if ( packet_data3 == 8)
    {
    //flag enable

    NRF_LOG_INFO("Receiving packet ");
    NRF_LOG_INFO("Receiving packet: %d", packet_data3);

    }
    if ( packet_data4 == 9)
    {
    //flag enable
    NRF_LOG_INFO("Receiving packet ");
    NRF_LOG_INFO("Receiving packet: %d", packet_data4);

    }

    }

    I make this logic but the indexes not going to change still got the same answer ..

    is there any way I can send a different number from tx which send only the specific index not the whole payload ?

  • Hi 

    Have you checked on the transmitting side that you are sending what you think you are sending?

    It should be possible to use the debugger to check the value of the ESB payload before you send it over the air. 

    You can also use the NRF_LOG_HEXDUMP_INFO() function to print all the ESB payload bytes to the log before you send it, so you can confirm that you are sending what you are supposed to. 

    luqman said:
    is there any way I can send a different number from tx which send only the specific index not the whole payload ?

    You can set the length field in the payload to a lower number if you like, as long as it is at least 1 byte long. So if you only want to send the index that is possible. 

    On the RX side you can then read the length field of the payload to see how much data was sent from the transmitter. 

    Best regards
    Torbjørn

  • yes I know what is sending by using 

    NRF_LOG_INFO("Receiving packet: %d", packet_data);

    i try to implement this but if there any example where I send specific data from Tx and read from RX as the same really help me a lot.. not like full buffer is a shared an example 

  • Hi 

    luqman said:
    but if there any example where I send specific data from Tx and read from RX as the same really help me a lot

    I am sorry, but I don't understand what you mean by this sentence. 

    The data you read on the RX side should be exactly the same as the data you upload on the TX side. Otherwise there is something wrong in the code. 

    Best regards
    Torbjørn 

  • thanks, buddy I got it,

    I make a 4 payload with a different name and it solves

    static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0,3,);
    
    static nrf_esb_payload_t        tx_payload;
    
    static nrf_esb_payload_t        tx_payload1 = NRF_ESB_CREATE_PAYLOAD(0,0,4,);
    
    static nrf_esb_payload_t        tx_payload1;
    
    static nrf_esb_payload_t        tx_payload2 = NRF_ESB_CREATE_PAYLOAD(0, 0,5);
    
    static nrf_esb_payload_t        tx_payload2;
    
    static nrf_esb_payload_t        tx_payload3 = NRF_ESB_CREATE_PAYLOAD(0, 0,6);
    
    static nrf_esb_payload_t        tx_payload3;
    
    static nrf_esb_payload_t        tx_payload4 = NRF_ESB_CREATE_PAYLOAD(0, 0,7);
    
    static nrf_esb_payload_t        tx_payload4;
    the problem

Reply
  • thanks, buddy I got it,

    I make a 4 payload with a different name and it solves

    static nrf_esb_payload_t        tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0,3,);
    
    static nrf_esb_payload_t        tx_payload;
    
    static nrf_esb_payload_t        tx_payload1 = NRF_ESB_CREATE_PAYLOAD(0,0,4,);
    
    static nrf_esb_payload_t        tx_payload1;
    
    static nrf_esb_payload_t        tx_payload2 = NRF_ESB_CREATE_PAYLOAD(0, 0,5);
    
    static nrf_esb_payload_t        tx_payload2;
    
    static nrf_esb_payload_t        tx_payload3 = NRF_ESB_CREATE_PAYLOAD(0, 0,6);
    
    static nrf_esb_payload_t        tx_payload3;
    
    static nrf_esb_payload_t        tx_payload4 = NRF_ESB_CREATE_PAYLOAD(0, 0,7);
    
    static nrf_esb_payload_t        tx_payload4;
    the problem

Children
Related