<?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>Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput</link><description>Hi, 
 I&amp;#39;m struggling to use ble_app_att_mtu_throughput and spi. Some help? 
 When I merge the two codes the main code (ble_app_att_mtu_throughput) doesn&amp;#39;t work. 
 
 Thanks for your help</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 19 Aug 2024 14:19:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput" /><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498886?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2024 14:19:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6697e765-e4a5-4ff8-9233-9e6d253b24dd</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Right, thank you very much for all&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498862?ContentTypeID=1</link><pubDate>Mon, 19 Aug 2024 13:17:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1991ad4b-2e99-41f0-b655-aff20332d0b3</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Can you make a new ticket for that problem?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498731?ContentTypeID=1</link><pubDate>Sun, 18 Aug 2024 15:54:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:434ccbe0-b6a4-4c52-b449-c48f77e09fa2</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think I solved my problems with merging spi and my code. But now I have another big issue: the throughput. My point in this project is also maintain an high throughput (2Mbps but actually 1.4Mbps). Do you have some advice?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Regards.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498274?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2024 12:32:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5671ef6-2aa6-4820-b004-166d811c0fde</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I think if I&amp;#39;ll continue to run two separate code (SPI for the SPI Master and ble_app_att_mtu_throughput+spis for BLE Server and BLE Client) it can&amp;#39;t works&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498253?ContentTypeID=1</link><pubDate>Wed, 14 Aug 2024 11:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e3fe13b8-a5ef-4502-9f73-b8807d157189</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If the SPI code works when you include it with the BLE code, then you should see the clock signal on the SCLK when it starts the transaction.&lt;/p&gt;
