<?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>128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19291/128-bit-characteristic-uuid-not-based-on-service-uuid</link><description>Hi Nordic Team, 
 What I want to achieve is to add a service with a custom 128-bit UUID that has about 4 characteristics with a completely different 128-bit UUIDs that are NOT based on the service UUID ? 
 Is that possible ? If so, how can I implement</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Jun 2018 12:21:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19291/128-bit-characteristic-uuid-not-based-on-service-uuid" /><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/138108?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 12:21:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1fd249fd-8341-4133-a59d-ceb02ef5db60</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;You&amp;#39;re welcome :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/138107?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 12:20:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:88159193-04e3-4219-a3a5-5aee93f7766a</guid><dc:creator>kalauffenburger</dc:creator><description>&lt;p&gt;Andy,&lt;/p&gt;
&lt;p&gt;Thanks so much.&amp;nbsp; That did the trick!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/138104?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 12:14:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e460a6a3-55b8-4faf-9d6a-fd1f4738b3ff</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;I&amp;#39;m pretty sure that should have solved it. Try turning off and on airplane mode on your phone, or try rebooting it altogether. I know for a fact that iOS caches BLE services and characteristics and this cache is cleared in those cases. If you&amp;#39;re on Android I&amp;#39;m not so sure how you can do that, but try something similar.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/138087?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 11:28:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9db62e91-2999-4ee4-be35-9812f247413b</guid><dc:creator>kalauffenburger</dc:creator><description>&lt;p&gt;Andy,&lt;/p&gt;
&lt;p&gt;You are right, that was a bug (a vestige of previous attempts to solve this).&amp;nbsp; Thanks.&lt;/p&gt;
&lt;p&gt;Unfortunately, that doesn&amp;#39;t fix the problem though.&lt;/p&gt;
&lt;p&gt;I am still getting the same UUID for the data characteristic as the service.&lt;/p&gt;
&lt;p&gt;--ken&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/138031?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 08:38:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aae8c9c2-79b4-4ad6-a341-4cb99be1aaf1</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;Your problem is that you&amp;#39;re passing different UUIDs to&amp;nbsp;sd_ble_uuid_vs_add().&lt;/p&gt;
&lt;p&gt;Try changing&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;VERIFY_SUCCESS(sd_ble_uuid_vs_add(&amp;amp;m_scs_data_txchar_uuid128, &amp;amp;p_scs-&amp;gt;data_uuid_type));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;VERIFY_SUCCESS(sd_ble_uuid_vs_add(&amp;amp;m_scs_data_txchar_uuid128, &amp;amp;char_uuid.type));
p_scs-&amp;gt;data_uuid_type = char_uuid.type;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/137993?ContentTypeID=1</link><pubDate>Thu, 28 Jun 2018 03:04:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b3f4520-0bc5-433c-8f66-05b926596582</guid><dc:creator>kalauffenburger</dc:creator><description>&lt;p&gt;I am having exactly this problem; my code is essentially the same as above.&amp;nbsp; I don&amp;#39;t know what I am doing wrong.&lt;/p&gt;
&lt;p&gt;What is happening is that the UUID of the data characteristic is the same as the UUID of the service.&lt;/p&gt;
&lt;p&gt;Here is what I am trying to achieve:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot_5F00_2018_2D00_06_2D00_27_5F00_21_2D00_50_2D00_40.png" /&gt;&lt;/p&gt;
&lt;p&gt;Instead, I&amp;#39;m getting this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot_5F00_2018_2D00_06_2D00_27_5F00_21_2D00_59_2D00_23.png" /&gt;&lt;/p&gt;
&lt;p&gt;What am I doing wrong?&lt;/p&gt;
&lt;p&gt;Here is an excerpt of my code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define BLE_UUID_SCS_SERVICE 0x0e04	/**&amp;lt; UUID of the SCS service */
#define BLE_UUID_SCS_DATA    0xb607	/**&amp;lt; UUID of the data characteristic */

typedef struct ble_scs_s ble_scs_t;

/**@brief   Nordic UART Service structure.
 *
 * @details This structure contains status information related to the service.
 */
