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

esb NRF_ESB_CREATE_PAYLOAD limit

I am using nRF5_SDK_11.0.0_89a8197 to test esb maximum throughput.

in the macro definition of NRF_ESB_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)

Where does the number 63 come from?

Since NRF_ESB_MAX_PAYLOAD_LENGTH can be from 1 to 252, I want to change 63 to 100; however, I have compiling error.

How can I stretch the payload length to 250 in NRF_ESB_CREATE_PAYLOAD?

  • the compiling error is caused by macro definition NUM_VA_ARGS in app_util.h from line 116 to 147, to get rid of the error, we need to add enough number to it. Previous maximum is 63, that's why NRF_ESB_CREATE_PAYLOAD cannot take more than 63 values. I've changed to 103; and it's working. I guess 250 will also work.

  • Hi.

    The macro NRF_ESB_CREATE_PAYLOAD just inserts values into the struct it is assigned to.

    For example in the following code:

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

    The tx_payload struct will get the .pipe value written to 0x0, the .length value written to 2, and the .data value written to {0x01,0x00}.

    The very allocation of the payload buffer does not happen inside the macro. It happens when the payload struct is created. You do not need to use the macro.

    The NRF_ESB_CREATE_PAYLOAD is nice to use for initiation of a short payload. If you want to fill up 250 bytes of data, i would first create the payload:

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

    And then assign values to the data variable.

    for(uint8_t i = 0; i < PAYLOAD_LENGTH; i++)
    {
        tx_payload.data[i] = some_value;
    }
    

    Of course you can use the NRF_ESB_CREATE_PAYLOAD macro, but i think your code will be messier, not cleaner :)

Related