I don't disagree that sometimes provocation is necessary to keep our credibility with hostile nations. Unfortunately, this will naturally escalate hostilities with Iran, a nuclear power. Hopefully, officials will be able to sooth over the situation without further damage. I think the warning was the right thing to do at the time.
Iran is constantly testing the resolve of the US Navy. That will probably only increase in the next week or so while Obama is still in office and Trump is getting ready to become President. Iran is likely to test the resolve of the new Commander in Chief and it is likely that Mr. Trump may take the opportunity to flex his muscle.
The US experiences a strained relationship with Iran due to its dictatorial politics and its threats of building up its nuclear artillery. More recently, the Iran Deal, put in place by President Obama's administration, loosen's US sanctions on Iran but tightens security over their nuclear acquisitions. Now that Iran's ships received warning signals from the US navy, it is likely that the Middle Eastern nation will resist cooperating with US demands and suggestions at best.
I don't think the Iranians are that surprised that a US destroyer fired a warning at one of their vessels, as this happens all the time. Both sides in these types of situations want to show their strength, and it was either going to be them firing a warning at the US or the US firing first.