<?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>BLE GATT characteristic variable length (Zephyr)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121111/ble-gatt-characteristic-variable-length-zephyr</link><description>I have a characteristic whose value is an array of char, which can from 1 to 20 bytes long. Using SDK17 I can set a vlen attribute and use the function update_characteristic() but I can&amp;#39;t see a way to do the same in NCS/Zephyr. 
 So, how can I change</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 02 May 2025 14:38:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121111/ble-gatt-characteristic-variable-length-zephyr" /><item><title>RE: BLE GATT characteristic variable length (Zephyr)</title><link>https://devzone.nordicsemi.com/thread/533771?ContentTypeID=1</link><pubDate>Fri, 02 May 2025 14:38:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e902ae7a-14d2-41ee-8c1b-ebde161555a2</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;That would explain why I couldn&amp;#39;t find anything! It works fine, thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE GATT characteristic variable length (Zephyr)</title><link>https://devzone.nordicsemi.com/thread/533766?ContentTypeID=1</link><pubDate>Fri, 02 May 2025 13:53:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ca3599ee-9b7a-4ac0-b696-3710bdee37b8</guid><dc:creator>Hung Bui</dc:creator><description>[quote user="Nick_RA"]and just return whatever I want to the central device whenever a connection is made[/quote]
&lt;p&gt;It&amp;#39;s actually true. You can take a look here at section 4 where I discussed a little bit about this approach in Zephyr and compare it to the old softdevice:&amp;nbsp;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/building-a-ble-application-on-ncs-comparing-and-contrasting-to-softdevice-based-ble-applications#mcetoc_1elnnim8t3"&gt;https://devzone.nordicsemi.com/guides/nrf-connect-sdk-guides/b/software/posts/building-a-ble-application-on-ncs-comparing-and-contrasting-to-softdevice-based-ble-applications#mcetoc_1elnnim8t3&lt;br /&gt;(&lt;/a&gt;The blog is a little bit old and may not have most up to date API, please follow the academy course)&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE GATT characteristic variable length (Zephyr)</title><link>https://devzone.nordicsemi.com/thread/533765?ContentTypeID=1</link><pubDate>Fri, 02 May 2025 13:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9613994d-6243-4691-bb74-4510cd3cc9a0</guid><dc:creator>Nick_RA</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I already have the callback:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static ssize_t char_foo_read(struct bt_conn *conn, const struct bt_gatt_attr *attr,void *buf, uint16_t len, uint16_t offset)
{
    const char *value = attr-&amp;gt;user_data;
    return bt_gatt_attr_read(conn, attr, buf, len, offset, value,len);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The intention here is to update the user_data before a connection is made. It&amp;#39;s part of a configuration set by the customer via a uart CLI.&lt;/p&gt;
&lt;p&gt;Or... are you saying I can ignore the actual characteristic data in the softdevice, and just return whatever I want to the central device whenever a connection is made? That doesn&amp;#39;t seem right to me.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE GATT characteristic variable length (Zephyr)</title><link>https://devzone.nordicsemi.com/thread/533756?ContentTypeID=1</link><pubDate>Fri, 02 May 2025 13:06:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:996205d9-cd69-46e6-8838-eb22bcf88adc</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Nick,&amp;nbsp;&lt;br /&gt;You will receive a call back when the client do a read.&amp;nbsp;&lt;br /&gt;I would suggest to take a look at our Academy course for BLE here:&amp;nbsp;&lt;a 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;/p&gt;
&lt;p&gt;At step 5 it discusses about implementing the callback.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>