&lt;p&gt;If you don&amp;#39;t see the clock signal, then it usually means either:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;The program have asserted or is stuck somewhere in your code before it reach the function that starts the SPI transaction.&lt;/li&gt;
&lt;li&gt;You are not measuring on the correct SCLK pin.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Option 1 can be checked by using breakpoints and the debugger.&lt;/p&gt;
&lt;p&gt;Option 2, can be checked by checking the &lt;a href="https://docs.nordicsemi.com/bundle/ps_nrf52832/page/spim.html#d946e4384"&gt;PSEL.SCLK&lt;/a&gt; register after the module have been initialized. You can read out this register by using memrd in nRF Command Line Tools, or using the debugger in Segger and watching the register content in debug view.&lt;/p&gt;
&lt;p&gt;I think you need to use a more time debugging your application,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498132?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 20:33:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95d6ed17-6d52-400f-894d-4a08d2eb32db</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="73165" url="~/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput/498082"]Earlier you wrote that the example works when the SPI code is not included[/quote]
&lt;p&gt;Yes, right. I moved the spi part from the main to the amts.c and it doesn&amp;#39;t&amp;nbsp;interfere, so the code run, but what the server receive is just 0 (instead of the data I send).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="73165" url="~/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput/498082"]Have you made sure to test only the SPI code separate from the BLE code, and verified that it works?[/quote]
&lt;p&gt;Yes, and in this case the SPI communication between SPI Master and SPI Slave works perfectly. It seems like the SPI Slave (when become also BLE server), when I run the ble code, can&amp;#39;t receive data via SPI.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/498082?ContentTypeID=1</link><pubDate>Tue, 13 Aug 2024 13:45:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57b866e8-f9e2-4514-8f5d-e7fbda7bcf32</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Earlier you wrote that the example works when the SPI code is not included. You mentioned that you do not see any SPI activity on SCLK, CS, MOSI or MISO when including the SPI code. Have you made sure to test only the SPI code separate from the BLE code, and verified that it works?&lt;/p&gt;
&lt;p&gt;I think that would be a good first step, before trying to merge that in to the BLE sample,&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497889?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 20:05:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:271446e5-08ba-4f3a-a077-07bb1ee36ec2</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;However, I think the main problem is in the fact the SPI Master code isn&amp;#39;t included in the ble_app_att_mtu_throughput project. I tried to add the spis code but is not enough. But another problem is the fact that the SPI Master is an nRF52840 board, not nRF52832 board as the SPI Slave or the ble client.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I think it&amp;#39;s ambitious, but I would try to include nRF52840 in the project. Is possible? The problem I&amp;#39;m afraid of is the fact that the SPI Master is an nRF52840 so I can&amp;#39;t run the&amp;nbsp;&lt;span&gt;ble_app_att_mtu_throughput_pca_10040 as SPI Slave (which is also ble server) or ble client&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497855?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 14:13:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5776fc6-03da-4f65-a0bc-b040d3d114a0</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;No but maybe I&amp;#39;m making some mistake. I connect the SPI Master to the SPI Driver (so I disconnected the SPI Slave), is it right?&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497829?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 12:55:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3067cf58-b4bc-41b4-8764-11cd150756dc</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Did you any clock signal on SCLK?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What about CS?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497820?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 12:42:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a99c887e-f5b7-4858-8f8e-d7459d8e2353</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Yes, I connected the MISO/MOSI to the SPI Driver but nothing happen. I think because 0 is transmitting.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497802?ContentTypeID=1</link><pubDate>Mon, 12 Aug 2024 12:04:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:25b56425-821c-450f-a638-9cb542447d47</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Yes, the SPI driver should be able to work along side the BLE samples. Did you probe the SPI lines as I suggested in my last reply?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497700?ContentTypeID=1</link><pubDate>Sun, 11 Aug 2024 13:35:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de7c16d4-6d60-4f9d-a556-124aed10a5d5</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Is an SPI Driver suitable to this scope? For istance I connected the SPI Driver to&amp;nbsp;the pins&amp;nbsp;of the SPI Slave/Master&amp;nbsp;but I see nothing (maybe because 0 is the data received &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/497160?ContentTypeID=1</link><pubDate>Tue, 06 Aug 2024 12:41:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fdd9cc5c-cbca-4184-b253-3a79a60c7a19</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Based on your latest answer, it seems like you are able to get logs compared to earlier. That is good.&lt;/p&gt;
&lt;p&gt;I know understand that you are not getting the desired data on the log output from the SPI communication.&lt;/p&gt;
&lt;p&gt;First step in debugging this is to either connect a logic analyzer or a oscilloscope to the MOSI/MISO pins, and confirm if the Master/slave is sending the expected data.&lt;/p&gt;
&lt;p&gt;regards&lt;br /&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/496514?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 06:28:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:537bb2e9-8700-4e03-9248-980c5c24c1df</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Hi Susheel,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks. Meanwhile, adding what I said to Jared in previous messages, I show you something else.&lt;/p&gt;
&lt;p&gt;This is a simply spi-spis SPI comunication where I send via SPI 10 packets of 244 bytes (from 0 to 243) from the Master and these bytes arrives to the Slave. I&amp;#39;ll show just the firsts 10 bytes for each packets to avoid filling the buffer log:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722493335908v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I verified bytes are succesfully send/received for each packets.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem come when I run on the the board which receive data via spi (so the board where I charge spis) the ble_att_app_mtu_thrpughput+spis:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722493539227v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;This image show what I receive via spi with this code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The news (compared to what I said to Jared) is that I&amp;#39;m trying to implement the spis part of the code on the amts.c and not in the main.c:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;amt.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;ble_err.h&amp;quot;
#include &amp;quot;ble_srv_common.h&amp;quot;
#include &amp;quot;nrf_error.h&amp;quot;
#include &amp;quot;sdk_common.h&amp;quot;
#include &amp;quot;nrf_drv_spis.h&amp;quot;

#define NRF_LOG_MODULE_NAME AMTS
#include &amp;quot;nrf_log.h&amp;quot;
NRF_LOG_MODULE_REGISTER();

#define OPCODE_LENGTH 1 /**&amp;lt; Length of opcode inside a notification. */
#define HANDLE_LENGTH 2 /**&amp;lt; Length of handle inside a notification. */

static const nrf_drv_spis_t spis = NRF_DRV_SPIS_INSTANCE(1);
#define MAX_PACKET_SIZE 244
static uint8_t m_tx_buf[MAX_PACKET_SIZE] = {0};
static uint8_t m_rx_buf[MAX_PACKET_SIZE + 1];
static const uint8_t m_length = MAX_PACKET_SIZE;
static volatile bool spis_xfer_done = false;
static uint8_t packets_received = 0;
static nrf_ble_amts_t *p_ctx;

