<?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 data</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5823/sending-data</link><description>Hi all, 
 I have a small question. If a GATT server needs to send data to a GATT client(about 65 bytes), does it have to create a service first and then adds characteristic, or it can use directly sd_gap_gatts_hvx function()? 
 Regards, 
 mohBOSS.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Mar 2015 10:23:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5823/sending-data" /><item><title>RE: Sending data</title><link>https://devzone.nordicsemi.com/thread/20343?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2015 10:23:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3980a2ae-31da-4f8d-975b-20375062c6e2</guid><dc:creator>mohBOSS</dc:creator><description>&lt;p&gt;Thank you Carles. I was sure that I was confusing something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending data</title><link>https://devzone.nordicsemi.com/thread/20342?ContentTypeID=1</link><pubDate>Wed, 04 Mar 2015 10:05:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7fbb757-25e7-48d3-b7be-ac351481cc30</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When you add a service and then a characteristic, you are just populating your own attribute table, and adding a placeholder to then be able to store data (inside the characteristic) that can then be filled in by your application, read by the peer client and updated (via hvx()) by you.&lt;/li&gt;
&lt;li&gt;I think you are confusing terms here. The client can read your characteristic value at any time and it will get the current value that is in memory. You can change that value locally by calling sd_ble_gatts_value_set(). Independently of that you can notify (i.e. push an update) the client whenever you want by calling sd_ble_gatts_hvx().&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending data</title><link>https://devzone.nordicsemi.com/thread/20346?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2015 10:14:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84ecc389-3d0a-49d4-9e01-791263114f9c</guid><dc:creator>mohBOSS</dc:creator><description>&lt;p&gt;Hi, please I have some questions.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When adding a service then a characteristic, this enables the SoftDevice to send BLE events to the application whenever a client wants to use the characteristic. Is that right ?&lt;/li&gt;
&lt;li&gt;If a client wants to read data (without authorization) from the server, then how can the server use sd_ble_gatts_hvx() if there is no event generated for a Read Request without Authorization  to notify the application?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;I hope that you understand me. Thanks a lot.&lt;/p&gt;
&lt;p&gt;mohBOSS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending data</title><link>https://devzone.nordicsemi.com/thread/20345?ContentTypeID=1</link><pubDate>Tue, 03 Mar 2015 09:08:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65929a24-a3b8-4c27-9272-9c30cec8a07b</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;Not sure about ble_lbs_t, it&amp;#39;s not something that&amp;#39;s part of the SoftDevice.
What I would recommend for simple data transmission as a service is to take a look at:&lt;/p&gt;
&lt;p&gt;Service:
components/ble/ble_services/ble_nus&lt;/p&gt;
&lt;p&gt;Example using the service:
examples/ble_peripheral/ble_app_uart&lt;/p&gt;
&lt;p&gt;The function call to:
ble_nus_string_send()&lt;/p&gt;
&lt;p&gt;is what you need. It sends a notification with arbitrary data.&lt;/p&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending data</title><link>https://devzone.nordicsemi.com/thread/20344?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2015 16:14:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b436266e-baf1-4e57-9d8e-87d7c6d8dc3a</guid><dc:creator>mohBOSS</dc:creator><description>&lt;p&gt;Hi Carles,&lt;/p&gt;
&lt;p&gt;In fact I need to be a server, in order to send data to the client. I can not understand yet how to make a service that can be used by the client to read data. So far I have adapted this code for my needs.&lt;/p&gt;
&lt;p&gt;static uint32_t characteristic_add(ble_lbs_t * p_lbs)
{
ble_gatts_char_md_t char_md;
ble_gatts_attr_t    attr_char_value;
ble_uuid_t          ble_uuid;
ble_gatts_attr_md_t attr_md;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;memset(&amp;amp;char_md, 0, sizeof(char_md));

char_md.char_props.read   = 1;
char_md.char_props.write  = 1;
char_md.char_ext_props.reliable_wr = 1;
char_md.p_char_user_desc  = NULL;
char_md.p_char_pf         = NULL;
char_md.p_user_desc_md    = NULL;
char_md.p_cccd_md         = NULL;
char_md.p_sccd_md         = NULL;

ble_uuid.type = p_lbs-&amp;gt;uuid_type;
ble_uuid.uuid = LBS_UUID_LED_CHAR;

memset(&amp;amp;attr_md, 0, sizeof(attr_md));

BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;attr_md.read_perm);
BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;attr_md.write_perm);

attr_md.vloc       = BLE_GATTS_VLOC_STACK;
attr_md.rd_auth    = 0;
attr_md.wr_auth    = 0;
attr_md.vlen       = 1;

memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

attr_char_value.p_uuid       = &amp;amp;ble_uuid;
attr_char_value.p_attr_md    = &amp;amp;attr_md;
attr_char_value.init_len     = sizeof(uint8_t);
attr_char_value.init_offs    = 0;
attr_char_value.max_len      = 30;
attr_char_value.p_value      = NULL;

return sd_ble_gatts_characteristic_add(p_lbs-&amp;gt;service_handle, &amp;amp;char_md,
                                           &amp;amp;attr_char_value,
                                           &amp;amp;p_lbs-&amp;gt;led_char_handles);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;But I can&amp;#39;t replace the ble_lbs_t type with what I need.&lt;/p&gt;
&lt;p&gt;I hope You are understanding me Dear Carles.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending data</title><link>https://devzone.nordicsemi.com/thread/20341?ContentTypeID=1</link><pubDate>Mon, 02 Mar 2015 15:56:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ef3724e-a928-420b-9391-0596c772d5ca</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;You will need to add a service and a characteristic to send arbitrary data. Once you have the handle to the characteristic you can use sd_ble_gatts_hvx() to send data. Alternatively, if it&amp;#39;s easier for you, you can add the service and characteristic on the peer device and use sd_ble_gattc_write() to send data, acting as a GATT client.&lt;/p&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>