Bluetooth and headset

Hello everyone, I want to ask a question. For example, if bluetooth is enabled and I connect the headset, the button should turn on, when the button is turned off, it should turn off, and when exiting the application, the headset should turn off, even if the application has tabs on how to release this, please help (that I found the extension

I need this type but these blocks are wrong help please

You should read the documentation on the website.