void spis_event_handler(nrf_drv_spis_event_t event)
{
    if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
    {
        spis_xfer_done = true;
        packets_received++;
        NRF_LOG_INFO(&amp;quot;SPIS Transfer completed. Received data:&amp;quot;);
        for (uint8_t i = 0; i &amp;lt; m_length; i++)
        {
            NRF_LOG_INFO(&amp;quot;%03d&amp;quot;, m_rx_buf[i]);  // Log in decimal
        }

        if (p_ctx-&amp;gt;conn_handle != BLE_CONN_HANDLE_INVALID)
        {
            // Aggiorna bytes_sent con la lunghezza dei dati ricevuti via SPI
            p_ctx-&amp;gt;bytes_sent += m_length;

            // Invia i dati ricevuti via SPI tramite BLE
            nrf_ble_amts_send(p_ctx, m_rx_buf, m_length);

            // Genera l&amp;#39;evento per la trasmissione dei dati
            nrf_ble_amts_evt_t evt;
            evt.evt_type = NRF_BLE_AMTS_EVT_TRANSFER_244B;
            evt.bytes_transfered_cnt = p_ctx-&amp;gt;bytes_sent;
            p_ctx-&amp;gt;evt_handler(evt);
        }
    }
}

void spis_init(nrf_ble_amts_t *p_ctx)
{
    nrf_drv_spis_config_t spis_config = NRF_DRV_SPIS_DEFAULT_CONFIG;
    spis_config.csn_pin = APP_SPIS_CS_PIN;
    spis_config.miso_pin = APP_SPIS_MISO_PIN;
    spis_config.mosi_pin = APP_SPIS_MOSI_PIN;
    spis_config.sck_pin = APP_SPIS_SCK_PIN;

    APP_ERROR_CHECK(nrf_drv_spis_init(&amp;amp;spis, &amp;amp;spis_config, spis_event_handler));
}

static void char_notification_send(nrf_ble_amts_t *p_ctx);

/**@brief Function for handling the Connect event.
 *
 * @param     p_ctx       Pointer to the AMTS structure.
 * @param[in] p_ble_evt  Event received from the BLE stack.
 */
static void on_connect(nrf_ble_amts_t *p_ctx, ble_evt_t const *p_ble_evt)
{
    p_ctx-&amp;gt;conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
}

/**@brief Function for handling the Disconnect event.
 *
 * @param     p_ctx         Pointer to the AMTS structure.
 * @param[in] p_ble_evt     Event received from the BLE stack.
 */
static void on_disconnect(nrf_ble_amts_t *p_ctx, ble_evt_t const *p_ble_evt)
{
    p_ctx-&amp;gt;conn_handle = BLE_CONN_HANDLE_INVALID;
}

/**@brief Function for handling the TX_COMPLETE event.
 *
 * @param   p_ctx   Pointer to the AMTS structure.
 */
static void on_tx_complete(nrf_ble_amts_t *p_ctx)
{
    if (p_ctx-&amp;gt;busy)
    {
        p_ctx-&amp;gt;busy = false;
        char_notification_send(p_ctx);
    }
}

/**@brief Function for handling the Write event.
 *
 * @param     p_ctx       Pointer to the AMTS structure.
 * @param[in] p_ble_evt   Event received from the BLE stack.
 */
static void on_write(nrf_ble_amts_t *p_ctx, ble_evt_t const *p_ble_evt)
{
    ble_gatts_evt_write_t const *p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;

    if ((p_evt_write-&amp;gt;handle == p_ctx-&amp;gt;amts_char_handles.cccd_handle) &amp;amp;&amp;amp; (p_evt_write-&amp;gt;len == 2))
    {
        // CCCD written, call the application event handler.
        nrf_ble_amts_evt_t evt;

        if (ble_srv_is_notification_enabled(p_evt_write-&amp;gt;data))
        {
            evt.evt_type = NRF_BLE_AMTS_EVT_NOTIF_ENABLED;
        }
        else
        {
            evt.evt_type = NRF_BLE_AMTS_EVT_NOTIF_DISABLED;
        }

        p_ctx-&amp;gt;evt_handler(evt);
    }
}

void nrf_ble_amts_on_ble_evt(ble_evt_t const *p_ble_evt, void *p_context)
{
    nrf_ble_amts_t *p_ctx = (nrf_ble_amts_t *)p_context;

    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
    case BLE_GAP_EVT_CONNECTED:
        on_connect(p_ctx, p_ble_evt);
        break;

    case BLE_GAP_EVT_DISCONNECTED:
        on_disconnect(p_ctx, p_ble_evt);
        break;

    case BLE_GATTS_EVT_WRITE:
        on_write(p_ctx, p_ble_evt);
        break;

    case BLE_GATTS_EVT_HVN_TX_COMPLETE:
        on_tx_complete(p_ctx);
        break;

    default:
        break;
    }
}

