Read-only archive of the All About Symbian forum (2001–2013) · About this archive

How can i get a list of BT devices?

2 replies · 1,839 views · Started 29 April 2005

Hi.
I'm trying to obtain a list of bluetooth devices.
I need to check it.

I know that in the following class: "CQBTUISelectDialog" there is an object
called "iFoundDevices" (which is an object of the following class:
"CBTDevice array"😉.

Do you know how can i use it (comparing the list and that stuff)?.

Thank you for your help.

Atreo.

This is the non-ui way of finding the list of bt devices in the range:


iSocketServ.Connect();
iSocketServ.FindProtocol(_L("BTLinkManager"😉,iProtocolInfo);
iHostResolver.Open(iSocketServ,iProtocolInfo.iAddrFamily,iProtocolInfo.iProtocol);

iSockAddr.SetIAC(KGIAC);
iSockAddr.SetAction(KHostResName|KHostResInquiry);

iHostResolver.GetByAddress(iSockAddr,iNameEntry,iStatus);
iState = ESearching;

while(User::WaitForRequest(iStatus),
(iStatus == KErrNone||iStatus==KRequestPending)){
/*add to list*/
aInquirySockAddrArray.Append(iNameEntry);
TBuf<50> aName;
TBuf<50> aServiceClass;
_LIT(KMsg1,"Name : %S"😉;
_LIT(KClass,"Service class : %d %d %d"😉;
aServiceClass.Format(KClass,iSockAddr.MajorClassOfDevice(),iSockAddr.MinorClassOfDevice(),iSockAddr.MajorServiceClass());
TNameRecord aRec = iNameEntry();
aName.Format(KMsg1,&aRec.iName);
iHostResolver.Next(iNameEntry,iStatus);
}

/*close the connections*/
iHostResolver.Close();
iSocketServ.Close();

/*
* now add the entries to the existing list
* check if entries are already present
* if present search for duplicate entries and
* update their status and just add new entries to the list
*/
if(iDevCount){
/*
* first check if the device exists in the list
* if it does then just update its status
*/

}
else if(aInquirySockAddrArray.Count()){
/*if device count is zero add the new entries to the list*/
// TBuf8<80> addr;
TNameEntry entry;
for(TInt i=0;i<aInquirySockAddrArray.Count();i++,iDevCount++){
/*add host name*/
iDeviceList.Append(aInquirySockAddrArray[i]().iName);
CEikonEnv::Static()->InfoWinL(iDeviceList[i],iDeviceList[i]);
/*add the bt addr*/
entry = aInquirySockAddrArray[i];
TInquirySockAddr &isa = TInquirySockAddr::Cast(aInquirySockAddrArray[i]().iAddr);
iDevBtAddrList.Append(isa.BTAddr());

/*have to fill in these two vars*/
//RArray<TInt> iDevBtCapsList;
//RArray<TInt> iDevBtServiceCapsList;
}
}
else {/*no devices found and no devices also in the list*/
}

return iDevCount;


Code is complete in terms of finding the list of devices,but it does not update
the currently user-maintained list as u can see from the comments.
Bye.
--eminemence.

hi eminemence
about your posted code, i am having difficulty in declaring some of the variables as i dont know some of the variable usage.

iState

ESearching

aInquirySockAddrArray

iDevCount

iDeviceList

iDevBtAddrList

can u help me in declaring these variables? and telling me the usage of it?