Hi, I am trying to use long characteristic (50byte) with variable length.
I can set value to the characteristic once, but it never change if I try to update to another value.
I defined below LEGATTDB_PERM_READABLE and LEGATTDB_PERM_VARIABLE_LENGTH set characteristic.
```
CHARACTERISTIC_UUID128 (
HANDLE_MY_CHARACTERISTIC,
HANDLE_MY_VALUE,
UUID_MY_CHARACTERISTIC,
LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY,
LEGATTDB_PERM_READABLE | LEGATTDB_PERM_AUTH_READABLE | LEGATTDB_PERM_VARIABLE_LENGTH,
50),
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
```
I set value as below.
```
BLEPROFILE_DB_PDU* my_characterestic = cfa_mm_Alloc(2 + data_len);
memcpy(my_characterestic->pdu, data, data_len);
my_characterestic->len = data_len;
bleprofile_WriteHandleData(HANDLE_MY_VALUE, my_characterestic, 2 + data_len);
cfa_mm_Free(my_characterestic);
```
reproducible procedure.
1. connect BCM20737S(peripheral) and iPhone(central)
2. set value with bleprofile_WriteHandleData.
data is {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} and data_len is 6.
3. read value from iPhone. {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} can be read correctly.
4. set another value like {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17} and data_len is 7.
5. read value from iPhone. {0x01, 0x02, 0x03, 0x04, 0x05, 0x06} remains even though another value has been set.
(if I set shorter byte array like {0x21,0x22,0x23,0x24,0x25} at step4, it can be set correctly..)
Can we use long characteristic with variable length?
Environment is as below.
```
Hardware : BCM20737S as BLE peripheral, and iPhone (iOS9.1) as BLE central
SDK : 2.2.0
```
Best Regards,
Solved! Go to Solution.
Thanks boont,
This issue has been solved with below modification (enable to write).
With our use case, this characteristic don't need to write, but without "writable", I cannot use variable length even though adding LEGATTDB_PERM_VARIABLE_LENGTH.
```
- CHARACTERISTIC_UUID128 (
+ CHARACTERISTIC_UUID128_WRITABLE (
HANDLE_MY_CHARACTERISTIC,
HANDLE_MY_VALUE,
UUID_MY_CHARACTERISTIC,
LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY,
- LEGATTDB_PERM_VARIABLE_LENGTH | LEGATTDB_PERM_READABLE | LEGATTDB_PERM_AUTH_READABLE,
+ LEGATTDB_PERM_VARIABLE_LENGTH | LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ | LEGATTDB_PERM_AUTH_READABLE,
50),
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
```
Anyway, thank you for your support!
Hi boont ,
Thank you for your reply, but your link is about length of long characteristic data. In your linked article, 79rpm use LEGATTDB_PERM_VARIABLE_LENGTH flag, but I cant know s/he can handle long characteristic as variable length data...
Thanks.
There is a description of a fix here. Let me know if it helps:
Thanks boont,
This issue has been solved with below modification (enable to write).
With our use case, this characteristic don't need to write, but without "writable", I cannot use variable length even though adding LEGATTDB_PERM_VARIABLE_LENGTH.
```
- CHARACTERISTIC_UUID128 (
+ CHARACTERISTIC_UUID128_WRITABLE (
HANDLE_MY_CHARACTERISTIC,
HANDLE_MY_VALUE,
UUID_MY_CHARACTERISTIC,
LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_NOTIFY,
- LEGATTDB_PERM_VARIABLE_LENGTH | LEGATTDB_PERM_READABLE | LEGATTDB_PERM_AUTH_READABLE,
+ LEGATTDB_PERM_VARIABLE_LENGTH | LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ | LEGATTDB_PERM_AUTH_READABLE,
50),
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
```
Anyway, thank you for your support!