Problem arduino and bluetooth esp32

Job ID: 34787679

Budget: $10 – $30 USD

I have an ESP32 chip with the code attached.
The problem is that it works perfectly when pairing it the first time, but when I restart the chromecast v3 or it unpairs or it also happens that it unpairs the remote control from the chromecast having to factory reset it.