This page was last modified 08:16, 25 September 2007.
Get List of Active Bluetooth Connections
From Forum Nokia Wiki
Symbian OS v7.0 have limited support for getting the connection information. There is a socket IOCTL command to get all the device addresses for connected ACL links (see KLMGetACLLinkArray in the Symbian Developer Library). Note that you can get the count of links first using KLMGetACLLinkCount. There is no way to get a notification when the set of links change.
The example code below shows how you can query for the list of addresses:
//Define buffer for the number of connected devices TPckgBuf<TInt> theDevNo; // Get the number of ACL links TInt err = iSocket.GetOpt(KLMGetACLLinkCount, KSolBtLM, theDevNo); User::LeaveIfError(err); // Number of ACL connections TInt& noLinks = theDevNo(); if(noLinks == 0) { return KErrNone; // If no links, no problem } // Allocate memory for the response of TBTDevAddr array TBTDevAddr* tmpAddrArray = new(ELeave) TBTDevAddr[noLinks]; CleanupArrayDeletePushL(tmpAddrArray); TInt theArraySize = noLinks*sizeof(TBTDevAddr); TPtr8 ptr((TUint8*)tmpAddrArray, theArraySize, theArraySize); // Get an array of device addresses for the ACL links, into a Link Array err = iSocket.GetOpt(KLMGetACLLinkArray, KSolBtLM, ptr); User::LeaveIfError(err); // Make sure we iterate through the addresses that we did get back as // opposed to the maximum which we could noLinks = ptr.Length()/sizeof(TBTDevAddr); CleanupStack::PopAndDestroy(); //tmpAddrArray
Symbian OS v8 provides improved support for this functionality.
The "publish & subscribe" (P&S) mechanism can be used to register for notification when the number of physical links changes.
The relevent P&S key is KPropertyKeyBluetoothLocalDeviceAddress, which is described in the API reference documentation as
"The key to observe the the number of Bluetooth physical links attached to the
local device".
Information on the Publish & Subscribe framework is available in the Symbian OS v8 SDKs on Symbian DevNet - see "Series 60 2nd Edition with Feature Pack 2 (Symbian OS v8.0)" » Developer Library » Symbian OS Guide » C++ API guide » Base » Publish & Subscribe » Publish and Subscribe Overview
Code can then use the
CBluetoothPhysicalLinks::Enumerate()
method to get the addresses of the connected devices.
API reference for the method is:
//Enumerate members of the piconet EXPORT_C TInt CBluetoothPhysicalLinks::Enumerate(RBTDevAddrArray& aBTDevAddrArray, TUint aMaxNumber) //aBTDevAddrArray - Bluetooth device address array to be filled with bluetooth addresses of members of the piconet. //aMaxNumber - Upper limit on number of members to be returned. //Returns - Error code
| Related Discussions | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| TCP Services via LAN over Bluetooth | paperjet | Bluetooth Technology | 0 | 2002-09-27 11:45 |
| MessageConnection.receive() | qwerty_wwd | Mobile Java Networking & Messaging & Security | 5 | 2006-03-07 07:52 |
| SCO connections on 7650 | dharker | Bluetooth Technology | 3 | 2004-07-06 05:40 |
| Problems with a signed application | Alfury | Mobile Java Networking & Messaging & Security | 7 | 2008-03-27 05:15 |
| Detecting the nearest Bluetooth | JereKuusela | Python | 2 | 2008-06-03 06:13 |
