<?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>Sending 32 bit of data over BLE onto nrf52832</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/50415/sending-32-bit-of-data-over-ble-onto-nrf52832</link><description>Hi, 
 I have used &amp;quot;write_handler(p_ble_evt-&amp;gt;evt.gap_evt.conn_handle, p_rtc_service, p_evt_write-&amp;gt;data[0]);&amp;quot; to send data to nrf52832 from mobile but iam able to send 1 byte data as it is meant to be predefined in the gatts structure i.e 
 If i want to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 Jul 2019 21:06:33 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/50415/sending-32-bit-of-data-over-ble-onto-nrf52832" /><item><title>RE: Sending 32 bit of data over BLE onto nrf52832</title><link>https://devzone.nordicsemi.com/thread/201365?ContentTypeID=1</link><pubDate>Tue, 30 Jul 2019 21:06:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:36d62df6-f1e1-4f13-b93b-ab28ffc90772</guid><dc:creator>BinderT</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Just no,&lt;br /&gt;&lt;br /&gt;Split your 32 bit data into an array of uint8_t(s) and and set that array equal to ble_gatts_evt_write_t -&amp;gt;data.&amp;nbsp;&lt;span&gt;ble_gatts_evt_write_t -&amp;gt;len should be set as the length of data sent in bytes.&lt;br /&gt;&lt;br /&gt;example code&lt;br /&gt;&lt;/span&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ble_gatts_evt_write_t params;

uint32_t data = 0x12345678

uint8_t buffer[sizeof(uint32_t)];


void set_data(uint32_t *data, uint8_t *buffer,uint16_t len){
    memcpy(buffer,data,len);
}


void main(void){
    set_data(&amp;amp;data,buffer,sizeof(buffer));
    // buffer = {78,56,34,12}
    
    params.data = data;
    params.len = sizeof(uint32_t)
    
}
&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;data[1] is a pointer to the start of an array of uint8_t(s).&lt;br /&gt;&lt;br /&gt;Example of sending more than one byte of data as a notification.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_packet_send(
		ble_service_t * p_service, // service handle
		packet_u * p_packet){ // data to send

		uint32_t err_code = NRF_SUCCESS;

		if (p_service-&amp;gt;conn_handle != BLE_CONN_HANDLE_INVALID) {
			ble_gatts_hvx_params_t hvx_params;
			uint8_t encoded_value[sizeof(packet_u)]; // array to split data
			uint16_t hvx_len;

			// Initialize value struct.
			memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

			hvx_len = ble_encode(p_respons_packet, encoded_value); // lenght in bytes 
			hvx_params.handle =p_service-&amp;gt;ble_handles.value_handle;
			hvx_params.type = BLE_GATT_HVX_NOTIFICATION;
			hvx_params.p_len = &amp;amp;hvx_len;
			hvx_params.offset = 0;
			hvx_params.p_data = encoded_value; //split data to send

			err_code = sd_ble_gatts_hvx(p_service-&amp;gt;conn_handle,&amp;amp;hvx_params);
		} else {
			err_code = NRF_ERROR_INVALID_STATE;
		}

		return err_code;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You should also set&amp;nbsp;ble_add_char_params_t.max_len to the size of the data in bytes you intend to send in you service init.&lt;br /&gt;&lt;br /&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>