Bluetooth : Discovering the devices (Name and Addr)

Login to reply to this topic.
Tue, 2008-03-25 10:54
Joined: 2008-01-03
Forum posts: 18

Puzzled i need the name and address of every device discovered.
i am using RHostResolver to get the address of the devices
for the frist device the code goes like this

RSocketServ socketServ;
socketServ.Connect();
TProtocolDesc pInfo;
_LIT(KL2Cap, "BTLinkManager");
User::LeaveIfError(socketServ.FindProtocol(KL2Cap,pInfo));

RHostResolver hr;
User::LeaveIfError(hr.Open(socketServ,pInfo.iAddrFamily,pInfo.iProtocol));

TInquirySockAddr addr;
TNameEntry entry;
addr.SetIAC(KGIAC);
addr.SetAction(KHostResInquiry);
TRequestStatus status;
hr.GetByAddress(addr, entry, status);
User::WaitForRequest(status);

if(status == KErrNone)
{
addr.SetAction(KHostResName);
hr.GetByAddress(addr, entry, status);
User::WaitForRequest(status);
}
now if i want to get the next device i need to call
hr.Next(entry,status);
this entry will contain the name as the set action is still by name

so can i change the SetAction() to KHostResInquiry before the next() also or not ?

n i need to do this for every device
Is there a simpler way to get the addr and name of every device

please suggest

thanks in adavance


Fri, 2008-03-28 15:07
Joined: 2008-03-28
Forum posts: 2
Re: Bluetooth : Discovering the devices (Name and Addr)

Hi!

Changing addr.SetAction(KHostResInquiry); to addr.SetAction(KHostResName|KHostResInquiry);
will get you both name and adress at the same time.

Good luck!

/Björn

  • Login to reply to this topic.