I continued my research and found an answer that works for me. There is a DiscoverableTimeout on /etc/bluetooth/main.conf which is, by default, set to 300s.
I just add DiscoverableTimeout = 0 on this configuration files.
Unless you have fiddled with it, Bluetooth uses /dev/ttyAMA0 and the serial port /dev/ttyS0. These are different devices.
You should use /dev/serial0 for serial rather than the physical port.
See How do I make serial work on the Raspberry Pi3 , Pi3B+, PiZeroW
Simplest way to do this would be setting up a Bluetooth socket server in Python, adding a simple communication over it - then adding some security algorithm, such as basic password check or even data (or text, if you wish to make it command-oriented) encryption of traffic - Python is simple and quick way to perform these tasks with little to no difficulty. ...
I just tested it with a python script I wrote myself (not the one you used, but thread is thread I guess).
So I used python programname.py >> test.txt &
to fork the process of and send output to a textfile "test.txt" so it won't block our console (I'm assuming you are using the raspberry without a GUI, if not you can ignore the last command and ...
Taken from raspberryPi.org
To pair type pair xx:xx:xx:xx:xx:xx where xx:xx:xx:xx:xx:xx is your BD address of the
device you want to pair
Next type trust xx:xx:xx:xx:xx:xx
You should read the full thread from the link, this can help you.
Basicly the idea is to pair bluetooth device without user gui.
[The raspberry is much faster without a Desktop ...