If you are using an Arduino board with HC-05 for AT commands over serial, you can follow the below flow :
- Setup HC-05
- Check for available nearby devices
- Check the response to check is the desired device is enlisted in the nearby devices
- If device is enlisted, use
AT+BIND=<Bluetooth address> to connect to the other device
- Check the response of the
AT+STATE? command until you receive “CONNECTED” (you can go for a while loop here)
- Once the connection is successfully established here, you can send a confirmation now as per your requirement.
The above scenario is applicable only when you are sure with the Bluetooth address of the device you want to connect to. If the scenario is something different, comment and let us know with the actual requirement.