void nrf_ble_amts_init(nrf_ble_amts_t *p_ctx, amts_evt_handler_t evt_handler)
{
    ret_code_t err_code;
    uint16_t service_handle;
    ble_uuid_t ble_uuid;
    ble_uuid128_t base_uuid = {SERVICE_UUID_BASE};

    err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;(p_ctx-&amp;gt;uuid_type));
    APP_ERROR_CHECK(err_code);

    ble_uuid.type = p_ctx-&amp;gt;uuid_type;
    ble_uuid.uuid = AMT_SERVICE_UUID;

    // Add service.
    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &amp;amp;ble_uuid, &amp;amp;service_handle);
    APP_ERROR_CHECK(err_code);

    // Add AMTS characteristic.
    ble_add_char_params_t amt_params;
    memset(&amp;amp;amt_params, 0, sizeof(amt_params));

    amt_params.uuid = AMTS_CHAR_UUID;
    amt_params.uuid_type = p_ctx-&amp;gt;uuid_type;
    amt_params.max_len = NRF_SDH_BLE_GATT_MAX_MTU_SIZE;
    amt_params.char_props.notify = 1;
    amt_params.cccd_write_access = SEC_OPEN;
    amt_params.is_var_len = 1;

    err_code = characteristic_add(service_handle, &amp;amp;amt_params, &amp;amp;(p_ctx-&amp;gt;amts_char_handles));
    APP_ERROR_CHECK(err_code);

    // Add AMT Received Bytes Count characteristic.
    ble_add_char_params_t amt_rbc_params;
    memset(&amp;amp;amt_rbc_params, 0, sizeof(amt_rbc_params));

    amt_rbc_params.uuid = AMT_RCV_BYTES_CNT_CHAR_UUID;
    amt_rbc_params.uuid_type = p_ctx-&amp;gt;uuid_type;
    amt_rbc_params.max_len = AMT_RCV_BYTES_CNT_MAX_LEN;
    amt_rbc_params.char_props.read = 1;
    amt_rbc_params.read_access = SEC_OPEN;

    err_code = characteristic_add(service_handle, &amp;amp;amt_rbc_params, &amp;amp;(p_ctx-&amp;gt;amt_rbc_char_handles));
    APP_ERROR_CHECK(err_code);

    p_ctx-&amp;gt;evt_handler = evt_handler;

    spis_init(p_ctx);
}

void nrf_ble_amts_notif_spam(nrf_ble_amts_t *p_ctx)
{
    p_ctx-&amp;gt;kbytes_sent = 0;
    p_ctx-&amp;gt;bytes_sent = 0;
    char_notification_send(p_ctx);
}

void nrf_ble_amts_on_gatt_evt(nrf_ble_amts_t *p_ctx, nrf_ble_gatt_evt_t const *p_gatt_evt)
{
    if (p_gatt_evt-&amp;gt;evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED)
    {
        p_ctx-&amp;gt;max_payload_len =
            p_gatt_evt-&amp;gt;params.att_mtu_effective - OPCODE_LENGTH - HANDLE_LENGTH;
    }
}

static void char_notification_send(nrf_ble_amts_t *p_ctx)
{
    uint16_t payload_len = p_ctx-&amp;gt;max_payload_len;
    nrf_ble_amts_evt_t evt;

    if (p_ctx-&amp;gt;bytes_sent &amp;gt;= AMT_BYTE_TRANSFER_CNT)
    {
        evt.bytes_transfered_cnt = p_ctx-&amp;gt;bytes_sent;
        evt.evt_type = NRF_BLE_AMTS_EVT_TRANSFER_FINISHED;

        p_ctx-&amp;gt;evt_handler(evt);

        p_ctx-&amp;gt;busy = false;
        p_ctx-&amp;gt;bytes_sent = 0;
        p_ctx-&amp;gt;kbytes_sent = 0;

        return;
    }

    ble_gatts_hvx_params_t hvx_param =
        {
            .type = BLE_GATT_HVX_NOTIFICATION,
            .handle = p_ctx-&amp;gt;amts_char_handles.value_handle,
            .p_data = m_rx_buf,
            .p_len = &amp;amp;payload_len,
        };

    uint32_t err_code = NRF_SUCCESS;
    uint16_t packets_to_send = PACKETS;
    while (err_code == NRF_SUCCESS &amp;amp;&amp;amp; packets_to_send &amp;gt; 0)
    {
        err_code = sd_ble_gatts_hvx(p_ctx-&amp;gt;conn_handle, &amp;amp;hvx_param);

        if (err_code == NRF_ERROR_RESOURCES)
        {
            // Wait for BLE_GATTS_EVT_HVN_TX_COMPLETE.
            p_ctx-&amp;gt;busy = true;
            break;
        }
        else if (err_code != NRF_SUCCESS)
        {
            NRF_LOG_ERROR(&amp;quot;sd_ble_gatts_hvx() failed: 0x%x&amp;quot;, err_code);
        }

        p_ctx-&amp;gt;bytes_sent += payload_len;

        if (p_ctx-&amp;gt;kbytes_sent != (p_ctx-&amp;gt;bytes_sent / 244))
        {
            p_ctx-&amp;gt;kbytes_sent = (p_ctx-&amp;gt;bytes_sent / 244);

            NRF_LOG_INFO(&amp;quot;Sending data: &amp;quot;);
            for (uint16_t i = 0; i &amp;lt; 10; i++)
            {
                NRF_LOG_INFO(&amp;quot;Byte %d: %d&amp;quot;, i, m_rx_buf[i]);
            }

            evt.evt_type = NRF_BLE_AMTS_EVT_TRANSFER_244B;
            evt.bytes_transfered_cnt = p_ctx-&amp;gt;bytes_sent;
            p_ctx-&amp;gt;evt_handler(evt);
        }
        packets_to_send--;
    }
}

