蓝牙问题

chen513562028 2010-10-21 04:22:50
哪位大牛能告诉我,如何在程序中启动手机蓝牙!不需要用户同意的!
我在其他论坛上有看到了,但是好像不行!请大牛详解!

在3rd里可以这样做:

CRepository* cr = CRepository::NewLC( KCRUidBluetoothPowerState );
TInt value;
cr->Get( KBTPowerState, value );
if(value==EBTPowerOn)
aPower=1;
CleanupStack::PopAndDestroy( cr );

注意:一定要在IDE中设置好3rd API的相关权限,否则会得到-46的错误代码,表示没有权限调用Get函数。

开启蓝牙

1. 弹出用户确认对话框的方式
头文件中:
RNotifier iNotifier;
TBTDeviceResponseParamsPckg iNotifierResult;
TPckgBuf<TBool> pckg;

CPP中:
User::LeaveIfError( iNotifier.Connect() );
iNotifier.StartNotifierAndGetResponse( iStatus,
KPowerModeSettingNotifierUid,
pckg,
iNotifierResult );
iState = EOpeningBT;
SetActive();

2.不经过用户确认,自动打开蓝牙

对SDK 1.2中的bteng.llib进行reverse engineering,然后使用其中的CBTMCMSettings类
// turn on Bluetooth in case it was off
CBTMCMSettings settings= CBTMCMSettings::NewL( (MBTMCMSettingsCB*)NULL );
settings->SetPowerStateL(ETrue,EFalse ); // on, off is (EFalse,EFalse)

在3rd中,还有一种办法,理论上也可以开启蓝牙,但由于权限不够,在真机上没有测试成功。

CRepository* cr = CRepository::NewLC( KCRUidBluetoothPowerState );
TInt err = cr->Set(KBTPowerState,EBTPowerOn);
此时在真机上err的值为-46表示没有权限。

其中那些常量代表什么意思!小弟不明白!
...全文
162 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,120

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