You might have a shot at getting the charges dropped due to illegal search and seizure.
As far as I know, cops are allowed to pat down anyone they want to check for weapons. If they don't feel a weapon, they cannot search you. It would be hard for a cop to mistake a weed pipe for a weapon...