void nrf_ble_amts_rbc_set(nrf_ble_amts_t *p_ctx, uint32_t byte_cnt)
{
    uint8_t data[AMT_RCV_BYTES_CNT_MAX_LEN];
    uint16_t len;

    ble_gatts_value_t value_param;

    memset(&amp;amp;value_param, 0x00, sizeof(value_param));

    len = (uint16_t)uint32_encode(byte_cnt, data);
    value_param.len = len;
    value_param.p_value = data;

    ret_code_t err_code = sd_ble_gatts_value_set(p_ctx-&amp;gt;conn_handle,
                                                 p_ctx-&amp;gt;amt_rbc_char_handles.value_handle,
                                                 &amp;amp;value_param);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;sd_ble_gatts_value_set() failed: 0x%x&amp;quot;, err_code);
    }
}

void nrf_ble_amts_send(nrf_ble_amts_t *p_ctx, uint8_t *data, uint16_t length)
{
    if (p_ctx-&amp;gt;conn_handle == BLE_CONN_HANDLE_INVALID)
    {
        NRF_LOG_ERROR(&amp;quot;No connection established, cannot send data.&amp;quot;);
        return;
    }

    ble_gatts_hvx_params_t hvx_params = {
        .type = BLE_GATT_HVX_NOTIFICATION,
        .handle = p_ctx-&amp;gt;amts_char_handles.value_handle,
        .p_data = data,
        .p_len = &amp;amp;length,
    };

    uint32_t err_code = sd_ble_gatts_hvx(p_ctx-&amp;gt;conn_handle, &amp;amp;hvx_params);
    if (err_code != NRF_SUCCESS)
    {
        NRF_LOG_ERROR(&amp;quot;sd_ble_gatts_hvx() failed: 0x%x&amp;quot;, err_code);
    }
    else
    {
        NRF_LOG_INFO(&amp;quot;Data sent successfully.&amp;quot;);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks for all,&lt;/p&gt;
&lt;p&gt;Best regards.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/496497?ContentTypeID=1</link><pubDate>Thu, 01 Aug 2024 05:06:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ecfab563-cb1d-4ea9-9adb-1877fd1c1927</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;sorry for late response here Stefano, Jared is away and will be back on Monday. Thanks for your patience so far.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/496095?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 20:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:631baaf7-a149-41cb-a263-2ee9bff0caae</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Just to simplify the reading of the code. Before I tried to add the SPIS part, data were generated in the amts.c as mentioned in line 220-222:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;for (uint16_t i = 0; i &amp;lt; payload_len; i++) {
      data[i] = i % 244;  // Riempie il buffer con valori da 0 a 243
  }&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;so I think I should work there.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/496062?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 16:25:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1995d2c1-b835-43ad-8dd3-a2f0fcd2b725</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;I have so many doubt.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know if you run the ble_app_att_mtu_throughput code, but normally you charge the code on the first nRF52832 and on the second nRF52832 and you can choose which one is the tester (the Central) and which one is the responder (the Peripheral). Once you choose it, data is sent from tester to responder.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, once I choose which one is the tester and which one is the responder, before send data via ble,&amp;nbsp;start the spis code (in meanwhile I start the spi code in the nRF52840 which send data via spi) which is the part that allow to receive data, then send data via BLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495992?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 11:56:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be133a9b-1aee-44d2-a430-12f904684dce</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2843.ble_5F00_app_5F00_att_5F00_mtu_5F00_throughput.zip"&gt;devzone.nordicsemi.com/.../2843.ble_5F00_app_5F00_att_5F00_mtu_5F00_throughput.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Sorry again&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495987?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 11:44:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dac6a19d-bb9f-4e23-a7e8-906e7de7ce5f</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Can you send me zip that contains your project code? Meaning main.c and any other source file you&amp;#39;ve added.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495956?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 08:56:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73defdfb-8b94-442f-95c1-08215232a323</guid><dc:creator>Ste_</dc:creator><description>&lt;p&gt;Yes, I&amp;#39;m using SEGGER&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495954?ContentTypeID=1</link><pubDate>Mon, 29 Jul 2024 08:55:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c5026eb-4837-4f56-b675-03df001729cb</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for the clear explanation.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The zip file does still not contain any main.c or any other source file as far as I can see. You&amp;#39;re using Segger Embedded Studio as IDE right?&lt;/p&gt;
&lt;p&gt;regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495897?ContentTypeID=1</link><pubDate>Sun, 28 Jul 2024 14:42:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d8484e2-7dc8-4098-a99b-78b4e908472d</guid><dc:creator>Ste_</dc:creator><description>[quote userid="73165" url="~/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput/495773"]So please clarify, when you see log output, what log output you see, and from what device,[/quote]
&lt;p&gt;This is what I see on responder and on tester terminal if I try to integrate my code with SPI code.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722177335781v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;And this is what I see if I run just the code ble_app_att_mtu_throughput:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1722177514224v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;Then, If I comment the SPI part of the code, it runs perfectly. But I need the SPI part.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="73165" url="~/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput/495773"]So you only see the log output if you only connect the client side?[/quote]
&lt;p&gt;Not if I integrate the SPI code&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="73165" url="~/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput/495773"]The project you shared doesn&amp;#39;t contain any source file?[/quote]
&lt;p&gt;Sorry, is it right now?&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/8371.ble_5F00_app_5F00_att_5F00_mtu_5F00_throughput.zip"&gt;devzone.nordicsemi.com/.../8371.ble_5F00_app_5F00_att_5F00_mtu_5F00_throughput.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495773?ContentTypeID=1</link><pubDate>Fri, 26 Jul 2024 08:58:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:188416d7-7001-4b09-b1e8-c985abd1ebbf</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The project you shared doesn&amp;#39;t contain any source file?&lt;/p&gt;
[quote user="Ste_"]Yes, I see the classic log output of ble_app_att_mtu_throughput[/quote]
&lt;p&gt;So you only see the log output if you only connect the client side?&lt;/p&gt;
&lt;p&gt;Because earlier you wrote this:&lt;/p&gt;
[quote user="Ste_"]&lt;p&gt;When I run just ble_app_att_mtu_throughput and I open the PuTTY terminals, I see &amp;quot;this board act as responder&amp;quot; and &amp;quot;this board act as tester.&lt;/p&gt;
&lt;p&gt;This doesn&amp;#39;t happen when I add spi code. I open the two terminals and nothing happen, neither if I push the reset button on the nRF52832 boards&lt;/p&gt;[/quote]
&lt;p&gt;So please clarify, when you see log output, what log output you see, and from what device,&lt;/p&gt;
&lt;p&gt;regards&lt;br /&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Merging spi and ble_app_att_mtu_throughput</title><link>https://devzone.nordicsemi.com/thread/495572?ContentTypeID=1</link><pubDate>Thu, 25 Jul 2024 08:34:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b9c0b2d2-c361-407e-93a2-3c671b0e5b91</guid><dc:creator>Ste_</dc:creator><description>[quote userid="133324" url="~/f/nordic-q-a/113246/merging-spi-and-ble_app_att_mtu_throughput/495564"]Yes, I see the classic log output of ble_app_att_mtu_throughput[/quote]
&lt;p&gt;I mean:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;NRF_LOG_INFO(&amp;quot;ATT MTU example started.&amp;quot;);
NRF_LOG_INFO(&amp;quot;Press button 3 on the board connected to the PC.&amp;quot;);
NRF_LOG_INFO(&amp;quot;Press button 4 on other board.&amp;quot;);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And next the other parts of the code&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>