This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Understanding GATTC execute write flags parameter to sd_ble_gattc_write()

The ble_gattc_write_params_t structure passed to sd_ble_gattc_write() includes a flags parameter, described as GATTC execute write flags.The only values listed for this, other than 0, are BLE_GATT_EXEC_WRITE_FLAG_PREPARED_CANCEL and BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE. My question is when to use either of these two values. My assumption is only when using prepared writes, but I am confused by it's usage in in SDK examples such as BLE_UART. In the ble_nus_c.c it write the notification cccd using the following code:

    ble_gattc_write_params_t const write_params =
    {
        .write_op = BLE_GATT_OP_WRITE_REQ,
        .flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE,
        .handle   = cccd_handle,
        .offset   = 0,
        .len      = sizeof(buf),
        .p_value  = buf
    };

    return sd_ble_gattc_write(conn_handle, &write_params);

Here the BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE is used even though writing the CCCD is not part of a prepared write. Is the flag needed here and is so why?

Thanks,

Ben

Related