I am using rfcomm to connect to an Arduino nano (HC-06 bluetooth module) from my RPI 4B+. It works flawlessly and the two devices are able to communicate with no issues. I need to be able to connect several of these same bluetooth devices over bluetooth and communicate with them serially. Right now, I have to manually connect each device like this:
sudo rfcomm connect 0 98:D3:41:FD:6B:EB
Connected /dev/rfcomm0 to 98:D3:41:FD:6B:EB on channel 1
Press CTRL-C for hangup
And I can communicate perfectly with each device very easily using python:
import serial
s = serial.Serial("/dev/rfcomm0", 9600)
s.write(bytes("0",'utf-8'))
This works fine for one device, but I would like each device to connect automatically on startup without myself having to initialize anything. How can I use rfcomm to connect and communicate with multiple devices over serial? I simply want my rpi to pair with each device on startup and be ready for communication.