<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/57619/multiple-data-sources-transmission-routing-and-identification</link><description>Dear Team, I&amp;#39;m preparing an application for nRF52840 that will require to send and receive data collected from two different sources, I2S and UART, two UART or SPI and UART channels. One of the connections will be lower in bps than the other but essentially</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 Apr 2020 06:46:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/57619/multiple-data-sources-transmission-routing-and-identification" /><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/246671?ContentTypeID=1</link><pubDate>Mon, 27 Apr 2020 06:46:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c24182c-2e6e-41ac-a50e-e7334ae10bae</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Pablo&lt;/p&gt;
&lt;p&gt;I am happy to help.&amp;nbsp;You have a great week too&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/246331?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 16:34:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14a550b1-792a-459b-a296-5ce430d6472a</guid><dc:creator>Mental Mode</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span style="background-color:#ffffff;"&gt;Torbj&amp;oslash;rn&lt;/span&gt;,&lt;/p&gt;
&lt;p&gt;Amazingly explained... Thanks a lot!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;And for the literature proposal! I&amp;#39;ll check out that to be more concentrated on plain C. &lt;br /&gt;I&amp;#39;ll be doing experiments with modified versions of the examples and my own code but now I have the basic bricks.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;I promise not bothering you with code related stuff. :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Thanks again and have a great week.&amp;nbsp;&lt;br /&gt;Best regards,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Pablo.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/246324?ContentTypeID=1</link><pubDate>Thu, 23 Apr 2020 15:34:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1cfd32b0-1453-43a6-b34c-ae4e3dce5977</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Pablo&lt;/p&gt;
&lt;p&gt;All our code examples including this one are based on C, not C++.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Technically C++ is a superset of C, but if you are reading about C++ you will get a lot of information about classes, inheritance, function overloading, exceptions etc which is not relevant to understand our C examples.&lt;/p&gt;
&lt;p&gt;In other words I would strongly suggest starting with a book on C to get familiar with the basics of the language, and then you can move to C++ later on if you need to learn all the additional features supported by C++.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;A good start is what many consider the &amp;quot;bible&amp;quot; on the C language, &amp;quot;The C Programming Language by Kernighan and Ritchie&amp;quot;, which even seems to be available for free &lt;a href="http://www2.cs.uregina.ca/~hilder/cs833/Other%20Reference%20Materials/The%20C%20Programming%20Language.pdf"&gt;here&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As for your questions, I tried to answer them inline:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-75b003839f9b4a6dafc8aa87ec4de41c/reply.c"&gt;devzone.nordicsemi.com/.../reply.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/246116?ContentTypeID=1</link><pubDate>Wed, 22 Apr 2020 19:15:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:509c0874-ae3f-41c3-a507-21c61411ad60</guid><dc:creator>Mental Mode</dc:creator><description>&lt;p&gt;Hello &lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/members/ovrebekk"&gt;ovrebekk&lt;/a&gt;,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Just for your to know, I&amp;#39;ve been programming for years in &amp;quot;too much high level&amp;quot; languages as Java, C# and so on...&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve been studying C++ in my free time the last 2 months, but at this point there are still things that I don&amp;#39;t fully understand about the code proposed so... Let me put the code step by step and comment what I&amp;#39;m understanding.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Probably, you&amp;#39;re so used to code for hardware using these compilers but I&amp;#39;m not so familiar with these types and operators.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ll paste your program and comment my doubts about the original definition and transmitter part.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The receiver part will be clarified with the transmitter part.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Again. I know that you&amp;#39;re not here to teach C++. You&amp;#39;re here to help to implement your solution.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m using SES and run several examples so I&amp;#39;ll able to test this at the moment you reply.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;// COMMON STRUCT DEFINITION:

typedef struct // Struct definition for dummy example. For me to understand how a struct is declared. 
{
    uint8_t     cmd_byte; // Unsigned integer size 1 byte variable called cmd_by. I understood that this will be the “packet type” for my program to distinguish between i2c or whatever origin. To be able to put in the right port on receivers side.
    uint32_t    some_data; // Unsigned integer size 4 bytes variable called some_data. This is dummy thing to explain struct declaration.
    float       some_more_data; // Float type integer size float variable called some more data. Another dummy thing to explain another variable in case of wanting to send more than 1 data in the same struct type. 
} packet_type_1_t;

