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

Max write length wiith sd_ble_gattc_write

I am using SDK nRF5_SDK_15.3.0_59ac345 with nrf32832. I want to write data from central to peripheral characteristics.  I wrote below code:

    ret_code_t       err_code;
    VERIFY_PARAM_NOT_NULL(p_ble_lbs_c);

    if (p_ble_lbs_c->conn_handle == BLE_CONN_HANDLE_INVALID)
    {
        return NRF_ERROR_INVALID_STATE;
    }

   ble_gattc_write_params_t const write_params =
    {
        .write_op = BLE_GATT_OP_WRITE_CMD,
        .flags    = BLE_GATT_EXEC_WRITE_FLAG_PREPARED_WRITE,
        .handle   = p_ble_lbs_c->peer_lbs_db.log_handle,
        .offset   = 0,
        .len      = length,
        .p_value  = data
    };

    err_code = sd_ble_gattc_write(p_ble_lbs_c->conn_handle, &write_params);
    APP_ERROR_CHECK(err_code);
    return err_code;

Everything worked fine when I am sending 250 bytes length but for 300 I am getting NRF_ERROR_DATA_SIZE. I set  NRF_SDH_BLE_GATT_MAX_MTU_SIZE as 512 and also set MTY  using the below code, but still the same issue. Any suggestions?

void client_int (void){
    ret_code_t       err_code;
    ble_lbs_c_init_t lbs_c_init_obj;

    lbs_c_init_obj.evt_handler   = lbs_c_evt_handler;

    db_discovery_init();

    err_code = ble_lbs_c_init(&m_ble_lbs_c, &lbs_c_init_obj);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_ble_gatt_att_mtu_central_set(&m_ble_lbs_c, NRF_SDH_BLE_GATT_MAX_MTU_SIZE);
    APP_ERROR_CHECK(err_code);
}

Parents Reply Children
No Data
Related