I have two Bluetooth devices and I’m trying to make two rfcomm connections, one connection per device.
I’m using bluez rfcomm socket
addr.rc_family = AF_BLUETOOTH;
addr.rc_channel = (uint8_t) 1;
str2ba( dest, &addr.rc_bdaddr );
// connect to server
s = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
// set disconnect timeout to 2sec
struct timeval tv;
tv.tv_sec = 2;
setsockopt(s, SOL_SOCKET, SO_RCVTIMEO,(struct timeval *)&tv,sizeof(struct timeval));
// make connection
status = connect(s, (struct sockaddr *)&addr, sizeof(addr));
How I select a device to make the connection?
you cannot do this, the bluez bluetooth stack will work on only one dongle i.e local bluetooth device at any time.
To be able to have a singe instance of the bluetooth stack control 2 bluetooth local dongles will be a big change to the bluez stack.