I had this same problem. It is weird that db_pdu.len doesn't actually change when you assign it. What I did was store the real length in a different variable, then pass that actual number to ble_sendNotification(). This transmits the correct number of bytes. Haven't tried a read request of the characteristic though...
thanks odbol, I found a workaround for this as well...
Now I am having a similar problem, but on the write side. And I cannot find a workaround. The Hello example allows for 1 byte to be written to HANDLE_HELLO_SENSOR_CONFIGURATION. I modified it to allow for 10:
CHARACTERISTIC_UUID128_WRITABLE (0x002c, HANDLE_HELLO_SENSOR_CONFIGURATION, UUID_HELLO_CHARACTERISTIC_CONFIG,
LEGATTDB_CHAR_PROP_READ | LEGATTDB_CHAR_PROP_WRITE,
LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ, 10),
But in hello_sensor_write_handler() no matter what I send (even if I send 1 byte) I receive a length of 10. How can I find the true length of what was received? Could it be a problem with my configuration?
int hello_sensor_write_handler(LEGATTDB_ENTRY_HDR *p)
UINT16 handle = legattdb_getHandle(p);
int len = legattdb_getAttrValueLen(p);
UINT8 *attrPtr = legattdb_getAttrValue(p);
// do some noise
ble_trace2("hello_sensor_write_handler: handle %04x len %d\n", handle, len); // modified
Try to add LEGATTDB_PERM_VARIABLE_LENGTH bit to the characteristic definition. For example
LEGATTDB_PERM_READABLE | LEGATTDB_PERM_WRITE_CMD | LEGATTDB_PERM_WRITE_REQ
that did it. thank you!