<?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>I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84913/i-want-to-solve-the-problem-that-the-characteristic-value-is-not-the-set-value</link><description>Hello. 
 It is being developed using nrf52832 (S132 v7.0.1, SDK v17.0.0) as a peripheral device. 
 Previously, I inquired about how to add a value to the characteristic with this ticket , the error no longer occurs, I can connect, I can confirm that the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Mar 2022 09:41:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84913/i-want-to-solve-the-problem-that-the-characteristic-value-is-not-the-set-value" /><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/359750?ContentTypeID=1</link><pubDate>Thu, 24 Mar 2022 09:41:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a89db1d6-aaa8-45e4-9057-a705a52945fb</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Good to hear you solved the issue. I did not spot that, but it makes full sense. Thank you for letting us know!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/359700?ContentTypeID=1</link><pubDate>Thu, 24 Mar 2022 04:20:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b9053d9-69e2-4104-b74e-b9b0b7fc17d1</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;As a result of repeated investigations, we were able to solve the problem.&lt;/p&gt;
&lt;p&gt;The cause is that the setting of &amp;quot;is_value_user&amp;quot; was wrong as described in the code example. Previously, I wasn&amp;#39;t using &amp;quot;is_value_user&amp;quot;, so it worked fine.&lt;/p&gt;
&lt;p&gt;The code said &amp;quot;.is_value_user = BLE_GATTS_VLOC_STACK&amp;quot;, but &amp;quot;.is_value_user = false&amp;quot; was correct. Now that I&amp;#39;ve corrected the code, I can read the settings.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/356326?ContentTypeID=1</link><pubDate>Fri, 04 Mar 2022 13:45:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:90b9151d-24c5-486d-b21c-a4f06abe7286</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Most of the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/examples_ble_peripheral.html"&gt;BLE peripheral examples&lt;/a&gt; in the SDK includes a characteristic that is written to that you can read (though most also notify it, so you may want to disable notification if you pick for instance the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/ble_sdk_app_hrs.html"&gt;Heart Rate Application example&lt;/a&gt;).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/356300?ContentTypeID=1</link><pubDate>Fri, 04 Mar 2022 12:56:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:06a7aba3-5fac-476e-9f5d-4e78d90ad4fc</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;I have confirmed that the response is returned when connecting with nRF Connect. However, the values are different.&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t had time to create a minimal example.&lt;br /&gt;Is there an example in the SDK?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/355000?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 11:20:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:61336b0c-8c06-49cd-b309-a48b8e49d141</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;You do not get an even in the nRF indicating that the read response has been sent. But it will be, and if it is not being delivered for some reason, then after several attempted retransmissions, the link will be disconnected with timeout as disconnect reason. As long as this does not happen, the data has been exchanged.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/354946?ContentTypeID=1</link><pubDate>Fri, 25 Feb 2022 08:38:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0aa73a5b-9665-4e31-9ff1-c04bf8d6f842</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;I thought that by implementing it with reference to the post, the data could be sent correctly, so I added the code.&lt;br /&gt;However, I don&amp;#39;t check the received data, so I&amp;#39;d like to have the stack process it all.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m checking the process again, but I haven&amp;#39;t solved the problem yet.&lt;/p&gt;
&lt;p&gt;One question is, in response to a Read Request, a Read Response is returned. Is there a way to confirm that this Read Response has been sent? Will any event occur?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/354281?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 08:35:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:330ffcb6-0929-469a-9363-897ae6738861</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I see you now added code for authorization. Do you need this? (I&amp;nbsp;mentioned it in my previously post as an&amp;nbsp;explanation for why you don&amp;#39;t get an event in your case, but not as a suggestion that you should do it).&lt;/p&gt;
[quote user="sdi_kei"]How can I read the value I set?[/quote]
&lt;p&gt;If you don&amp;#39;t use authorization, the stack&amp;nbsp;will&amp;nbsp;handle everything for you. As long as you update the value with&amp;nbsp;sd_ble_gatts_value_set(), that value will be read when you read it. There is not really much more to say.&lt;/p&gt;
&lt;p&gt;I suggest the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First figure out if. you need authorization or not. I have not seen any indication you do. If not, remove it.&lt;/li&gt;
&lt;li&gt;Make a example that I can test on my end on a DK and explain how to test it.,&lt;/li&gt;
&lt;li&gt;I will test and see if I spot the issue.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The reason for the above is that as mentioned, this&amp;nbsp;should just work, and I am not able to spot the error. But as I am not seeing everything you do, there might be some issue somewhere else, or I might overlook something. So giving me a minimal failing&amp;nbsp;example that I can run on my end should help to find the issue faster.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/354249?ContentTypeID=1</link><pubDate>Tue, 22 Feb 2022 04:36:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c11745c7-a541-40f5-8bd5-e9f29908c33e</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/84913/i-want-to-solve-the-problem-that-the-characteristic-value-is-not-the-set-value/354077#354077"]You do not normally get a event on read requests, that is handled by the stack all by itself (you can use authorization if you need to though, see for instance &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/42613/event-form-read-request/166472#166472"&gt;this post&lt;/a&gt;).[/quote]
&lt;p&gt;I created the process by referring to the link you gave me. However, when I connected and checked with nRF Connect, the data (0x00) at the 0x00000000 address was read as in the current phenomenon.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    case BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST:
            ble_char_read_evt(p_ble_evt);
            break;
    
    return;     
}

