Proprietary radio 2.4Ghz transmit and receive sample applications in nRFconnect SDK

Hi,

I need to transmit and recieve data over the 2.4GHz radio. I have customized packets to be sent and received over the radio. But I dont want to use ESB or Gazell protocols.

Is there any sample code that has the simple transmit and receive functions in nRFconnect SDK?

Thanks and regards

Ajit

  • Hi Ajit,

    We have the Radio transmitter and receiver samples in nRF5 SDK. We don't have anything similar in the nRF Connect SDK and the closest will be using ESB. But you can maybe use this code and modify it too, though we would not recommend working this low level because in case later on you need to develop code for retransmission, pairing etc, then it would be quite difficult and you will end up with codes similar to what you get if you initially began with ESB, Gazell etc.

    Best Regards,

    Priyanka

  • Hi Priyanka,

    Thanks for your reply. We are using the ESB example "radio_ptx" now and made some changes to transmit our payload.

    Our protocol requires the data to be sent in the below mentioned format.

     Header <-----------> Data <-----------> CRC

    (5 bytes)               (21 bytes)          (2 bytes)

    The Header in turn consists of the following

    Preamble -> 1byte

    Address -> 4 bytes

    The payload data that we would want to transmit is 21 bytes long.

    To achieve this packet we did the following changes in "esb_config" structure in "main.c" of "radio_ptx" project.

    struct esb_config config = ESB_DEFAULT_CONFIG;
    config.bitrate = ESB_BITRATE_1MBPS;

    We also had to make the changes in the esb.c file.

    1) We changed the value written to the CRCPOLY register from 0x11021 to 0x1021

            NRF_RADIO->CRCPOLY = 0x1021UL; /* CRC poly: x^16+x^12^x^5+1 */ // 
    2) We changed the CNF0 register values to zero as below
        NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) |
                   (0 << RADIO_PCNF0_LFLEN_Pos) |
                   (0 << RADIO_PCNF0_S1LEN_Pos);
    3) We changed the "addr_length" to 4 since we want the address to be just 4 byte long. So now 3bytes from address bytes are used and 1 byte from prefix is used. We also changed the base address and prefix address default values in the structure.
    static struct esb_address esb_addr = {
        .base_addr_p0 = {0xA9, 0x44, 0xA9, 0xA5},
        .base_addr_p1 = {0x00, 0x00, 0x00, 0x00},
        .pipe_prefixes = {0xA5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
        .addr_length = 4,
        .num_pipes = CONFIG_ESB_PIPE_COUNT,
        .rf_channel = 2,
        .rx_pipes_enabled = 0xFF
    };

    Then we copy 21bytes of data payload onto tx_payload.data and transmit the payload.

        memcpy(tx_payload.data, &Pkt, 21);
        esb_flush_tx();
       
        err = esb_write_payload(&tx_payload);
        if (err) {
            LOG_ERR("Payload write failed, err %d", err);
        }

    We do not get any error for esb_write_payload function. However we get the following prints continuously.

    D: TX FAILED EVENT
    D: TX FAILED EVENT
    D: TX FAILED EVENT

    These prints are coming from the following "event_handler" function in "main.c" file of "radio_ptx" project.

    void event_handler(struct esb_evt const *event)
    {
        ready = true;

        switch (event->evt_id) {
        case ESB_EVENT_TX_SUCCESS:
            LOG_DBG("TX SUCCESS EVENT");
            break;
        case ESB_EVENT_TX_FAILED:
            LOG_DBG("TX FAILED EVENT");
            break;
        case ESB_EVENT_RX_RECEIVED:
            while (esb_read_rx_payload(&rx_payload) == 0) {
                LOG_DBG("Packet received, len %d : "
                    "0x%02x, 0x%02x, 0x%02x, 0x%02x, "
                    "0x%02x, 0x%02x, 0x%02x, 0x%02x",
                    rx_payload.length, rx_payload.data[0],
                    rx_payload.data[1], rx_payload.data[2],
                    rx_payload.data[3], rx_payload.data[4],
                    rx_payload.data[5], rx_payload.data[6],
                    rx_payload.data[7]);
            }
            break;
        }
    }
    Looks like it's getting some transmit failed interrupts. Could you please let me know what could be wrong? Or how do I solve this error?
    Thanks and regards
    Ajit
  • Hi Ajit,

    Sorry for the delayed response. Please take a look at the packet identification in the ESB. 

    Ajitsj said:
    We changed the CNF0 register values to zero as below

    So you have disabled the header, but it will cause issues every time the library tries to read one of these values. So, you need to change any part of the library where these values are used.

    You could try looking into "dpl_pdu" or "fixed_pdu" in esb.c. These are the places that use these values. dpl_pdu is used if you configure the library in ESB_DPL mode, otherwise fixed_pdu is used.

    But since you disable the header, it would be better to use the ESB mode. 

Related