电子产品世界 » 论坛首页 » 综合技术 » 通讯及无线技术 » 如何在工模下面读取蓝牙本机地址


共1条 1/1 1 跳转至

如何在工模下面读取蓝牙本机地址

菜鸟
2017-09-14 17:59:37    评分

可以参考:alps/mediatek/factory/src/util/ftm_bt_op.c

在 ftm_bt_op.c文件中添加如下函数:

static BOOL BT_Read_LocalAddr(void)

{

DBG("BT_Read_LocalAddr\n");

UCHAR HCI_READ_LOCAL_ADDR[] = {0x01, 0x09, 0x10, 0x00};

UCHAR pAckEvent[13];

UCHAR ucEvent[] = {0x04, 0x0E, 0x0a, 0x01, 0x09, 0x10};

if (!glib_handle){

ERR("mtk bt library is unloaded!\n");

return FALSE;

}

if (bt_fd < 0){

ERR("bt driver fd is invalid!\n");

return FALSE;

}

if(bt_send_data(bt_fd, HCI_READ_LOCAL_ADDR, sizeof(HCI_READ_LOCAL_ADDR)) < 0){

ERR("Send read BD_ADDR command fails errno %d\n", errno);

return FALSE;

}

if(bt_receive_data(bt_fd, pAckEvent, sizeof(pAckEvent)) < 0){

ERR("Receive event fails errno %d\n", errno);

return FALSE;

}

if(memcmp(pAckEvent, ucEvent, sizeof(ucEvent))){

ERR("Receive unexpected event\n");

return FALSE;

}else{

DBG("Read LOCAL BD_ADDR: lup:0x%x-0x%x-0x%x,uap:0x%x,nap:0x%x-0x%x\n",

pAckEvent[7],pAckEvent[8],pAckEvent[9],pAckEvent[10],pAckEvent[11],pAckEvent[12]);

}

return TRUE;

}

然后在:FM_BT_init()函数中

BG("BT is enabled success\n");

这句下面调用此函数

BT_Read_LocalAddr();

然后有下列方法编译及测试

1. ./mk mediatek/factory

2. ./mk snod

3. enter factory mode:Press volume down and Power Key.

4. adb shell logcat

5. enter bluetooth test item.

6. you will see the BD_ADDR read Log .

Thanks





关键词: mtk    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]