How to connect to a particular Bluetooth address
Article Metadata
Overview
This code snippet shows how we can connect to a Bluetooth device over RFCOMM when we know the address. If we know the address and channel number of interested service then it can be connected directly. If we don't know the channel number then we need to find it as usual way and then we can connect.
TBTDevAddr devAddr(MAKE_TINT64(0x0019, 0x79fa2193));
// 001979fa2193 is target BT address divided into two parts
TBTSockAddr asocket;
asocket.SetBTAddr(devAddr);
asocket.SetPort(5);
//Assuming the expected service is advertised on channel 5
When Channel number is not known
TBTDevAddr devAddr(MAKE_TINT64(0x0019, 0x79fa2193));
iState = EGettingService;
iStatus = KRequestPending;
iServiceSearcher->FindServiceL(iStatus, devAddr);
SetActive();


(no comments yet)