struct ble_scs_s
{
    uint8_t service_uuid_type;				/**&amp;lt; UUID type for SCS service base UUID */
    uint8_t data_uuid_type;					/**&amp;lt; UUID type for SCS data base UUID. */
    uint16_t service_handle;				/**&amp;lt; Handle for SCS service (as provided by the SoftDevice). */
    ble_gatts_char_handles_t service_handles;	/**&amp;lt; service characteristic handles */
    ble_gatts_char_handles_t data_handles;	    /**&amp;lt; data characteristic handles */
    uint16_t conn_handle;					/**&amp;lt; Handle of current connection */
    bool is_notification_enabled;			/**&amp;lt; Variable to indicate if the peer has enabled notification of the RX characteristic.*/
    ble_scs_data_handler_t data_handler;	/**&amp;lt; Event handler to be called for handling received data. */
};

static ble_uuid128_t const m_scs_base_uuid128 =
{
	{
	   	0x17, 0x76, 0x6f, 0xcf, 0x10, 0x88, 0xbc, 0xb5,
	   	0x6d, 0x4a, 0x61, 0xc2, 0x04, 0x0e, 0xbf, 0xe6
   	}
};

static ble_uuid128_t const m_scs_data_txchar_uuid128 =
{
	{
	   	0x0d, 0xee, 0x3e, 0x5f, 0x8d, 0x2e, 0xfd, 0x97,
	   	0x82, 0x4f, 0xe8, 0xf5, 0x07, 0xb6, 0x25, 0xc7
   	}
};


/**@brief Add data characteristic.
 *
 * @param[in] p_scs       SCS Service structure.
 * @param[in] p_scs_init  Information needed to initialize the service.
 *
 * @return NRF_SUCCESS on success, otherwise an error code.
 */
static uint32_t scs_data_char_add(ble_scs_t *p_scs, ble_scs_init_t const *p_scs_init)
{
    /**@snippet [Adding proprietary characteristic to the SoftDevice] */
    ble_gatts_char_md_t char_md;
    ble_gatts_attr_md_t cccd_md;
    ble_gatts_attr_t attr_char_value;
    ble_uuid_t char_uuid;
    ble_gatts_attr_md_t attr_md;
	uint8_t initial_data[20];

	BLE_UUID_BLE_ASSIGN(char_uuid, BLE_UUID_SCS_DATA);
    VERIFY_SUCCESS(sd_ble_uuid_vs_add(&amp;amp;m_scs_data_txchar_uuid128, &amp;amp;p_scs-&amp;gt;data_uuid_type));

    memset(&amp;amp;cccd_md, 0, sizeof(cccd_md));
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.read_perm);
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.write_perm);
    cccd_md.vloc = BLE_GATTS_VLOC_STACK;

    memset(&amp;amp;char_md, 0, sizeof(char_md));
    char_md.char_props.write  = 1;
    char_md.char_props.indicate = 1;
    char_md.p_char_pf = NULL;
    char_md.p_user_desc_md = NULL;
    char_md.p_cccd_md = &amp;amp;cccd_md;
    char_md.p_sccd_md = NULL;

    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));
	memset(initial_data, 0, sizeof(initial_data));
    attr_char_value.p_uuid = &amp;amp;char_uuid;
    attr_char_value.p_attr_md = &amp;amp;attr_md;
    attr_char_value.init_len = sizeof(initial_data);
    attr_char_value.init_offs = 0;
    attr_char_value.max_len = sizeof(initial_data);
	attr_char_value.p_value = initial_data;

    return sd_ble_gatts_characteristic_add(p_scs-&amp;gt;service_handle,
                                           &amp;amp;char_md,
                                           &amp;amp;attr_char_value,
                                           &amp;amp;p_scs-&amp;gt;data_handles);
}


