Democrats don't support illegal immigration. They support law. They support following it. Trump doesn't really think we are under attack by them. He only thinks that Republicans are so stupid that they have already been groomed to react to certain dog whistles and free mongering. Thats why he refers to these poor people as invaders. They are 'coming to get you'. He sent more troops down to the border than people actually there. And most people don't realize that they can't be used to attack these poor people because of strict guidelines. They are just for show to create the illusion of a real threat.
Here is the reason why Trump has brought this subject up now. It really doesn't matter if he can do it or not, as you stated its a dog whistle.