//判断蓝牙是否打开的函数
TBool CMessageClient::GetBluetoothOn()
{
// 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, KBTLinkManager);
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;
}
TBool CMessageClient::GetBluetoothOn()
{
// 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, KBTLinkManager);
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;
}
//打开蓝牙的函数
void CMessageClient::ProcessBTPowerON()
{
TPckgBuf<TBool> pckg;
RNotifier iNotifier;
TPckgBuf<TBool> iNotifierResult;
TRequestStatus status;
User::LeaveIfError(iNotifier.Connect());
iNotifier.StartNotifierAndGetResponse(status,KPowerModeSettingNotifierUid,pckg,iNotifierResult);
User::WaitForRequest(status);
User::LeaveIfError(status.Int());
iNotifier.CancelNotifier(KPowerModeSettingNotifierUid);
iNotifier.Close();
User::LeaveIfError(iNotifierResult[0]);
}