static void ble_char_read_evt(ble_evt_t const * p_ble_evt)
{
    ble_gatts_rw_authorize_reply_params_t reply_params;
    ble_gatts_evt_rw_authorize_request_t  const * p_evt_rw_auth = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.authorize_request;
    ret_code_t err_code;
    uint8_t    reply_data = 0x01;

    memset(&amp;amp;reply_params, 0, sizeof(ble_gatts_rw_authorize_reply_params_t));

    reply_params.type = BLE_GATTS_AUTHORIZE_TYPE_READ;
    reply_params.params.read.gatt_status = BLE_GATT_STATUS_SUCCESS;
    reply_params.params.read.update = 0x01;
    reply_params.params.read.offset = 0x00;
    reply_params.params.read.len = 0x01;
    reply_params.params.read.p_data = &amp;amp;reply_data;

    err_code = sd_ble_gatts_rw_authorize_reply(p_ble_evt-&amp;gt;evt.common_evt.conn_handle, &amp;amp;reply_params);
    APP_ERROR_CHECK(err_code);

    return;
}&lt;/pre&gt;&lt;/p&gt;
[quote userid="7377" url="~/f/nordic-q-a/84913/i-want-to-solve-the-problem-that-the-characteristic-value-is-not-the-set-value/354077#354077"]I am not sure about 8 byte, as the code her clearly only works with 1 byte, and that is also the max length you specified.[/quote]
&lt;p&gt;The explanation was insufficient. I&amp;#39;m sorry.&lt;br /&gt;The code described in DevZone says that it works with 1Byte, but I also confirmed the operation with the pattern that changed this to 8Byte. This is because it is not possible to know from which address the data is being referenced with only 1 byte.&lt;/p&gt;
&lt;p&gt;In the code I wrote, I set 0x01 to the characteristic, so I should be able to read 0x01, but in my case, it reads the data (0x00) at the address 0x00000000.&lt;/p&gt;
&lt;p&gt;How can I read the value I set?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/354077?ContentTypeID=1</link><pubDate>Mon, 21 Feb 2022 09:56:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ba1fdd5-bb07-4319-96e7-50f13085ab0b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="sdi_kei"]Since the characteristic is set to read, it is assumed that a Read Request will be received from the connected BLE device (nRF Connect) and the data will be acquired.[/quote]
&lt;p&gt;You do not normally get a event on read requests, that is handled by the stack all by itself (you can use authorization if you need to though, see for instance &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/42613/event-form-read-request/166472#166472"&gt;this post&lt;/a&gt;).&lt;/p&gt;
[quote user="sdi_kei"]In this code, it is 1Byte, but when I set the data of about 8Byte and acquired it with a BLE device, it was the same value as the address 0x00000000 in the memory. Why is the data at address 0x00000000 sent?[/quote]
&lt;p&gt;I am not sure about 8 byte, as the code her clearly only works with 1 byte, and that is also the max length you specified. With this code you should always read 1, as you set the value to one after&amp;nbsp;adding&amp;nbsp;the characteristic. From what I see you should always receive 0x01 with this code. Perhaps there is another issue somewhere else?&lt;/p&gt;
&lt;p&gt;If you cannot share your code, perhaps you can make a minimal failing example with just the relevant parts that I can run on my end.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/354026?ContentTypeID=1</link><pubDate>Mon, 21 Feb 2022 06:46:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b4fc54a-9021-47f4-bf4b-54ddb5e54377</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;Since the actual code cannot be published, some contents are different, but we are considering such code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// UUID Setting
#define ADV_UUID_BASE     {0x77, 0x77, 0x66, 0x66, 0x55, 0x55, 0x44, 0x44, 0x33, 0x33, 0x22, 0x22, 0x11, 0x11, 0x00, 0x00}
#define SERVICE_UUID_BASE {0x0F, 0x0E, 0x0D, 0x0C, 0x0B, 0x0A, 0x09, 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00}
#define CHAR_UUID_BASE    {0xF0, 0xE0, 0xD0, 0xC0, 0xB0, 0xA0, 0x90, 0x80, 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, 0x00}
#define BLE_UUID_CHAR     {0x1234}

#define BLE_UUID_CHAR_MAX {1}

// Connection Handle
static uint16_t                 m_service_handle;   /**&amp;lt; Handle of local service (as provided by the BLE stack).*/
static ble_gatts_char_handles_t m_char_handles;     /**&amp;lt; Handles of local characteristic (as provided by the BLE stack).*/
static uint16_t                 conn_handle;

// Characteristic
static ble_add_char_params_t char_test_data = 
{
    .uuid                = BLE_UUID_CHAR,
    .uuid_type           = NULL,
    .max_len             = 1,
    .init_len            = 1,
    .is_var_len          = false,
    .char_props.read     = 1,
    .read_access         = SEC_MITM,
    .is_value_user       = BLE_GATTS_VLOC_STACK,
};

// UUID Base
static ble_uuid128_t ble_char_uuid_base[BLE_UUID_CHAR_MAX] = 
{
    CHAR1_UUID_BASE,
};

// set the UUID here.
static void uuid_init(void)
{
    ret_code_t    err_code;
    ble_uuid_t    adv_uuid;
    ble_uuid_t    service_uuid;
    ble_uuid_t    char_uuid;
    ble_uuid128_t adv_uuid_base = {ADV_UUID_BASE};
    ble_uuid128_t service_uuid_base = {SERVICE_UUID_BASE};

    uint8_t       test_data = 0x01;

    // advertise setting
    err_code = sd_ble_uuid_vs_add(&amp;amp;adv_uuid_base, &amp;amp;adv_uuid.type);
    APP_ERROR_CHECK(err_code);

    // service setting
    err_code = sd_ble_uuid_vs_add(&amp;amp;service_uuid_base, &amp;amp;service_uuid.type);
    APP_ERROR_CHECK(err_code);

    err_code = sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY, &amp;amp;service_uuid, &amp;amp;m_service_handle);
    APP_ERROR_CHECK(err_code);

    // characteristic setting
    err_code = sd_ble_uuid_vs_add(&amp;amp;ble_char_uuid_base[0], &amp;amp;char_uuid.type);
    APP_ERROR_CHECK(err_code);

    add_char_params.uuid_type = char_uuid.type;
    err_code = characteristic_add(m_service_handle, &amp;amp;add_char_params, &amp;amp;m_char_handles);
    APP_ERROR_CHECK(err_code);

    char_data_set(m_char_handles, 1, &amp;amp;test_data);

    return;
}

