?? hci.c
字號:
***********************************************************************************************************
*/
int hci_reject_conn_req(struct hci_dev *hdev,UINT8 reason)
{
reject_conn_cp rc;
hdev->req_status = HCI_REQ_PEND;
__bt_mem_cpy((void*)(rc.bdaddr),(void*)(hdev->hci_connection.hci_c_info.dst),6);//?to be corrected
rc.reason = reason;
hci_send_cmd(hdev,OGF_LINK_CTL,OCF_REJECT_CONN_REQ,REJECT_CONN_REQ_CP_SIZE,(void*)&rc);
return 0;
}
/*
***********************************************************************************************************
* 請求遠方設備的friendly name
* 功 能:發送請求遠方設備的friendly name命令
***********************************************************************************************************
*/
int hci_remote_name_req(struct hci_dev *hdev)
{
remote_name_req_cp rnr;
hdev->req_status = HCI_REQ_PEND;
__bt_mem_cpy((void*)(rnr.bdaddr),(void*)(hdev->hci_connection.hci_c_info.dst),6);
rnr.pscan_rep_mode = hdev->hci_inquiry_info.pscan_rep_mode;
rnr.pscan_mode = hdev->hci_inquiry_info.pscan_mode;
rnr.clock_offset = (hdev->hci_inquiry_info.clock_offset) & 0x8000;
hci_send_cmd(hdev,OGF_LINK_CTL,OCF_REMOTE_NAME_REQ,REMOTE_NAME_REQ_CP_SIZE,(void*)&rnr);
return 0;
}
/*
***********************************************************************************************************
* hci scan request
* 功 能:發送scan命令
***********************************************************************************************************
*/
void hci_scan_req(struct hci_dev *hdev)
{
UINT8 scan = hdev->scan_enable;
hdev->req_status = HCI_REQ_PEND;
//Inquiry and Page scans
hci_send_cmd(hdev,OGF_HOST_CTL,OCF_WRITE_SCAN_ENABLE,1,&scan);
}
/*
***********************************************************************************************************
* hci authentication request
* 功 能:發送authentication命令
***********************************************************************************************************
*/
void hci_auth_req(struct hci_dev *hdev)
{
UINT8 auth = hdev->authen_enable;
hdev->req_status = HCI_REQ_PEND;
/* Authentication */
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE, 1, &auth);
}
/*
*************************************************************************
HOST CONTROL
*************************************************************************
*/
/*
***********************************************************************************************************
* hci reset request
* 功 能:發送reset命令
***********************************************************************************************************
*/
void hci_reset_req(struct hci_dev *hdev)
{
hdev->req_status = HCI_REQ_PEND;
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_RESET, 0, NULL);
}
/*
*************************************************************************
PKT ANALYZE FUNCTION
*************************************************************************
*/
__inline void hci_req_complete(struct hci_dev *hdev, int result)
{
if (hdev->req_status == HCI_REQ_PEND) {
hdev->req_result = result;
hdev->req_status = HCI_REQ_DONE;
}
}
__inline void hci_cmd_complete(struct hci_dev *hdev, int result)
{
if (hdev->req_status == HCI_REQ_PEND) {
hdev->cmd_complete_flags= result;
hdev->req_status = HCI_REQ_DONE;
}
}
/*
***********************************************************************************************************
* Command Complete OGF LINK_CTL
* 功 能:
***********************************************************************************************************
*/
/* Command Complete OGF LINK_POLICY */
void hci_cc_link_policy(struct hci_dev *hdev, UINT16 ocf)
{
#ifdef DEBUG
printf("%s ocf 0x%x", hdev->hci_device_info.name, ocf);
#endif
switch (ocf) {
default:
{
//UINT8 status;
//status=SDC_Get_Char(hdev->port);
//if(!status)
//{
// hdev->cmd_complete_flags = 1;
#ifdef DEBUG
printf("%s Command complete: ogf LINK_CTL ocf %x", hdev->name, ocf);
#endif
//}
break;
}
}
}
//In this function the main handling is to be filled
void hci_cc_link_ctl(struct hci_dev *hdev, UINT16 ocf)
{
switch (ocf) {
default:
{
UINT8 status;
status=SDC_Get_Char(hdev->port);
if(!status)
{
hdev->cmd_complete_flags = 0;
#ifdef DEBUG
printf("%s Command complete: ogf LINK_CTL ocf %x", hdev->hci_device_info.name, ocf);
#endif
}
}
break;
}
}
/* Command Complete OGF HOST_CTL */
void hci_cc_host_ctl(struct hci_dev *hdev,UINT16 ocf)
{
UINT8 status,param;
//void *send;
//printf("%s ocf 0x%x",hdev->name,ocf);
switch(ocf){
case OCF_EVT_MSK:
break;
case OCF_RESET:
status =(UINT8)(SDC_Get_Char(hdev->port));//replaced form line1359
hci_cmd_complete(hdev,status);
break;
case OCF_SET_EVENT_FLT:
status = (UINT8)(SDC_Get_Char(hdev->port));//replaced form line
hci_cmd_complete(hdev,status);
#ifdef DEBUG
if(status)
printf("%s SET_EVENT_FLT failed %d", hdev->name, status);
else
printf("%s SET_EVENT_FLT successful", hdev->name);
#endif
break;
case OCF_WRITE_AUTH_ENABLE:
//if (!(send = hci_send_cmd_data(hdev, OGF_HOST_CTL, OCF_WRITE_AUTH_ENABLE)))
//break;
status =(UINT8)(SDC_Get_Char(hdev->port)); //????????????????????????????????????????????????
param = hdev->authen_enable;
if(!status){
if(param == AUTH_ENABLED)
hdev->auth_flags |= HCI_AUTH;
else
hdev->auth_flags &= ~HCI_AUTH;
}
hci_cmd_complete(hdev,status);
break;
case OCF_WRITE_CA_TIMEOUT:
status = (UINT8)(SDC_Get_Char(hdev->port)); //????????????????????????????????????????????????
hci_cmd_complete(hdev,status);
#ifdef DEBUG
if(status){
printf("%s OCF_WRITE_CA_TIMEOUT failed %d", hdev->name, status);
}else{
printf("%s OCF_WRITE_CA_TIMEOUT succeseful", hdev->name);
}
#endif
break;
case OCF_WRITE_PG_TIMEOUT:
status =(UINT8)(SDC_Get_Char(hdev->port));
#ifdef DEBUG
if(status){
printf("%s OCF_WRITE_PG_TIMEOUT failed %d", hdev->name, status);
}else{
printf("%s OCF_WRITE_PG_TIMEOUT succeseful", hdev->name);
}
#endif
break;
case OCF_WRITE_SCAN_ENABLE:
status = (UINT8)(SDC_Get_Char(hdev->port)); //????????????????????????????????????????????????
param = hdev->scan_enable;
if(!status){
switch(param){
case IS_ENA_PS_ENA:
hdev->scan_flags |= HCI_PSCAN | HCI_ISCAN;
break;
case IS_ENA_PS_DIS:
hdev->scan_flags &= ~HCI_PSCAN;
hdev->scan_flags |= HCI_ISCAN;
break;
case IS_DIS_PS_ENA:
hdev->scan_flags &= ~HCI_ISCAN;
hdev->scan_flags |= HCI_PSCAN;
break;
default:
hdev->scan_flags &= ~(HCI_ISCAN | HCI_PSCAN);
break;
};
}
hci_cmd_complete(hdev, status);
break;
default:
#ifdef DEBUG
printf("%s Command complete: ogf HOST_CTL ocf %x", hdev->hci_device_info.name, ocf);
#endif
break;
};
}
/* Command Complete OGF INFO_PARAM */
void hci_cc_info_param(struct hci_dev *hdev,UINT16 ocf)
{
//READ_BUFFER_SIZE_RP_SIZE READ_BD_ADDR_RP_SIZE
read_local_features_rp lf;
read_buffer_size_rp bs;
read_bd_addr_rp ba;
read_local_version_rp lv;
int i;
switch(ocf){
case OCF_READ_LOCAL_VERSION:
for(i=0;i<OCF_READ_LOCAL_VER_RP_SIZE;i++)
{
if((hdev->port->rx_buffer_status==SDC_BUFFER_DATA)||(hdev->port->rx_buffer_status==SDC_BUFFER_FULL))
{
*((UINT8*)(&lv)+i) = (UINT8)(SDC_Get_Char(hdev->port));
}
}
if(lv.status)
{
hci_cmd_complete(hdev, lv.status);
#ifdef DEBUG
printf("%s READ_LOCAL_VERSION failed %d", hdev->hci_device_info.name, lv.status);
#endif
break;
}
__bt_mem_cpy((void *)(&( hdev->hci_device_info.ver)), (void *)((char*)(&lv)+1), OCF_READ_LOCAL_VER_RP_SIZE-1);
break;
case OCF_READ_LOCAL_FEATURES:
for(i=0;i<READ_LOCAL_FEATURES_RP_SIZE;i++)
{
if((hdev->port->rx_buffer_status==SDC_BUFFER_DATA)||(hdev->port->rx_buffer_status==SDC_BUFFER_FULL))
{
*((UINT8*)(&lf)+i) = (UINT8)(SDC_Get_Char(hdev->port));
}
}
if(lf.status){
hci_cmd_complete(hdev, lf.status);
#ifdef DEBUG
printf("%s READ_LOCAL_FEATURES failed %d", hdev->name, lf.status);
#endif
break;
}
__bt_mem_cpy((void*)(hdev->hci_device_info.features), (void*)lf.features, 8);
/* Adjust default settings according to features supported by device. */
if(hdev->hci_device_info.features[0] &LMP_3SLOT)
hdev->hci_device_info.pkt_type |= (HCI_DM3 | HCI_DH3);
if (hdev->hci_device_info.features[0] & LMP_5SLOT)
hdev->hci_device_info.pkt_type |= (HCI_DM5 | HCI_DH5);
#ifdef DEBUG
printf("%s: features 0x%x 0x%x 0x%x", hdev->hci_device_info.name, lf.features[0], lf.features[1], lf.features[2]);
#endif
break;
case OCF_READ_BUFFER_SIZE:
for(i=0;i<READ_BUFFER_SIZE_RP_SIZE;i++)
{
if((hdev->port->rx_buffer_status==SDC_BUFFER_DATA)||(hdev->port->rx_buffer_status==SDC_BUFFER_FULL))
{
*((UINT8*)(&bs)+i) = (UINT8)(SDC_Get_Char(hdev->port));
}
}
if (bs.status) {
hci_cmd_complete(hdev, bs.status);
#ifdef DEBUG
printf("%s READ_BUFFER_SIZE failed %d", hdev->hci_device_info.name, bs.status);
#endif
break;
}
hdev->hci_device_info.acl_mtu = (UINT16)(bs.acl_mtu);
hdev->hci_device_info.sco_mtu = (UINT8 )(bs.sco_mtu);
hdev->hci_device_info.acl_max = hdev->acl_cnt = (UINT16)(bs.acl_max_pkt);
hdev->hci_device_info.sco_max = hdev->sco_cnt = (UINT16)(bs.sco_max_pkt);
#ifdef DEBUG
printf("%s mtu: acl %d, sco %d max_pkt: acl %d, sco %d", hdev->hci_device_info.name,hdev->hci_device_info.acl_mtu, hdev->hci_device_info.sco_mtu, hdev->hci_device_info.acl_max, hdev->hci_device_info.sco_max);
#endif
break;
case OCF_READ_BD_ADDR:
for(i=0;i<READ_BD_ADDR_RP_SIZE;i++)
{
if((hdev->port->rx_buffer_status==SDC_BUFFER_DATA)||(hdev->port->rx_buffer_status==SDC_BUFFER_FULL))
{
*((UINT8*)(&ba)+i) = (UINT8)(SDC_Get_Char(hdev->port));
}
}
if(!ba.status){
__bt_mem_cpy((void*)(hdev->hci_device_info.bdaddr),(void*)(ba.bdaddr),6);
}else{
#ifdef DEBUG
printf("%s: READ_BD_ADDR failed %d", hdev->hci_device_info.name, ba.status);
#endif
}
hci_cmd_complete(hdev,ba.status);
break;
default:
#ifdef DEBUG
printf("%s Command complete: ogf INFO_PARAM ocf %x", hdev->hci_device_info.name, ocf);
#endif
break;
}
}
/* Command Status OGF LINK_CTL */
void hci_cs_link_ctl(struct hci_dev *hdev,UINT16 ocf,UINT8 status)
{
switch(ocf){
case OCF_CREATE_CONN:
hci_req_complete(hdev,status); //future
if(status){
//create_conn_cp *cc = hci_send_cmd_data(hdev,OGF_LINK_CTL,OCF_CREATE_CONN);
//if(!cc)
// break;
//printf("%s Create connection error: status 0x%x %s", hdev->name,status,&cc.bdaddr);
}
break;
case OCF_INQUIRY:
hci_req_complete(hdev,status);//future
if(status){
#ifdef DEBUG
printf("%s Inquiry error: status 0x%x", hdev->hci_device_info.name, status);
#endif
}
break;
default:
#ifdef DEBUG
printf("%s Command status: ogf LINK_CTL ocf %x", hdev->hci_device_info.name, ocf);
#endif
break;
}
}
/* Command Status OGF LINK_POLICY */
void hci_cs_link_policy(struct hci_dev *hdev,UINT16 ocf,UINT8 status)
{
switch(ocf){
default:
hci_req_complete(hdev,status);
#ifdef DEBUG
printf("%s Command status: ogf HOST_POLICY ocf %x", hdev->hci_device_info.name, ocf);
#endif
}
}
/* Command Status OGF HOST_CTL */
void hci_cs_host_ctl(struct hci_dev *hdev,UINT16 ocf,UINT8 status)
{
switch(ocf){
default:
hci_req_complete(hdev, status);
#ifdef DEBUG
printf("%s Command status: ogf HOST_CTL ocf %x", hdev->hci_device_info.name, ocf);
#endif
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -