'How to obtain bluetooth port direction with pyserial?

I'm trying to connect to an RN42, module through python. When the RN42 pairs with W10 it creates two virtual COM ports(outgoing and incoming). I need to connect to the outgoing port.

I'm trying to do this automatically. I've tried:

import serial
import serial.tools.list_ports as port_lst

ports = list(port_lst.comports())
bluetooth_ports = []
for p in ports:
    if 'Bluetooth' in p.description:
        bluetooth_ports += [p.device]
bluetooth_com = serial.Serial(bluetooth_ports[0],115200)

I thought that the first port was usually the outgoing one, but I've paired the module to another computer, and this didn't apply (the second port was the outgoing one). Is there a way to find out the direction of the COM ports?

Thanks!!!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source