How do you create a characteristic that can written to?

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

I've created a characteristic that has the "Write" checkbox checked under it's properties. However, using an app I downloaded to write to a characteristic, the value I want to change it to won't be written. Is there any C code that needs to be implemented?

0 Likes
1 Solution
Anonymous
Not applicable

IDK, I had those permissions before, but after looking at some sample code I ended up using these props/permissions:

LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_WRITE


LEGATTDB_PERM_VARIABLE_LENGTH | LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ | LEGATTDB_PERM_RELIABLE_WRITE


And it started writing correctly. I think I was missing the Variable Length permission and that was causing it not to work.

View solution in original post

0 Likes
4 Replies
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Refer to the document How to Write WICED Smart Applications

You'll find that in order to make make a writable characteristic you must use (for a 16 bit uuid):

CHARACTERISTIC_UUID16_WRITABLE (handle, handle_value, uuid, properties, permission, value_len)

This would be in place of a regular characteristic:
CHARACTERISTIC_UUID16 (handle, handle_value, uuid, properties, permission, value_len)

that you simply added writable permissions to
Jacob
0 Likes
Anonymous
Not applicable

I do have CHARACTERISTIC_UUID16_WRITABLE instead of CHARACTERISTIC_UUID16, and it still wont take the value...

0 Likes
Anonymous
Not applicable

I think you need to format your characteristic to look something like this:

CHARACTERISTIC_UUID128_WRITABLE (HDLC_FIRST_CUSTOM_SERVICE_CHAR1,                  HDLC_FIRST_CUSTOM_SERVICE_CHAR1_VALUE,   __UUID_FIRST_CUSTOM_SERVICE_CHAR1,                  LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_WRITE, LEGATTDB_PERM_READABLE |      LEGATTDB_PERM_WRITE_REQ,             1),             '0',

0 Likes
Anonymous
Not applicable

IDK, I had those permissions before, but after looking at some sample code I ended up using these props/permissions:

LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_WRITE


LEGATTDB_PERM_VARIABLE_LENGTH | LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ | LEGATTDB_PERM_RELIABLE_WRITE


And it started writing correctly. I think I was missing the Variable Length permission and that was causing it not to work.

0 Likes