I’m unsure but this maybe (?) because once the link to you phone is switched off the Arduino code doesn’t look for a connection again ( I haven’t waded through the code) and so does nothing .
You need to write some very simple basic code to just connect to the phone and see how it operates and if this is the case .
It does look like this might be the case as code links up in setup - which of course only runs once , so if the link fails , it’s not re established .
I don’t know how to sort this in your code but others or google might help