×
Namespaces

Variants
Actions

How to check if Bluetooth is on or off using Symbian C++

From Nokia Developer Wiki
Jump to: navigation, search

The following Symbian C++ code snippet checks whether Bluetooth is available (on or off) by attempting to open a Bluetooth socket.

Article Metadata
Article
Created: neois (03 May 2007)
Last edited: hamishwillee (24 Jan 2012)
TBool GetBluetoothOn() // BTONOFF 
{
// Create and initialise an RHostResolver
RHostResolver hr;
TInt res = false;
TBool ret;
 
RSocketServ socketServer;
User::LeaveIfError(socketServer.Connect());
CleanupClosePushL(socketServer);
 
res = hr.Open(socketServer, KBTAddrFamily, BTLinkManager);
 
if (KErrNone != res) {
// if not success, this means bluetooth is not on
ret = EFalse;
}
 
else
{
ret = ETrue; // Bluetooth is already ON
hr.Close();
}
 
CleanupStack::PopAndDestroy(1);
 
return ret;
}
This page was last modified on 24 January 2012, at 07:03.
50 page views in the last 30 days.
×