📄 mfw_bta.c
字号:
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
help_id->next->next = NULL;/* finish chain */
#ifdef _SIMULATION_
TRACE_EVENT_P1("fax found ind = %s", help_id->next->bd_name);
#endif
}
}
else if(service_indication->service EQ MFW_BT_OPP)
{
MALLOC(service_id, sizeof(T_MFW_BT_SERVICE_ID));/* allocate memory for new device id */
if(!service_id)
return FALSE;
memset(service_id, 0, sizeof(T_MFW_BT_SERVICE_ID));
len = sizeof(service_indication->service_name);
id_ptr = &found_opp; /* pointer to list of detected opp services */
if(!id_ptr->device_id) /* test if does any device id exist */
{
id_ptr->device_id = service_id; /* append new device_id */
memcpy(id_ptr->device_id->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
id_ptr->device_id->next = NULL; /* finish chain */
#ifdef _SIMULATION_
TRACE_EVENT_P1("opp found ind = %s", found_opp.device_id->bd_name);
#endif
}
else
{
help_id = id_ptr->device_id;/* first element */
while(help_id->next) /* look for next device_id */
{
help_id = help_id->next;
}
help_id->next = service_id;/* append new device_id */
memcpy(help_id->next->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
help_id->next->next = NULL;/* finish chain */
#ifdef _SIMULATION_
TRACE_EVENT_P1("opp found ind = %s", help_id->next->bd_name);
#endif
}
}
else if(service_indication->service EQ MFW_BT_SYNC)
{
MALLOC(service_id, sizeof(T_MFW_BT_SERVICE_ID));/* allocate memory for new device id */
if(!service_id)
return FALSE;
memset(service_id, 0, sizeof(T_MFW_BT_SERVICE_ID));
len = sizeof(service_indication->service_name);
id_ptr = &found_sync; /* pointer to list of detected SYNC services */
if(!id_ptr->device_id) /* test if does any device id exist */
{
id_ptr->device_id = service_id; /* append new device_id */
memcpy(id_ptr->device_id->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
id_ptr->device_id->next = NULL; /* finish chain */
}
else
{
help_id = id_ptr->device_id;/* first element */
while(help_id->next) /* look for next device_id */
{
help_id = help_id->next;
}
help_id->next = service_id;/* append new device_id */
memcpy(help_id->next->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
help_id->next->next = NULL;/* finish chain */
}
}
else if(service_indication->service EQ MFW_BT_SYNC_CMD)
{
MALLOC(service_id, sizeof(T_MFW_BT_SERVICE_ID));/* allocate memory for new device id */
if(!service_id)
return FALSE;
memset(service_id, 0, sizeof(T_MFW_BT_SERVICE_ID));
len = sizeof(service_indication->service_name);
id_ptr = &found_sync_cmd; /* pointer to list of detected SYNC services with SYN commands support */
if(!id_ptr->device_id) /* test if does any device id exist */
{
id_ptr->device_id = service_id; /* append new device_id */
memcpy(id_ptr->device_id->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
id_ptr->device_id->next = NULL; /* finish chain */
#ifdef _SIMULATION_
TRACE_EVENT_P1("sync found ind = %s", found_sync_cmd.device_id->bd_name);
#endif
}
else
{
help_id = id_ptr->device_id;/* first element */
while(help_id->next) /* look for next device_id */
{
help_id = help_id->next;
}
help_id->next = service_id;/* append new device_id */
memcpy(help_id->next->bd_addr, service_indication->bd_addr, MFW_BT_ADDR_MAX_LEN);/* new address */
memcpy(id_ptr->device_id->bd_name, service_indication->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(id_ptr->device_id->cod, service_indication->cod, MFW_BT_DEVICE_CLASS_LEN);
memcpy(id_ptr->device_id->service_name, service_indication->service_name, MFW_BT_SERVICE_NAME_MAX_LEN);/* new name */
help_id->next->next = NULL;/* finish chain */
#ifdef _SIMULATION_
TRACE_EVENT_P1("sync found ind = %s", help_id->next->bd_name);
#endif
}
}
bt_signal(BT_SERVICE_FOUND_IND, service_indication);
MFREE(service_indication);
return TRUE;
case BTP_SERVICE_SEARCH_CNF:
/* BTI confirms finish of search of services */
MALLOC(search_conf, sizeof(T_MFW_BT_SERVICE_SEARCH_CNF));
memset(search_conf, 0, sizeof(T_MFW_BT_SERVICE_SEARCH_CNF));
search_conf->service = ((T_BTP_SERVICE_SEARCH_CNF *)data)->device;
bt_signal(BT_SERVICE_SEARCH_CNF, search_conf);
#ifdef _SIMULATION_
TRACE_EVENT("sync search cnf");
#endif
MFREE(search_conf);
return TRUE;
case BTP_DEVICE_SEARCH_CNF:
/* BTI confirms finish of search of devices */
MALLOC(dev_search_conf, sizeof(T_MFW_BT_DEVICE_SEARCH_CNF));
memset(dev_search_conf, 0, sizeof(T_MFW_BT_DEVICE_SEARCH_CNF));
dev_search_conf->result = ((T_BTP_DEVICE_SEARCH_CNF *)data)->result;
bt_signal(BT_DEVICE_SEARCH_CNF, dev_search_conf);
MFREE(dev_search_conf);
return TRUE;
case BTP_CONNECT_DEVICE_CNF:
/* BTI confirms connection */
MALLOC(connect_cnf, sizeof(T_MFW_BT_CONNECT_CNF));
memset(connect_cnf, 0, sizeof(T_MFW_BT_CONNECT_CNF));
connect_cnf->service = ((T_BTP_CONNECT_DEVICE_CNF *)data)->device;
memcpy(connect_cnf->bd_addr, ((T_BTP_CONNECT_DEVICE_CNF *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
connect_cnf->result_bd = ((T_BTP_CONNECT_DEVICE_CNF *)data)->result;
connect_cnf->cnf_id = ((T_BTP_CONNECT_DEVICE_CNF *)data)->cnf_id;
connect_cnf->cause = ((T_BTP_CONNECT_DEVICE_CNF *)data)->cause;
bt_signal(BT_CONNECT_DEVICE_CNF, connect_cnf);
#ifdef _SIMULATION_
TRACE_EVENT_P4("conn cnf = %d, %d, %d, %s", connect_cnf->service, connect_cnf->result_bd, connect_cnf->cause, connect_cnf->bd_addr);
#endif
MFREE(connect_cnf);
return TRUE;
case BTP_CONNECT_DEVICE_IND:
/* BTI indicates that a remote device wants to establish a connection */
MALLOC(connect_ind, sizeof(T_MFW_BT_CONNECT_IND));
memset(connect_ind, 0, sizeof(T_MFW_BT_CONNECT_IND));
connect_ind->service = ((T_BTP_CONNECT_DEVICE_IND *)data)->device;
connect_ind->mfw_src_id = ((T_BTP_CONNECT_DEVICE_IND *)data)->src_id;
switch(connect_ind->service)
{
case MFW_BT_SYNC_CMD:
memcpy(connect_ind->bd_addr, ((T_BTP_CONNECT_DEVICE_IND *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
memcpy(connect_ind->bd_name, ((T_BTP_CONNECT_DEVICE_IND *)data)->bd_name, MFW_BT_NAME_MAX_LEN);
connect_ind->ind_id = ((T_BTP_CONNECT_DEVICE_IND *)data)->ind_id;
break;
case MFW_BT_HEADSET:
if(connect_ind->mfw_src_id NEQ MFW_BT_GSM_NETWORK) /* indication from remote headset */
{
connect_ind->ind_id = ((T_BTP_CONNECT_DEVICE_IND *)data)->ind_id;
memcpy(connect_ind->bd_addr, ((T_BTP_CONNECT_DEVICE_IND *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
}
break;
default:
break;
}
bt_signal(BT_CONNECT_DEVICE_IND, connect_ind);
#ifdef _SIMULATION_
if((connect_ind->service EQ MFW_BT_SYNC_CMD) OR (connect_ind->service EQ MFW_BT_HEADSET))
{
TRACE_EVENT_P3("conn ind = %d %d %s", connect_ind->service, connect_ind->mfw_src_id, connect_ind->bd_addr);
}
else
TRACE_EVENT_P2("conn ind = %d %d", connect_ind->service, connect_ind->mfw_src_id);
#endif
MFREE(connect_ind);
return TRUE;
case BTP_PIN_IND:
/* BTI indicates that a pin code is needed */
MALLOC(pin_indication, sizeof(T_MFW_BT_PIN_IND));
memset(pin_indication, 0, sizeof(T_MFW_BT_PIN_IND));
memcpy(pin_indication->bd_addr, ((T_BTP_PIN_IND *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
memcpy(pin_indication->bd_name, ((T_BTP_PIN_IND *)data)->bd_name, MFW_BT_NAME_MAX_LEN);
bt_signal(BT_PIN_IND, pin_indication);
#ifdef _SIMULATION_
TRACE_EVENT_P2("pin = %s %s", pin_indication->bd_name, pin_indication->bd_addr);
#endif
MFREE(pin_indication);
return TRUE;
case BTP_AUTHORIZATION_IND:
/* BTI indicates that a authorization reply is needed */
MALLOC(authorization_ind, sizeof(T_MFW_BT_AUTHORIZATION_IND));
memset(authorization_ind, 0, sizeof(T_MFW_BT_AUTHORIZATION_IND));
memcpy(authorization_ind->bd_addr, ((T_BTP_AUTHORIZATION_IND *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
memcpy(authorization_ind->bd_name, ((T_BTP_AUTHORIZATION_IND *)data)->bd_name, MFW_BT_NAME_MAX_LEN);
memcpy(authorization_ind->appli_name, ((T_BTP_AUTHORIZATION_IND *)data)->appli_name, MFW_BT_APPL_NAME_MAX_LEN);
authorization_ind->auth_mask_mfw = ((T_BTP_AUTHORIZATION_IND *)data)->authorization_mask_serv;
authorization_ind->connection_dir = ((T_BTP_AUTHORIZATION_IND *)data)->incom_conn;
bt_signal(BT_AUTHORIZATION_IND, authorization_ind);
#ifdef _SIMULATION_
TRACE_EVENT_P4("author ind = %x %d %s %s", authorization_ind->auth_mask_mfw, authorization_ind->connection_dir, authorization_ind->bd_name, authorization_ind->appli_name);
#endif
MFREE(authorization_ind);
return TRUE;
case BTP_TRANSFER_AUDIO_OUT_CNF:
/* BTI confirms audio connection to device */
MALLOC(audio_out_cnf, sizeof(T_MFW_BT_TRANSFER_AUDIO_OUT_CNF));
memset(audio_out_cnf, 0, sizeof(T_MFW_BT_TRANSFER_AUDIO_OUT_CNF));
audio_out_cnf->service = ((T_BTP_TRANSFER_AUDIO_OUT_CNF *)data)->device;
audio_out_cnf->result_bd = ((T_BTP_TRANSFER_AUDIO_OUT_CNF *)data)->result;
memcpy(audio_out_cnf->bd_addr, ((T_BTP_TRANSFER_AUDIO_OUT_CNF *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
audio_out_cnf->cnf_id = ((T_BTP_TRANSFER_AUDIO_OUT_CNF *)data)->cnf_id;
bt_signal(BT_TRANSFER_AUDIO_OUT_CNF, audio_out_cnf);
#ifdef _SIMULATION_
TRACE_EVENT_P2("audio out cnf = %d, %s", audio_out_cnf->service, audio_out_cnf->bd_addr);
#endif
MFREE(audio_out_cnf);
return TRUE;
case BTP_TRANSFER_AUDIO_IN_CNF:
/* BTI confirms audio connection from headset */
MALLOC(audio_in_cnf, sizeof(T_MFW_BT_TRANSFER_AUDIO_IN_CNF));
memset(audio_in_cnf, 0, sizeof(T_MFW_BT_TRANSFER_AUDIO_IN_CNF));
audio_in_cnf->service = ((T_BTP_TRANSFER_AUDIO_IN_CNF *)data)->device;
audio_in_cnf->result_bd = ((T_BTP_TRANSFER_AUDIO_IN_CNF *)data)->result;
memcpy(audio_in_cnf->bd_addr, ((T_BTP_TRANSFER_AUDIO_IN_CNF *)data)->bd_addr, MFW_BT_ADDR_MAX_LEN);
bt_signal(BT_TRANSFER_AUDIO_IN_CNF, audio_in_cnf);
#ifdef _SIMULATION_
TRACE_EVENT_P2("audio in cnf = %d, %s", audio_in_cnf->service, audio_in_cnf->bd_addr);
#endif
MFREE(audio_in_cnf);
return TRUE;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -