Hi James, On Sat, May 28, 2016 at 12:53:14PM -0700, James Howarth wrote: > Hi, > > Looking at the peripheral callback gatt_svr_chr_access_gatt, is there a way > to determine the length of data received? > > Here's the whole function definition. > > static int > gatt_svr_chr_access_gatt(uint16_t conn_handle, uint16_t attr_handle, > uint8_t op, > union ble_gatt_access_ctxt *ctxt, void *arg)
The length of the received data is contained in the ctxt->chr_access.len field. For example, bleprph handles an incoming write of the gap-reconnect-address characteristic as follows: case BLE_GAP_CHR_UUID16_RECONNECT_ADDR: assert(op == BLE_GATT_ACCESS_OP_WRITE_CHR); if (ctxt->chr_access.len != sizeof bleprph_reconnect_addr) { return BLE_ATT_ERR_INVALID_ATTR_VALUE_LEN; } memcpy(bleprph_reconnect_addr, ctxt->chr_access.data, sizeof bleprph_reconnect_addr); break; The code validates the length of the incoming data immediately after the assert() invocation. Chris