<?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>How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27003/how-do-i-create-my-own-service-on-the-ble-stack</link><description>I&amp;#39;ve sifted through the examples given to me, and none of them seem to explain how to create your own service and add it to the stack. All of the services that are registered in the ble examples (nRF51 nordic pca10001) have their own header and c files</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Dec 2017 15:59:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27003/how-do-i-create-my-own-service-on-the-ble-stack" /><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105911?ContentTypeID=1</link><pubDate>Mon, 04 Dec 2017 15:59:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ed3fb75-1a73-46a3-a46d-f294e24cd43b</guid><dc:creator>Raja</dc:creator><description>&lt;p&gt;Link does not work&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105913?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2017 14:46:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb7f4734-4a6a-40bf-87ab-22b82f0a71f2</guid><dc:creator>phipi</dc:creator><description>&lt;p&gt;Broken link&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105910?ContentTypeID=1</link><pubDate>Wed, 09 Oct 2013 12:14:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f3d74424-f3fb-42d4-bc88-1a69f2694c02</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;An application note explaining how to build a custom service is now out. Get it here: &lt;a target="_blank" href="https://www.nordicsemi.com/eng/nordic/download_resource/24020/2/80193304" rel="nofollow"&gt;https://www.nordicsemi.com/eng/nordic/download_resource/24020/2/80193304&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105909?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 16:37:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e32c7d9c-9c48-48e1-9423-34d43ce1ab26</guid><dc:creator>Alex Lynchosky</dc:creator><description>&lt;p&gt;Ahh thank you this helps a lot! From the 10,000 foot level it looked as though all their services depended on each other, but knowing that I can single one out will make things much easier.&lt;/p&gt;
&lt;p&gt;Thank you very much for bearing with my naivete!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105912?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 16:31:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7c5171a-77af-413e-a651-8b43782fd2c2</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;I&amp;#39;m sorry that I misunderstood you, but I&amp;#39;ve provided a new answer now, that explains the flow a little better.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105908?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 16:30:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f0a7dc4-4cd0-49d8-99de-59aef21bd555</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;To create a custom service, you should try to follow the general flow of the existing services, and mor or less copy them. The battery service (ble_bas.c/ble_bas.h) is probably the simplest one, and should provde a good starting point.&lt;/p&gt;
&lt;p&gt;If you look at it, you can see that the init function first adds a service, using the sd_ble_gatts_service_add() function, then calls an internal function to add a characteristic. This internal functions sets up a lot of parameter structures, that in different ways affect the characteristic added.&lt;/p&gt;
&lt;p&gt;Most services also needs to know what happens on run-time, so you need to create a event handler to handle events coming from the stack. This should be named service_name_on_ble_evt(), and be called from the applications main.c-file&amp;#39;s ble_evt_dispatch() method.&lt;/p&gt;
&lt;p&gt;Finally, most services also need some API function to actually do something useful, for example the battery service&amp;#39;s method to update the measured battery value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105906?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 15:15:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a3c4775-bd22-4bc3-a81d-61da7d7d463c</guid><dc:creator>Alex Lynchosky</dc:creator><description>&lt;p&gt;I&amp;#39;ve looked at the example, and it helps a lot, thanks! But the one part that I really needed help on it just tells me to fill in myself. The function,
static void services_init(void)
{
// YOUR_JOB: Add code to initialize the services used by the application.
}&lt;/p&gt;
&lt;p&gt;is the one that I have no idea how to do! This is where the other ble examples dive into their 20 file infrastructure that I can&amp;#39;t quite follow. I just need to create one simple bare-bones service to get my foot in the door.&lt;/p&gt;
&lt;p&gt;Carles was nice enough to provide me with these functions:&lt;/p&gt;
&lt;p&gt;sd_ble_gatts_service_add
sd_ble_gatts_include_add
sd_ble_gatts_characteristic_add
sd_ble_gatts_descriptor_add&lt;/p&gt;
&lt;p&gt;but I&amp;#39;m not sure how to use them.&lt;/p&gt;
&lt;p&gt;Do you know how to implement these?&lt;/p&gt;
&lt;p&gt;Thanks again!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105907?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 12:30:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e14130f3-eee2-47de-a73a-02a468ab38e8</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;If by &amp;quot;create your own service&amp;quot; you mean simply adding a service to the ATT table so it&amp;#39;s visible to all GATT clients connecting to your application, then it&amp;#39;s simply a matter of using the provided APIs:&lt;/p&gt;
&lt;p&gt;sd_ble_gatts_service_add
sd_ble_gatts_include_add
sd_ble_gatts_characteristic_add
sd_ble_gatts_descriptor_add&lt;/p&gt;
&lt;p&gt;All those APIs can be used both with 16-bit UUIDs (for SIG approved services) and 128-bit UUIDs (if you are designing your own proprietary services).&lt;/p&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105905?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 05:17:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55618796-cbaf-47b0-bc1d-e68bb3cd287f</guid><dc:creator>Ole Morten</dc:creator><description>&lt;p&gt;This is absolutely correct, and this is a base principle of BLE; all services and profiles are implemented in the application and not in the stack. This makes custom services much easier to create and use.&lt;/p&gt;
&lt;p&gt;Please also see these questions:
&lt;a target="_blank" href="http://devzone.nordicsemi.com/index.php/is-there-a-serial-port-profile-for-ble" rel="nofollow"&gt;http://devzone.nordicsemi.com/index.php/is-there-a-serial-port-profile-for-ble&lt;/a&gt;
&lt;a target="_blank" href="http://devzone.nordicsemi.com/index.php/what-is-the-most-efficient-way-to-transfer-data-over-ble" rel="nofollow"&gt;http://devzone.nordicsemi.com/index.php/what-is-the-most-efficient-way-to-transfer-data-over-ble&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I create my own service on the BLE stack?</title><link>https://devzone.nordicsemi.com/thread/105904?ContentTypeID=1</link><pubDate>Thu, 27 Jun 2013 04:57:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef688586-78a9-493b-ac24-c8ca65e21d54</guid><dc:creator>Tielman</dc:creator><description>&lt;p&gt;Hi Alex&lt;/p&gt;
&lt;p&gt;A good place to start would be the ble_app_template example. I created one generic working service from there and used it to build multiple of my own services.&lt;/p&gt;
&lt;p&gt;Unfortunately you will not be able to move away from using .c and .h files to configure your services. If you look at figure 2 on page 7 of the softdevice specification, you will see that the setup of services and attributes is the responsibility of your app. Even though the Softdevice hosts the GAPP server, the configuration is up to the you.
As far as adding your own service to the stack: This is not possible since the stack is a pre-compiled .hex file supplied by Nordic. You can simply send your setup and configuration at runtime to the stack to configure the GATT server.&lt;/p&gt;
&lt;p&gt;Hope this helps a bit&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>