I created a custom app to connect via bluetooth to my Raspberry Pi. All it does is it scans for bluetooth devices and connects to them through an RFCOMM socket.
As per this Android documentation I have the following code when creating the socket on my app, by using the well-known SPP UUID.
val uuid: UUID = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb")
device.createRfcommSocketToServiceRecord(uuid)
Everything works great!
The thing is, I would like it if only those using my app (i.e. those who have been authenticated by me) could connect to my Raspberry Pi.
Is it possible to set a custom UUID for the Raspberry's RFCOMM server?
EDIT:
I've made some progress by using this example code from the pybluez module. However, what happens now is that I can establish a connection by using two different UUIDs, the one I set on the python script and the default well-known SPP UUID.
How could I make it so that it works exclusively with the one I set?
I have once again answered my own question. I am glad it didn't take me too long this time.
I was running sdptool add SP
as part of my bluetooth setup process on my Raspberry Pi, I had seen that command as a recommendation on multiple different threads. It's interesting because the expected UUID does not get overriden, it just waits for either of them on the same RFCOMM channel.
Anyways, avoid using that command if you are trying to establish a bluetooth connection using your own UUID.