uint32_t ble_scs_init(ble_scs_t *p_scs, ble_scs_init_t const *p_scs_init)
{
    ble_uuid_t ble_uuid;

    VERIFY_PARAM_NOT_NULL(p_scs);
    VERIFY_PARAM_NOT_NULL(p_scs_init);

    // Initialize the service structure.
    p_scs-&amp;gt;conn_handle = BLE_CONN_HANDLE_INVALID;
    p_scs-&amp;gt;data_handler = p_scs_init-&amp;gt;data_handler;
    p_scs-&amp;gt;is_notification_enabled = false;

    /**@snippet [Adding proprietary Service to the SoftDevice] */
    // Add a custom base UUID.
	BLE_UUID_BLE_ASSIGN(ble_uuid, BLE_UUID_SCS_SERVICE);
    VERIFY_SUCCESS(sd_ble_uuid_vs_add(&amp;amp;m_scs_base_uuid128, &amp;amp;p_scs-&amp;gt;service_uuid_type));

    // Add the service.
    VERIFY_SUCCESS(sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
											&amp;amp;ble_uuid,
										   	&amp;amp;p_scs-&amp;gt;service_handle));

    // Add the data characteristic.
    VERIFY_SUCCESS(scs_data_char_add(p_scs, p_scs_init));

    return NRF_SUCCESS;
}

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thanks for any help you can give.&lt;/p&gt;
&lt;p&gt;--ken&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/135015?ContentTypeID=1</link><pubDate>Wed, 06 Jun 2018 21:26:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea241a51-9970-4856-82b5-397a2063a269</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;It is fairly easy to do. You just need to add a new 128-bit UUID to the BLE stack table and then add a service/characteristic with that UUID.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// To add a service
// Declare 16-bit service and 128-bit base UUIDs and add them to BLE stack table
ret_code_t	err_code;
ble_uuid_t	service_uuid;

BLE_UUID_BLE_ASSIGN(service_uuid, your_16_bit_uuid);

ble_uuid128_t base_uuid = YOUR_CUSTOM_128_BIT_UUID;

// Add the UUID to the BLE stack
err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;service_uuid.type);
APP_ERROR_CHECK(err_code);

// Add your service
err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
                                    &amp;amp;service_uuid,
                                    &amp;amp;service_handle);
APP_ERROR_CHECK(err_code);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// To add a characteristic
// Add a custom characteristic UUID
ret_code_t err_code;
ble_uuid_t char_uuid;
BLE_UUID_BLE_ASSIGN(char_uuid, your_16_bit_uuid);

ble_uuid128_t base_uuid = YOUR_CUSTOM_128_BIT_UUID;

// Add the UUID to the BLE stack
err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;char_uuid.type);
APP_ERROR_CHECK(err_code);

[Initialize all attribute metadata and stuff]
[Copy from any example]

// Add our new characteristic to the service
err_code = sd_ble_gatts_characteristic_add(service_handle,
                                           &amp;amp;char_md,
                                           &amp;amp;attr_char_value,
                                           &amp;amp;custom_char_handles);
APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/134589?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2018 13:55:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:119dc8e4-857a-4a13-b055-49abb983660e</guid><dc:creator>Hannu Hirvonen</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have exactly same problem (or is this challenge). If you have some code example how to do this I will be very happy :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/74778?ContentTypeID=1</link><pubDate>Mon, 30 Jan 2017 14:14:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:839fd610-b955-4b37-aa9c-3af97be1a7de</guid><dc:creator>Aymen Rejeb</dc:creator><description>&lt;p&gt;any hints here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/74777?ContentTypeID=1</link><pubDate>Sat, 28 Jan 2017 08:15:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23f602bd-388c-403b-8b18-da39ffd4a6db</guid><dc:creator>Aymen Rejeb</dc:creator><description>&lt;p&gt;Could you please be so kind and provide me a code example showing the right way to that?
Many thanks in advance.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: 128-bit Characteristic UUID not based on  Service UUID</title><link>https://devzone.nordicsemi.com/thread/74776?ContentTypeID=1</link><pubDate>Sat, 28 Jan 2017 01:10:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f1d3d078-af05-4fe1-93eb-3fdc12bef1a7</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Of course you can do it - you can use any UUID for a service or a characteristic and they don&amp;#39;t have to be related in any way at all, they can be totally random.&lt;/p&gt;
&lt;p&gt;And how? Just come up with your 5 UUIDs, register the service under one of them and the characteristics under the other ones, every registration method takes a UUID, just supply them.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>