I am using library react-native-ble-plx. If I know the real actual bluetooth mac address can I establish the connection? Since on scanning it's random address
I am using bleManager.connectToDevice by providing the bluetooth mac address which I get from phone settings. But it never connects and throws the error like Device was disconnected. I implemented a code to do the scanning and get the devices list along with the mac address but we know it's not a real mac address and if I try to connect using this mac address it works. But we know that's not the real address
The answer is no, it's not possible. At least if it's not bonded.
A BLE device typically has an "Identity Address" which is either a Public address or a Static Random address. I assume this is what you mean when you say "the real address". This can either be retrieved locally, e.g. if the device in question is an Android or iPhone you can see it in system settings under "about device" or similar. It will also be sent over the air to the other part as a step in the Bonding process of BLE. This is also the address used for Bluetooth Classic (if it's a Public Address).
If a BLE device in the peripheral role advertises and chooses to do so with a Random Resolvable address instead of its Identity Address, a BLE central that is not bonded with the peripheral will not be able to connect to this address since it cannot know that there is any relationship between the Random Resolvable address advertised and the Identity Address given by the host, when it looks for the device to connect to.
However, if the devices are already bonded, the central knows the IRK (Identity Resolving Key) belonging to the Identity Address, assuming it was exchanged during the bonding procedure earlier. If this is provided to the BLE controller's resolving list from the host, it will be able to deduce that a Random Resolvable address in fact corresponds to the given Identity Address and hence the connection will succeed.
My suggestion is to instead use some advertisement data that you can distinguish and perform a BLE scan in the central in order to find the device you want to connect to.