def set_calibration_mode()

in webserver_pkg/webserver_pkg/calibration.py [0:0]


def set_calibration_mode():
    """API to call the service to activate calibration mode.

    Returns:
        dict: Execution status if the API call was successful.
    """
    webserver_node = webserver_publisher_node.get_webserver_node()
    try:
        vehicle_state_req = ActiveStateSrv.Request()
        vehicle_state_req.state = CALIBRATION_MODE
        vehicle_state_res = call_service_sync(webserver_node.vehicle_state_cli,
                                              vehicle_state_req)

        enable_state_req = EnableStateSrv.Request()
        enable_state_req.is_active = True
        enable_state_res = call_service_sync(webserver_node.enable_state_cli,
                                             enable_state_req)

        success = (vehicle_state_res and
                   vehicle_state_res.error == 0 and
                   enable_state_res and
                   enable_state_res.error == 0)
        if not success:
            webserver_node.get_logger().error("Vehicle state service call failed")
            return jsonify(success=False, reason="Error")
        return jsonify(success=True)
    except Exception as ex:
        webserver_node.get_logger().error(f"Unable to reach vehicle state server: {ex}")
        return jsonify(success=False, reason="Error")