/* Function to convert an nRF51 error code to a DFU Response Value. 
This function will convert a given nRF51 error code to a DFU Response Value. The result of this function depends on the current DFU procedure in progress, given as input in current_dfu_proc parameter. */
static ble_dfu_resp_val_t nrf_err_code_translate(uint32_t err_code, const ble_dfu_procedure_t current_dfu_proc)
/* Function to convert an nRF51 error code to a DFU Response Value. 
This function will convert a given nRF51 error code to a DFU Response Value. The result of this function depends on the current DFU procedure in progress, given as input in current_dfu_proc parameter. */
static ble_dfu_resp_val_t nrf_err_code_translate(uint32_t err_code, const ble_dfu_procedure_t current_dfu_proc)
{
    switch (err_code)
    {
        case NRF_SUCCESS:
            return BLE_DFU_RESP_VAL_SUCCESS;
        case NRF_ERROR_INVALID_STATE:
            return BLE_DFU_RESP_VAL_INVALID_STATE;
        case NRF_ERROR_NOT_SUPPORTED:
            return BLE_DFU_RESP_VAL_NOT_SUPPORTED;
        case NRF_ERROR_DATA_SIZE:
            return BLE_DFU_RESP_VAL_DATA_SIZE;
        case NRF_ERROR_INVALID_DATA:
            if (current_dfu_proc == BLE_DFU_VALIDATE_PROCEDURE)
            {
                return BLE_DFU_RESP_VAL_CRC_ERROR;
            }
            return BLE_DFU_RESP_VAL_OPER_FAILED;
        default:
            return BLE_DFU_RESP_VAL_OPER_FAILED;
    }
}