<?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>ble sending 4 bytes of data with custom service</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/74128/ble-sending-4-bytes-of-data-with-custom-service</link><description>Hello i am trying to send 4 bytes of data over ble with custom service but im getting an unknown error and i am stuck in a dead end please help me .I am greatfull to any kind of help . 
 this is my main function 
 
 
 at 181 i have this 
 
 this is my</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 21 Apr 2021 11:36:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/74128/ble-sending-4-bytes-of-data-with-custom-service" /><item><title>RE: ble sending 4 bytes of data with custom service</title><link>https://devzone.nordicsemi.com/thread/306073?ContentTypeID=1</link><pubDate>Wed, 21 Apr 2021 11:36:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e011268-26e8-43d5-8d6a-483f525d57cb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;m_conn_handle is usually assigned in the CONNECTED event. This is from the ble_app_template example in SDK 17.0.2:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;case BLE_GAP_EVT_CONNECTED:
    NRF_LOG_INFO(&amp;quot;Connected.&amp;quot;);
    err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
    APP_ERROR_CHECK(err_code);
    m_conn_handle = p_ble_evt-&amp;gt;evt.gap_evt.conn_handle;
    err_code = nrf_ble_qwr_conn_handle_assign(&amp;amp;m_qwr, m_conn_handle);
    APP_ERROR_CHECK(err_code);
    break;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble sending 4 bytes of data with custom service</title><link>https://devzone.nordicsemi.com/thread/305650?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 18:57:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d87dfbfa-5e29-4cbe-a295-56121d28723f</guid><dc:creator>kefom</dc:creator><description>&lt;p&gt;i think my error is caused because i cant change connection handle it stays as&amp;nbsp;BLE_CONN_HANDLE_INVALID and i tried some coding and now when i connect to the device my connection handle becames 0&amp;nbsp; &amp;quot;m_conn_handle = 0&amp;quot; so it becames null what can i do to fix this thanks again for your help.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Efe&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble sending 4 bytes of data with custom service</title><link>https://devzone.nordicsemi.com/thread/305641?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 17:12:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10eddecb-e564-4739-a4ca-b3c073fdc63a</guid><dc:creator>kefom</dc:creator><description>&lt;p&gt;Hi Jorgen first of all thank you now its not giving any error but again its not updating data my init data is 0 and it always stays like that it does not change and like i said i dont get any error message&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;static void pres_value_update(presvalue)
{
ret_code_t err_code;
err_code = ble_cus_pres_level_update(&amp;amp;m_cus, presvalue , m_conn_handle);
if(err_code != NRF_SUCCESS &amp;amp;&amp;amp;
err_code != NRF_ERROR_INVALID_STATE &amp;amp;&amp;amp;
err_code != NRF_ERROR_RESOURCES &amp;amp;&amp;amp;
err_code != NRF_ERROR_BUSY &amp;amp;&amp;amp;
err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING &amp;amp;&amp;amp;
err_code != BLE_ERROR_INVALID_CONN_HANDLE)
{ 
APP_ERROR_CHECK(err_code);
}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i am putting a stop point here but i cant see the value of err_code do you have any guess what the problem could be ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards and thanks&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Efe&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ble sending 4 bytes of data with custom service</title><link>https://devzone.nordicsemi.com/thread/305583?ContentTypeID=1</link><pubDate>Mon, 19 Apr 2021 13:46:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41b26550-3355-4f2a-bdc0-870da9c23dfa</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t find any error codes corresponding to that value, but my guess would be that&amp;nbsp;ble_cus_pres_level_update() is called with&amp;nbsp;p_cus-&amp;gt;conn_handle = BLE_CONN_HANDLE_INVALID, which will cause it to return without any return statement. The return code could then possibly be some garbage data from RAM (it looks like it could be a pointer-address).&amp;nbsp;Try returning an error from all calls, for instance like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;uint32_t ble_cus_pres_level_update(ble_cus_t * p_cus, uint32_t presvalue, uint16_t conn_handle)
{
	if (p_cus-&amp;gt;conn_handle != BLE_CONN_HANDLE_INVALID)
	{
		ble_gatts_hvx_params_t params;
		uint16_t len = sizeof(presvalue);

		memset(&amp;amp;params, 0, sizeof(params));
		params.type   = BLE_GATT_HVX_NOTIFICATION;
		params.handle = p_cus-&amp;gt;bme280_presvalue_char_handles.value_handle;
		params.p_data = (uint8_t*)presvalue;
		params.p_len  = &amp;amp;len;

		 return sd_ble_gatts_hvx(p_cus-&amp;gt;conn_handle, &amp;amp;params);
	}
	else
	{
		return BLE_ERROR_INVALID_CONN_HANDLE;
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Then you can filter this error code like the others:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void pres_value_update(presvalue)
{
    ret_code_t err_code;
    err_code = ble_cus_pres_level_update(&amp;amp;m_cus, presvalue , m_conn_handle);
    if(err_code != NRF_SUCCESS &amp;amp;&amp;amp;
    err_code != NRF_ERROR_INVALID_STATE &amp;amp;&amp;amp;
    err_code != NRF_ERROR_RESOURCES &amp;amp;&amp;amp;
    err_code != NRF_ERROR_BUSY &amp;amp;&amp;amp;
    err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING &amp;amp;&amp;amp;
    err_code != BLE_ERROR_INVALID_CONN_HANDLE)
    { 
        APP_ERROR_CHECK(err_code);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>