<?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>Usage of Queued Read and Write</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/83336/usage-of-queued-read-and-write</link><description>Hello everyone, 
 I am using the SDK 17.1 with the NRF52832 chip. My current project is created based on the multirole example. My first step was to implement writing and reading out the characteristic values of my custom service. Its working really good</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 06 Jan 2022 14:09:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/83336/usage-of-queued-read-and-write" /><item><title>RE: Usage of Queued Read and Write</title><link>https://devzone.nordicsemi.com/thread/346510?ContentTypeID=1</link><pubDate>Thu, 06 Jan 2022 14:09:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de647efb-b17a-48e2-87f2-2d3201a4ca68</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Hi Hani,&lt;/p&gt;
&lt;p&gt;If the read is longer than the max MTU size then you need to use the offset field and keep track of how much data you already read.The code you used is good for the first read but you need to extend this some thing like below in the event handler. Please note that i just wrote the code and have not compiled it, so use this as a logic and not as a solution in itself&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static uint32_t remaining_read_count = 500;

static void current_time_read(ble_hrs_c_t * p_ble_hrs_c, ble_evt_t const * p_ble_evt)
{
    ble_cts_c_evt_t evt;
    uint32_t        err_code = NRF_SUCCESS;

    // Check whether the event is on the same connection as this HRS instance
    if (p_ble_hrs_c-&amp;gt;conn_handle != p_ble_evt-&amp;gt;evt.gattc_evt.conn_handle)
    {
        return;
    }
	else
	{
		uint8_t len = p_ble_evt-&amp;gt;evt.gattc_evt.params.read_rsp.len;
		memcpy(&amp;amp;YOUR_DATA_STORAAGE[500-remaining_read_count], p_ble_evt-&amp;gt;evt.gattc_evt.params.read_rsp.data, len);
		remaining_read_count = remaining_read_count - len;
		if(remaining_read_count)
		{
			// initiate another read with offset set to len
			    nrf_ble_gq_req_t hrs_c_req;

				VERIFY_PARAM_NOT_NULL(p_ble_hrs_c);

				memset(&amp;amp;hrs_c_req, 0, sizeof(hrs_c_req));
				hrs_c_req.type                     = NRF_BLE_GQ_REQ_GATTC_READ;
				hrs_c_req.error_handler.cb         = gatt_error_handler;
				hrs_c_req.error_handler.p_ctx      = p_ble_hrs_c;
				hrs_c_req.params.gattc_read.handle = p_ble_hrs_c-&amp;gt;peer_hrs_db.hrm_handle;
				hrs_c_req.params.gattc_read.offset = len;  

				err_code = nrf_ble_gq_item_add(p_ble_hrs_c-&amp;gt;p_gatt_queue, &amp;amp;hrs_c_req, p_ble_hrs_c-&amp;gt;conn_handle);
				// Handle errors if any
		}
	}
}

void ble_hrs_c_on_ble_evt(ble_evt_t const * p_ble_evt, void * p_context)
{
    ble_hrs_c_t * p_ble_hrs_c = (ble_hrs_c_t *)p_context;
    NRF_LOG_DEBUG(&amp;quot;BLE event handler called with event 0x%x&amp;quot;, p_ble_evt-&amp;gt;header.evt_id);

    switch (p_ble_evt-&amp;gt;header.evt_id)
    {
        case BLE_GATTC_EVT_READ_RSP:
            handle_read(p_ble_hrs_c, p_ble_evt);
            break;

        case BLE_GATTC_EVT_HVX:
            on_hvx(p_ble_hrs_c, p_ble_evt);
            break;

        case BLE_GAP_EVT_DISCONNECTED:
            on_disconnected(p_ble_hrs_c, p_ble_evt);
            break;

        default:
            break;
    }
	
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>