BLE GATT characteristic variable length (Zephyr)

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't see a way to do the same in NCS/Zephyr.

So, how can I change the value *and length* of a characteristic?

These are all read-only, no notify, and created with the macros created using the macros BT_GATT_SERVICE_DEFINE BT_GATT_PRIMARY_SERVICE & BT_GATT_CHARACTERISTIC

Currently using NCS2.9.0 with a nRF52832DK

Parents Reply
  • Hi

    I already have the callback:

    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->user_data;
        return bt_gatt_attr_read(conn, attr, buf, len, offset, value,len);
    }

    The intention here is to update the user_data before a connection is made. It's part of a configuration set by the customer via a uart CLI.

    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't seem right to me.

Children
Related