Learn to be calm in your relations with others, never text, write or say anything vulgar or threatening, and do not deal with liar and losers, If the police contact you say nothing and retain an attorney.
Time to change your accounts so that this person can no longer locate you. Retain an attorney and get a restraining order. Document everything. Make forensic copies of your phone and computer(s) to protect yourself before law enforcement takes them from you.
The response above is not intended as legal advice since it’s impracticable to provide thorough, accurate advice based upon the query without additional details. It is highly recommended that one should seek advice from a criminal defense attorney licensed in your jurisdiction by setting up a confidential meeting. Moreover, this response does not constitute the creation of an attorney-client relationship since this message is not a confidential communication because it was posted on a public website, thereby publicly disclosing the information, which is another reason to setup a confidential meeting with an attorney.
I suggest that you obtain a protective order, temporary restraining order that prohibits him from calling, communicating and coming within 100 feet of you. Change all passwords, locks and install security camera at your home. The habits of yours that he is familiar with, alter them. Contact a supervisor officer and advise him that a person contacted you impersonating an officer and request a status of your charge. Hire an attorney to obtain the protective order.