The documentation simply says: 1 for variable length and 0 for fixed length.
What exactly does changing this do? Do I save space by setting it to fixed? Why does BDS set it to 1 by default.
The documentation simply says: 1 for variable length and 0 for fixed length.
What exactly does changing this do? Do I save space by setting it to fixed? Why does BDS set it to 1 by default.
Hi,
is_var_len indicates if the user characteristic descriptor has variable length or not. When you are setting up characteristics there is a vlen field can be set to mark a characteristic as variable length. A characteristic can either be of constant length (vlen = 0), or of variable length (vlen = 1).
E.g. for the UART characteristics, it makes sense to have vlen = 1, since you may want to transmit any size of data from e.g. 1 to 20 bytes. But, e.g. for the Temperature Type, which is a fixed length characteristic (it has 8 bits and every bit is fixed),vlen should be 0.
The information is part of the ble_add_char_params_t
strucutre, and is commonly used when setting up the Attribute Metadata structure (ble_gatts_attr_md_t attr_md
)(e.g. in the function called characteristic_add()
in ble_srv_common.c). This is a structure holding permissions and authorization levels required by characteristic value attributes. It also holds information on whether or not the characteristic value is of variable length and where in memory it is stored. So you basically tell the SoftDevice how the characteristic should be configured and handled. The central is informed about this when it performs a Service Discovery, and then knows how it should interact with the characteristic, and yes, it then knows exactly the right number of bytes to use when writing to the characteristic.
The information is part of the ble_add_char_params_t
strucutre, and is commonly used when setting up the Attribute Metadata structure (ble_gatts_attr_md_t attr_md
)(e.g. in the function called characteristic_add()
in ble_srv_common.c). This is a structure holding permissions and authorization levels required by characteristic value attributes. It also holds information on whether or not the characteristic value is of variable length and where in memory it is stored. So you basically tell the SoftDevice how the characteristic should be configured and handled. The central is informed about this when it performs a Service Discovery, and then knows how it should interact with the characteristic, and yes, it then knows exactly the right number of bytes to use when writing to the characteristic.