typedef struct 
{
    uint8_t     cmd_byte; // here we are declaring what type of data I want to send to be routed by the receiver. 
    uint8_t     spi_data[4]; // Unsigned integer size 4 bytes ARRAY called some_data maximum 4 bytes in length. Is this the data size expected from SPI?
    uint8_t     i2c_data[6]; // Float type integer size float ARRAY called some more data maximum 6 bytes in length. Is this the data size expected for I2C data? 
} packet_type_2_t;

enum {PACKET_TYPE_1, PACKET_TYPE_2}; // Here you declare the two structs as unique types to be used in all the program. Take into account that my original program was intended to separate i2c and spi in two different structs but this is OK for me, 

// TRANSMITTER PART:

static uint32_t send_packet_type_1(packet_type_1_t *data_packet) // function declaration returning 4 bytes of static (doesn’t change each time is called) data called send_packet_type_1. **DOUBT** Are you passing the cmd_byte and the “deferenced pointer here? If that’s the case, why we don’t have the comma? 
{
    nrf_esb_payload_t esb_payload = {0}; // Declaration of a variable using your struct type nrf_esb_payload_t called esb_payload and initialized to 0. 

    // Ensure that the cmd_byte field is set correctly, in correspondence with the packet type
    data_packet-&amp;gt;cmd_byte = PACKET_TYPE_1; // Here, we are defining our data packet cmd byte struct as type 1. 

    // Populate the esb_payload struct
    memcpy(esb_payload.data, (uint8_t*)data_packet, sizeof(packet_type_1_t)); // Copy our unsigned 1 byte data packet variable to es_payload_data and defining the size of out whole struct. **DOUBT**Why the * in uint8_t?
    esb_payload.length = sizeof(packet_type_1_t); // Populating the required variable esb_payload.length with the size of the struct.
    esb_payload.pipe = 0; // Selecting the pipe to send it. **DOUBT** how many pipes do I can use?

    // Forward the data to the ESB library
    return nrf_esb_write_payload(&amp;amp;esb_payload); // Returning all the stuff to the nrf_esb_write_payload function.
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Again, Thanks for your valuable help.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Pablo.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/234097?ContentTypeID=1</link><pubDate>Thu, 13 Feb 2020 07:17:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cca27647-a454-4bbf-aac5-a277fbab929d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Pablo&lt;/p&gt;
&lt;p&gt;Thanks for the kind words, and the best of luck with your project &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/234006?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2020 14:05:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:587b98ff-0f33-4d01-a4a1-4f2866f91d20</guid><dc:creator>Mental Mode</dc:creator><description>&lt;p&gt;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Hi Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;All clear. Now I have something to start from.&lt;br /&gt;Amazing support by the way guys.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Thanks a lot for your time and attention.&amp;nbsp;&lt;br /&gt;Have a great day!&amp;nbsp;&lt;br /&gt;Mental Mode.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/233950?ContentTypeID=1</link><pubDate>Wed, 12 Feb 2020 12:10:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35de4534-0984-4a7f-b696-c489518dd6df</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Pablo&lt;/p&gt;
&lt;p&gt;If you look at any of our examples the different data types are usually organized in structs, allowing you to build up a packet in a logical manner instead of just using long arrays of bytes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Then in applications where you want to send different types of data you can&amp;nbsp;define multiple different structs, and use a command byte to identify them.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As an example consider the following two data structures, and an enum used to create unique identifiers for them:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;typedef struct
{
    uint8_t     cmd_byte;
    uint32_t    some_data;
    float       some_more_data;
} packet_type_1_t;

typedef struct 
{
    uint8_t     cmd_byte;
    uint8_t     spi_data[4];
    uint8_t     i2c_data[6];
} packet_type_2_t;

enum {PACKET_TYPE_1, PACKET_TYPE_2};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Sending a packet of type 1 using ESB can be as simple as this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint32_t send_packet_type_1(packet_type_1_t *data_packet)
{
    nrf_esb_payload_t esb_payload = {0};

    // Ensure that the cmd_byte field is set correctly, in correspondence with the packet type
    data_packet-&amp;gt;cmd_byte = PACKET_TYPE_1;

    // Populate the esb_payload struct
    memcpy(esb_payload.data, (uint8_t*)data_packet, sizeof(packet_type_1_t));
    esb_payload.length = sizeof(packet_type_1_t);
    esb_payload.pipe = 0;

    // Forward the data to the ESB library
    return nrf_esb_write_payload(&amp;amp;esb_payload);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then on the receiving end you need to check the command byte (the first byte of the packet in this case) and process it accordingly:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint32_t process_received_packets(nrf_esb_payload_t *rx_payload)
{
    packet_type_1_t packet_1;
    packet_type_2_t packet_2;

    switch(rx_payload-&amp;gt;data[0])
    {
        case PACKET_TYPE_1:
            // Copy the ESB payload data into our struct variable
            memcpy((uint8_t*)&amp;amp;packet_1, rx_payload-&amp;gt;data, sizeof(packet_type_1_t));

            // Now the data is stored in the packet_1 struct, and can be accessed accordingly. 
            // What to do with the data is up to the application. 
            break;

        case PACKET_TYPE_2:
            // Similar to the type 1 case, except the packet_2 struct is used
            break;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;To maximize the throughput you should try to make each packet as long as possible, up to a maximum of 252 bytes for ESB.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BLE defines 40 channels, each spaced 2MHz apart in the range 2402-2480MHz.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;With ESB you should use 2MHz separation if you are using the 2Mbps PHY (on-air bitrate), or 1MHz separation if you use the 1Mbps PHY.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Gazell is based on ESB and supports the same channels. The main difference is that Gazell supports a mechanism for switching channels automatically, while ESB requires you to manually control the channel selection.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/233791?ContentTypeID=1</link><pubDate>Tue, 11 Feb 2020 14:25:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:49f07a6d-55bd-416c-8424-744d0a4db869</guid><dc:creator>Mental Mode</dc:creator><description>&lt;p&gt;&lt;span style="background-color:#ffffff;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:1.5em;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Hi Torbj&amp;oslash;rn,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Do you have any example about both examples? Take into account that the custom command packets will be sent by the user only sometimes so, reserving space for that commands and interface in all packts will be pretty unnecesary. About creating whole packets with the commands per each interface may be a waste as you said so, If I have an example of each one I could create some kind of conditional packet building to mix them and not waste part of the packets that will be send continously from one of the interfaces.&lt;br /&gt;&lt;br /&gt;If you don&amp;#39;t have examples of this, I could review any sample of packet building and origin-destination specification in the packet or interface. &amp;nbsp;&lt;br /&gt;Sorry if I&amp;#39;m asking these basic things but I&amp;#39;m pretty new on this technology &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;About protocols, I&amp;#39;ve been exploring that options and multiprotocol stacks.&lt;br /&gt;I have to say that the options are very flexible and seem to be pretty powerful...&lt;br /&gt;Maybe I&amp;#39;m little lost with frequency selection and tables... I read that there 80 channels for BRE to create necessary tables, but I have to study a way to make less populated selectable ones. What&amp;#39;s the minimum frequency separation that I could use in ESB? Does it common to Gazell?&lt;br /&gt;&lt;br /&gt;Again, thanks for your time and patience.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#007000;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:medium;"&gt;Mental Mode&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple data sources transmission routing and identification</title><link>https://devzone.nordicsemi.com/thread/233713?ContentTypeID=1</link><pubDate>Tue, 11 Feb 2020 12:17:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc5d4c5f-0200-4e32-80bf-c6c5fce12e3f</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Pablo&lt;/p&gt;
[quote user=""]How do I route the packets to be sent to the correct interfaces at the destination (receiver)?&amp;nbsp;[/quote]
&lt;p&gt;You are free to do this any way you like. If you can combine all the serial data into a single packet then you can use the position in the packet to differentiate the different interfaces, and make sure to route the right parts of the packet to the right interfaces on the receiver end.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Alternatively you use one packet for each of the serial interfaces, and put some kind of command byte in the packet telling the receiver which interface the data is from. The drawback of this method is that it is not very efficient to send many small packets if you want to maximize data throughput.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]Is it possible to do this?&amp;nbsp;[/quote]
&lt;p&gt;For maximizing bandwidth I would recommend either ESB or BLE. ESB will give you lower latency and slightly higher maximum throughput, while BLE is easier to design in since the entire protocol is provided (the ESB protocol is quite simple, and will require more work on the software side).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Using BLE will also require BLE certification, which adds to the cost.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In both cases it is possible to do it, it&amp;#39;s just a matter of priorities.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>