|
Information
说明: |
建议参照本版块置顶帖内容输入必要信息 |
芯片型号: |
TLSR8258 |
SDK及版本: |
single connection 3.4.2.4 |
hi,
将8258作为slave(b85m_module) ,想通过event来获知各阶段状态,可是只有一个GAP event GAP_EVT_SMP_CONN_ENCRYPTION_DONE 在连接成功后出现,HCI event一个也没有。最麻烦的是在与master(手机) disconnect后没有任何event出现。
请问哪里有问题?
HCI 部分代码从 b85m_master_kma_dongle 中从拷贝而来:
Initial 部分:
blc_hci_registerControllerEventHandler(controller_event_callback); //controller hci event to host all processed in this func
//bluetooth event
blc_hci_setEventMask_cmd (HCI_EVT_MASK_DISCONNECTION_COMPLETE | HCI_EVT_MASK_ENCRYPTION_CHANGE);
//bluetooth low energy(LE) event
blc_hci_le_setEventMask_cmd( HCI_LE_EVT_MASK_CONNECTION_COMPLETE \
| HCI_LE_EVT_MASK_ADVERTISING_REPORT \
| HCI_LE_EVT_MASK_CONNECTION_UPDATE_COMPLETE \
| HCI_LE_EVT_MASK_PHY_UPDATE_COMPLETE \
| HCI_LE_EVT_MASK_CONNECTION_ESTABLISH ); //connection establish: telink private event
callback 部分:
int controller_event_callback (u32 h, u8 *p, int n)
{
(void)n;
static u32 event_cb_num;
event_cb_num++;
printf("controller_event_callback = %x\r\n", h);
if (h &HCI_FLAG_EVENT_BT_STD) //ble controller hci event
{
u8 evtCode = h & 0xff;
printf("hci evtCode = %02X\r\n", evtCode);
//------------ disconnect -------------------------------------
if(evtCode == HCI_EVT_DISCONNECTION_COMPLETE) //connection terminate
{
printf("HCI_EVT_DISCONNECTION_COMPLETE\r\n");
//blm_disconnect_event_handle(p);
}
#if (BLE_HOST_SMP_ENABLE)
else if(evtCode == HCI_EVT_ENCRYPTION_CHANGE)
{
printf("HCI_EVT_ENCRYPTION_CHANGE\r\n");
//event_enc_change_t *pe = (event_enc_change_t *)p;
//blm_smp_encChangeEvt(pe->status, pe->handle, pe->enc_enable);
}
else if(evtCode == HCI_EVT_ENCRYPTION_KEY_REFRESH)
{
printf("HCI_EVT_ENCRYPTION_KEY_REFRESH\r\n");
//event_enc_refresh_t *pe = (event_enc_refresh_t *)p;
//blm_smp_encChangeEvt(pe->status, pe->handle, 1);
}
#endif
else if(evtCode == HCI_EVT_LE_META)
{
u8 subEvt_code = p[0];
//------hci le event: le connection complete event---------------------------------
if (subEvt_code == HCI_SUB_EVT_LE_CONNECTION_COMPLETE) // connection complete
{
//after controller is set to initiating state by host (blc_ll_createConnection(...) )
//it will scan the specified device(adr_type & mac), when find this ADV packet, send a connection request packet to slave
//and enter to connection state, send connection complete event. but notice that connection complete not
//equals to connection establish. connection complete means that master controller set all the ble timing
//get ready, but has not received any slave packet, if slave rf lost the connection request packet, it will
//not send any packet to master controller
printf("HCI_SUB_EVT_LE_CONNECTION_COMPLETE\r\n");
//conn_timer = clock_time();
}
//------hci le event: le connection establish event---------------------------------
else if(subEvt_code == HCI_SUB_EVT_LE_CONNECTION_ESTABLISH) //connection establish(telink private event)
{
//notice that: this connection event is defined by telink, not a standard ble controller event
//after master controller send connection request packet to slave, when slave received this packet
//and enter to connection state, send a ack packet within 6 connection event, master will send
//connection establish event to host(HCI_SUB_EVT_LE_CONNECTION_ESTABLISH)
//blm_le_connection_establish_event_handle(p);
printf("HCI_SUB_EVT_LE_CONNECTION_ESTABLISH\r\n");
}
//--------hci le event: le ADV report event ----------------------------------------
else if (subEvt_code == HCI_SUB_EVT_LE_ADVERTISING_REPORT) // ADV packet
{
//after controller is set to scan state, it will report all the ADV packet it received by this event
//blm_le_adv_report_event_handle(p);
printf("HCI_SUB_EVT_LE_ADVERTISING_REPORT\r\n");
}
//------hci le event: le connection update complete event-------------------------------
else if (subEvt_code == HCI_SUB_EVT_LE_CONNECTION_UPDATE_COMPLETE) // connection update
{
//after master host send update conn param req cmd to controller( blm_ll_updateConnection(...) ),
//when update take effect, controller send update complete event to host
//blm_le_conn_update_event_proc(p);
printf("HCI_SUB_EVT_LE_CONNECTION_UPDATE_COMPLETE\r\n");
}
//------hci le event: le phy update complete event-------------------------------
else if (subEvt_code == HCI_SUB_EVT_LE_PHY_UPDATE_COMPLETE) // connection update
{
//2 situation can trigger this event:
// 1) master host trigger: by calling API blc_ll_setPhy(...)
// 2) peer slave device trigger: send "LL_PHY_REQ" on linklayer
//when update take effect, controller send update complete event to host
//blm_le_phy_update_complete_event_proc(p);
printf("HCI_SUB_EVT_LE_PHY_UPDATE_COMPLETE\r\n");
}
else {
printf("hci sub event = %d\r\n", subEvt_code);
}
}
}
return 0;
}
GAP mask 几乎全部打开:
blc_gap_registerHostEventHandler( app_host_event_callback );
blc_gap_setEventMask( GAP_EVT_MASK_SMP_PARING_BEAGIN | \
GAP_EVT_MASK_SMP_PARING_SUCCESS | \
GAP_EVT_MASK_SMP_PARING_FAIL | \
GAP_EVT_MASK_SMP_CONN_ENCRYPTION_DONE | \
GAP_EVT_MASK_SMP_TK_DISPLAY | \
GAP_EVT_MASK_SMP_TK_REQUEST_PASSKEY | \
GAP_EVT_MASK_SMP_TK_REQUEST_OOB | \
GAP_EVT_MASK_SMP_TK_NUMERIC_COMPARE | \
GAP_EVT_MASK_L2CAP_COC_CONNECT | \
GAP_EVT_MASK_L2CAP_COC_DISCONNECT | \
GAP_EVT_MASK_L2CAP_COC_RECONFIGURE | \
GAP_EVT_MASK_L2CAP_COC_RECV_DATA | \
GAP_EVT_MASK_L2CAP_COC_SEND_DATA_FINISH | \
GAP_EVT_MASK_L2CAP_COC_CREATE_CONNECT_FINISH);
|
|