// characteristic data setting.
static void char_data_set(uint16_t handle, uint8_t len, uint8_t * value)
{
    ret_code_t        err_code;
    ble_gatts_value_t char_value;

    memset(&amp;amp;char_value, 0, sizeof(char_value));

    char_value.len     = len;
    char_value.offset  = 0;
    char_value.p_value = value;

    err_code = sd_ble_gatts_value_set(BLE_CONN_HANDLE_INVALID, handle, &amp;amp;char_value);
    APP_ERROR_CHECK(err_code);

    return;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Since the characteristic is set to read, it is assumed that a Read Request will be received from the connected BLE device (nRF Connect) and the data will be acquired.&lt;/p&gt;
&lt;p&gt;In this code, it is 1Byte, but when I set the data of about 8Byte and acquired it with a BLE device, it was the same value as the address 0x00000000 in the memory. Why is the data at address 0x00000000 sent?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to solve the problem that the characteristic value is not the set value.</title><link>https://devzone.nordicsemi.com/thread/353840?ContentTypeID=1</link><pubDate>Fri, 18 Feb 2022 12:41:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35fff13c-202b-42b9-b4f4-ab535a990d1f</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]&lt;p&gt;However, although no error now occurs, the characteristic value is no longer the set value.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know why this is happening. Do you have any advice?&lt;/p&gt;[/quote]
&lt;p&gt;What have you changed since it did work? What value do you write and what do you see? Could it be that other parts of your code sets another value, or that you do not set it at all? If you explain and show your code I can take a look and see if I spot any issues.&lt;/p&gt;
[quote user=""]Also, I am currently inquiring with this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid" rel="noopener noreferrer" target="_blank"&gt;ticket&lt;/a&gt;, but I am creating a process to switch the advertised UUID. Isn&amp;#39;t this advertisement UUID and service UUID need to be linked? I searched for such a process, but couldn&amp;#39;t find it.[/quote]
&lt;p&gt;If you advertise a service UUID, then that indicates that your device supports that service. There is however no direct link, so you can&amp;nbsp;technically advertise any UUID(s) regardless of what services the peripheral actually implements. For instance if you take a look at&amp;nbsp;examples\ble_peripheral\ble_app_hrs\main.c you can see some UUIDs that are part of the advertisement packet by looking at how&amp;nbsp;m_adv_uuids is declared. Implementation-vise this is completely independent of adding the services themselves.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>