A former British soldier accused of passing secret information to Iran has told a court he is a “patriot” who is “against” the country.