How to check if Bluetooth is on or off using Symbian C++
The following Symbian C++ code snippet checks whether Bluetooth is available (on or off) by attempting to open a Bluetooth socket.
Article Metadata
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;
}


24 Sep
2009
Article shows a function to check out whether the Bluetooth of our device is on or off. Function returns true for on-bluetooth and false for off-Bluetooth. In Bluetooth application we have to first check that if Bluetooth of the device is on/off. Then we have to give another instruction. At that time this function is useful. Image which shows the use of this application is a good improvement.