<?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>Sample code to add a Custom BLE Service on nRF82540DK using nRF Connect SDK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/66803/sample-code-to-add-a-custom-ble-service-on-nrf82540dk-using-nrf-connect-sdk</link><description>Hi nRF support team, 
 I am trying to add a new Custom Service and Characteristic an application on nRF82540 development kit using the nRF Connect SDK. 
 Can you please let me know the instructions on how to add a custom service and characteristic? It</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 31 Dec 2024 05:04:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/66803/sample-code-to-add-a-custom-ble-service-on-nrf82540dk-using-nrf-connect-sdk" /><item><title>RE: Sample code to add a Custom BLE Service on nRF82540DK using nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/516550?ContentTypeID=1</link><pubDate>Tue, 31 Dec 2024 05:04:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45f2f88c-109f-4efe-b964-4da093fe473f</guid><dc:creator>Nguyen Kha Duong</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;I followed your tutorial for create a new service by copy your source to flask on my board, but it&amp;#39;s not received device name when I use NRF connect. Please help me solution.&amp;nbsp;&lt;br /&gt;&lt;a id="" href="https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-4-bluetooth-le-data-exchange/topic/blefund-lesson-4-exercise-1/"&gt;https://academy.nordicsemi.com/courses/bluetooth-low-energy-fundamentals/lessons/lesson-4-bluetooth-le-data-exchange/topic/blefund-lesson-4-exercise-1/&lt;/a&gt;&lt;br /&gt;&lt;a href="https://github.com/NordicDeveloperAcademy/bt-fund/blob/main/v2.8.x-v2.7.0/l4/l4_e1_sol/src/main.c"&gt;github.com/.../main.c&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sample code to add a Custom BLE Service on nRF82540DK using nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/273825?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 14:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c9cb2aaa-a829-4ad7-ae9e-6d632fc7c697</guid><dc:creator>Kalyan Agepati</dc:creator><description>&lt;p&gt;Hi Edvin,&lt;/p&gt;
&lt;p&gt;Thanks for the response and instructions to add new Custom Service.&lt;/p&gt;
&lt;p&gt;I have implemented to added a new custom service under&amp;nbsp;folder path ncs\zephyr\subsys\bluetooth\services and created custom.c file similar as bas.c and header file&amp;nbsp;custom.h at ncs\zephyr\include\bluetooth\services. I am able to verify the custom gatt service in the light blue app.&lt;/p&gt;
&lt;p&gt;Code looks like as you mentioned above macros. Thanks for the instructions.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Kalyan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sample code to add a Custom BLE Service on nRF82540DK using nRF Connect SDK</title><link>https://devzone.nordicsemi.com/thread/273787?ContentTypeID=1</link><pubDate>Thu, 08 Oct 2020 13:47:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96f26bf1-aeb1-4678-b798-6eed112ab4c9</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;I assume you refer to the nRF52840, just to clear any misunderstandings&amp;nbsp;&lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;We don&amp;#39;t have much other than the examples in the folder NCS\nrf\samples\bluetooth&lt;br /&gt;&lt;br /&gt;I suggest you check out the example peripheral_uart. This is an example that uses a custom BLE service (custom meaning that this service is not a standardized BLE service). &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;In main.c you can see that the nus.h file is included:&lt;br /&gt;&lt;br /&gt;#include &amp;lt;bluetooth/services/nus.h&amp;gt;&lt;br /&gt;This file is located in NCS\nrf\include\bluetooth\services\nus.h&lt;br /&gt;The complimentary .c file is nus.c in NCS\nrf\subsys\bluetooth\services\nus.c&lt;br /&gt;&lt;br /&gt;The &amp;quot;main thread&amp;quot; in this example is the &amp;quot;led_blink_thread&amp;quot;. There you can see the &lt;br /&gt;err = bt_enable(NULL);&lt;br /&gt;which enables the BLE stack, and:&lt;br /&gt;err = bt_gatt_nus_init(&amp;amp;nus_cb);&lt;br /&gt;which initializes the nus (Nordic UART Service), which is the custom BLE service in this example.&lt;br /&gt;&lt;br /&gt;Actually, it is not entirely true that this function intializes this service, but you can look at the nuc.c/h to see how to set up a service. It is the macros in nuc.c:&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;/* UART Service Declaration */
BT_GATT_SERVICE_DEFINE(nus_svc,
BT_GATT_PRIMARY_SERVICE(BT_UUID_NUS_SERVICE),
	BT_GATT_CHARACTERISTIC(BT_UUID_NUS_TX,
			       BT_GATT_CHRC_NOTIFY,
			       BT_GATT_PERM_READ,
			       NULL, NULL, NULL),
	BT_GATT_CCC(NULL, BT_GATT_PERM_READ | BT_GATT_PERM_WRITE),
	BT_GATT_CHARACTERISTIC(BT_UUID_NUS_RX,
			       BT_GATT_CHRC_WRITE |
			       BT_GATT_CHRC_WRITE_WITHOUT_RESP,
			       BT_GATT_PERM_READ | BT_GATT_PERM_WRITE,
			       NULL, on_receive, NULL),
);&lt;/pre&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Use this as a starting point, and let me know if you get stuck.&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;Best regards,&lt;/div&gt;
&lt;div&gt;Edvin&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>