Do we have any example for implementing a characteristic with more than 20 bytes? Thanks.
Do we have any example for implementing a characteristic with more than 20 bytes? Thanks.
Example? Just set the length of the characteristic to what you want when you add it.
ble_gatts_attr_t.max_len
ble_gatts_attr_t.init_len
and note the defines
#define BLE_GATTS_FIX_ATTR_LEN_MAX (510) /**< Maximum length for fixed length Attribute Values. */
#define BLE_GATTS_VAR_ATTR_LEN_MAX (512) /**< Maximum length for variable length Attribute Values. */
I thought there is a limitation every packet is only 20 bytes and you need to write your own code to use offsets to let all 512 bytes be read.
The 20 byte limitation is for notifications and indications. Characteristics can be as long as the stack supports. If you're writing the peripheral side (which I assumed without asking, sorry if you're not), you have nothing to do, central implementations (eg iOS, android) do the necessary repeated reads to get the whole characteristic, if what they read is a full MTU, they just read the next bit until they get something less than a full MTU.
If you're writing the central side then yes you have to do the repeated reads. There's a message sequence chart for that but I don't think there's an example, I can't find one in which the gattc read function is called with anything other than 0 offset, because all the examples use services which have characteristics with fixed lengths shorter than MTU.
Is this peripheral or central code?
Thanks RK! I am writing a peripheral. You made my day :-)
I am testing the code right now. How do I define the attribute value to be fixed or variable? Thanks.