/*********************************************************************** * * FUNCTION NAME: OBEX_RegisterService * DESCRIPTION: This function * KNOWN ISSUES: none. * * ***********************************************************************/ APIDECL1 t_api APIDECL2 OBEX_RegisterService(u_int32 tid_s,t_obex_service_handler handler, u_int8 length, u_int8* target, void* cref) { struct prh_obex_service_registration *p_temp, *p_new; /* check arguments */ p_temp = obex_registered_services; if(p_temp) { tim1: if(prh_obex_compair_registration(p_temp,length,target) == BT_NOERROR) { return BT_HOSTERROR; } else { if(p_temp->p_next) { p_temp = p_temp->p_next; goto tim1; } else { p_new = pMalloc(sizeof(struct prh_obex_service_registration)); if(!p_new) return BT_NORESOURCES; p_new->handler = handler; p_new->tid = tid_s; p_new->target = pMalloc(length); pMemcpy(p_new->target,target,length); p_new->target_length = length; p_new->cid = 0x00; p_new->p_next = 0x00; p_temp->p_next = p_new; } } } else { p_temp = pMalloc(sizeof(struct prh_obex_service_registration)); if(!p_temp) return BT_NORESOURCES; p_temp->handler = handler; p_temp->tid = tid_s; //p_temp->target = target; p_temp->target = pMalloc(length); pMemcpy(p_temp->target,target,length); p_temp->target_length = length; p_temp->cid = 0x00; p_temp->p_next = 0x00; obex_registered_services = p_temp; } return BT_NOERROR; }
prh_t_hu_outcome UT_TP_RFC_BV_03_C(int p1, void *arg) { int ret, dummy; void *conn_handle; t_bdaddr remote_dev; struct host_buf *pdu_buf; int pdu_type; prh_t_hu_outcome outcome=HU_FAILED; u_int8 expected_answer[]={ 0x03, 0x73, 0x01, 0xD7 }; u_int8 expected_length=4; pMemcpy(remote_dev.bytes, "\x00\x01\x02\x03\x04\x05", 6); ret=prh_stub_l2cap_setup_l2_connection(remote_dev, RFCOMM_PSM, TEST_CID, &conn_handle); if (ret==BT_NOERROR) { rftest_sendsabm(conn_handle, 0, 1, 1); rftest_dumppdu(); rftest_senddisc(conn_handle, 0, 1, 1); rftest_takepdu(&pdu_buf, &dummy); if (!(pMemcmp(pdu_buf->data, expected_answer, expected_length))) outcome=HU_PASSED; } else outcome=HU_FAILED; return outcome; }
prh_t_hu_outcome UT_TP_RFC_BV_01_C(int p1, void *arg) { int ret; void *conn_handle; t_bdaddr remote_dev; struct host_buf *pdu_buf; int pdu_type; u_int8 expected_answer[]={ 0x03, 0x3F, 0x01, 0x1C }; u_int8 expected_length=4; prh_t_hu_outcome outcome=HU_FAILED; pMemcpy(remote_dev.bytes, "\x00\x01\x02\x03\x04\x05", 6); ret=PE_CliConnectPort(remote_dev, TEST_REMOTE_CHAN, "hello", UT_RFCOMM_test_connect_cb); if(ret==BT_PENDING) { prh_stub_l2cap_accept_l2_connection(&conn_handle); rftest_takepdu(&pdu_buf, &pdu_type); fprintf(stderr,"pdu_buf size is %d\n", pdu_buf->len); rftest_sendua(conn_handle, 0, 1, 1); if (!(pMemcmp(pdu_buf->data, expected_answer, expected_length))) outcome=HU_PASSED; else outcome=HU_FAILED; } return outcome; }
void prh_tcs_groupAddMember(u_int16 cid, t_bdaddr bdaddr, u_int16 status) { groupAddMemberStatus=status; groupAddMemberCid=cid; pMemcpy(&groupAddMemberBdaddr,&bdaddr,sizeof(t_bdaddr)); pEventSet(prh_tcs_groupAddMemberEvent); pEventFree(prh_tcs_groupAddMemberEvent); }
APIDECL1 t_api APIDECL2 TCS_TLConnectToGW(t_bdaddr GWbdAddress, void (*callbackFunc)(t_bdaddr address, t_api status)) { if(connectToGWCompleteCB) return BT_UNKNOWNERROR; /* only allow one GW to be connected */ if(0 != TCSInstance.cid) return BT_DISALLOWED; connectToGWCompleteCB = callbackFunc; pMemcpy(&(TCSInstance.GWBDAddress.bytes), &(GWbdAddress.bytes), 6); prh_tcs_connect_device_control(GWbdAddress, PRH_TCS_PSM_TCSCORDLESS, NULL, prh_tcs_cc_callback_L2ConnComplete); return BT_PENDING; }
int prh_tcs_wug_keydb_trav_helper(void *data, void *input) { struct prh_st_tcs_wug_member *instance=(struct prh_st_tcs_wug_member *)data; struct prh_st_tcs_wug_member *wug_mem=(struct prh_st_tcs_wug_member *)input; int ret; struct prh_st_tcs_wug_member_link_key *link_key1, *link_key2; /* generate link key */ link_key1=(struct prh_st_tcs_wug_member_link_key *)pMalloc(sizeof(struct prh_st_tcs_wug_member_link_key)); if (link_key1==pNULL) return BT_NORESOURCES; link_key2=(struct prh_st_tcs_wug_member_link_key *)pMalloc(sizeof(struct prh_st_tcs_wug_member_link_key)); if (link_key2==pNULL) { pFree(link_key1); return BT_NORESOURCES; } prh_tcs_wug_keydb_generate_linkkey(link_key1->link_key); pMemcpy(link_key2->link_key, link_key1->link_key, 16); link_key1->peer = instance->addr; link_key2->peer = wug_mem->addr; /* add link key to both wug_members */ ret=prh_tcs_wug_keydb_add_key(wug_mem, link_key1); if (ret!=BT_NOERROR) { pFree(link_key1); pFree(link_key2); return BT_NORESOURCES; } ret=prh_tcs_wug_keydb_add_key(instance, link_key2); if (ret!=BT_NOERROR) { prh_tcs_wug_keydb_remove_key_by_bd_addr(wug_mem, instance->addr, &link_key1); pFree(link_key1); pFree(link_key2); return BT_NORESOURCES; } return BT_NOERROR; }
prh_t_hu_outcome UT_TP_RFC_BV_05_C(int p1, void *arg) { int ret, dummy; void *conn_handle; t_bdaddr remote_dev; struct host_buf *pdu_buf; int pdu_type; int ptype; prh_t_hu_outcome outcome=HU_FAILED; u_int8 expected_answer[]={ 0x2B, 0x3F, 0x01, 0x8c }; u_int8 expected_length=4; pMemcpy(remote_dev.bytes, "\x00\x01\x02\x03\x04\x05", 6); ret=PE_CliConnectPort(remote_dev, TEST_REMOTE_CHAN, "hello", UT_RFCOMM_test_connect_cb); if (ret==BT_PENDING) { prh_stub_l2cap_accept_l2_connection(&conn_handle); rftest_dumppdu(); rftest_sendua(conn_handle, 0, 1, 1); do { rftest_takepdu(&pdu_buf, &pdu_type); ptype=pdu_buf->data[1]; if (ptype==0xef) /* check is this a UIH frame */ { int type; if ((pdu_buf->data[3] & 0xFC) == PRH_RFCOMM_CC_TYPE_PN) rftest_sendpn(conn_handle, pdu_buf->data[5], 0, 127); L2_FreeWriteBuffer(pdu_buf); } } while(ptype!=0x3f); if (!(pMemcmp(pdu_buf->data, expected_answer, expected_length))) outcome=HU_PASSED; else outcome=HU_FAILED; } else outcome=HU_FAILED; return outcome; }
void UT_TP_RFC_not_used(void) { int ret; void *conn_handle; t_bdaddr remote_dev; struct host_buf *pdu_buf; int pdu_type; prh_t_hu_outcome outcome; pMemcpy(remote_dev.bytes, "\x00\x01\x02\x03\x04\x05", 6); outcome=HU_PASSED; test_event=pEventCreate(FALSE); ret=PE_CliConnectPort(remote_dev, TEST_REMOTE_CHAN, "hello", UT_RFCOMM_test_connect_cb); RFCOMMLT_GetLastConnectHandle(&conn_handle); /* feed in a connect response */ RFCOMMLT_Send_ConnectConfirm(conn_handle); RFCOMMLT_Send_ConfigureIndication(conn_handle); RFCOMMLT_Send_ConfigureComplete(conn_handle); rftest_takepdu(&pdu_buf, &pdu_type); fprintf(stderr,"pdu_buf size is %d\n", pdu_buf->len); rftest_sendua(conn_handle, 0, 1, 1); rftest_takepdu(&pdu_buf, &pdu_type); fprintf(stderr,"pdu_buf size is %d\n", pdu_buf->len); rftest_sendpn(conn_handle, 10, 0, 127); rftest_takepdu(&pdu_buf, &pdu_type); rftest_sendua(conn_handle, 10, 1, 1); if (ret==BT_PENDING) pEventWait(test_event); else outcome=HU_FAILED; return; }
prh_t_hu_outcome UT_TP_RFC_BV_06_C(int p1, void *arg) { int ret, dummy; void *conn_handle; t_bdaddr remote_dev; struct host_buf *pdu_buf; int pdu_type; int chan=TEST_REMOTE_CHAN; prh_t_hu_outcome outcome=HU_FAILED; u_int8 expected_answer[]={ 0x2B, 0x73, 0x01, 0x47 }; u_int8 expected_length=4; ret=PE_SrvRegisterPort("/dev/ptyr0", &chan, UT_RFCOMM_test_connect_cb); if (ret==BT_NOERROR) { pMemcpy(remote_dev.bytes, "\x00\x01\x02\x03\x04\x05", 6); ret=prh_stub_l2cap_setup_l2_connection(remote_dev, RFCOMM_PSM, TEST_CID, &conn_handle); if (ret==BT_NOERROR) { rftest_sendsabm(conn_handle, 0, 1, 1); rftest_dumppdu(); rftest_sendsabm(conn_handle, 10, 1, 1); rftest_takepdu(&pdu_buf, &pdu_type); if (!(pMemcmp(pdu_buf->data, expected_answer, expected_length))) outcome=HU_PASSED; } else outcome=HU_FAILED; } else outcome=HU_FAILED; //cuReport("Connect Test Failed\n", test_outcome==1); return outcome; }
struct st_t_TCS_TLPeer *prh_tcs_cc_core_getNewTLPeer(t_bdaddr address, /*u_int8 initState,*/ u_int16 cid) { int i, j; for(i=0; i<PRH_TCS_MAXTERMINALSPERGATEWAY; i++) { if(!(TCSInstance.TLPeer[i])) { TCSInstance.TLPeer[i] = (struct st_t_TCS_TLPeer *)pMalloc(sizeof(struct st_t_TCS_TLPeer)); if(!(TCSInstance.TLPeer[i])) return NULL; pMemcpy(&(TCSInstance.TLPeer[i]->bdAddress.bytes), &(address.bytes), 6); TCSInstance.TLPeer[i]->cid = cid; for(j=0; j<PRH_TCS_MAX_CALLS_PER_DEVICE; j++) TCSInstance.TLPeer[i]->callInstance[j] = NULL; TCSInstance.TLPeer[i]->bcastCallInstance = NULL; return TCSInstance.TLPeer[i]; } } return NULL; }
t_api prh_tcs_cc_core_storeCallParams(struct st_t_TCS_callParams **destRef, struct st_t_TCS_callParams *src) { struct st_t_TCS_callParams *dest; if(!destRef) return BT_INVALIDPARAM; if(*destRef) prh_tcs_cc_core_freeCallParams(*destRef); if(!src) { *destRef = NULL; return BT_NOERROR; } dest = (struct st_t_TCS_callParams *)pMalloc(sizeof(struct st_t_TCS_callParams)); if(dest) pMemcpy(dest, src, sizeof(struct st_t_TCS_callParams)); else return BT_NORESOURCES; if(dest) { pMemcpy(dest, src, sizeof(struct st_t_TCS_callParams)); if(PRH_TCS_CC_PARAM_BEARERCAPABILITY_EXISTS(src->bitMask) && PRH_TCS_BEARER_CAP_LINK_TYPE_ACL == src->linkType && src->aclBearer) { dest->aclBearer = (struct st_t_TCS_aclBearer *)pMalloc(sizeof(struct st_t_TCS_aclBearer)); if(dest->aclBearer) pMemcpy(dest->aclBearer, src->aclBearer, sizeof(struct st_t_TCS_aclBearer)); else return BT_NORESOURCES; } if(PRH_TCS_CC_PARAM_AUDIOCONTROL_EXISTS(src->bitMask) && src->audioControlInfo) { dest->audioControlInfo = (u_int8 *)pMalloc(src->audioControlInfoLength); if(dest->audioControlInfo) pMemcpy(dest->audioControlInfo, src->audioControlInfo, src->audioControlInfoLength); else return BT_NORESOURCES; } if(PRH_TCS_CC_PARAM_COMPANYSPECIFIC_EXISTS(src->bitMask) && src->companySpecific) { dest->companySpecific = (u_int8 *)pMalloc(src->companySpecificLength); if(dest->companySpecific) pMemcpy(dest->companySpecific, src->companySpecific, src->companySpecificLength); else return BT_NORESOURCES; } if(PRH_TCS_CC_PARAM_CALLEDPARTYNUMBER_EXISTS(src->bitMask) && src->calledPartyNumber) { dest->calledPartyNumber = (u_int8*)pMalloc(src->calledPartyNumberLength); if(dest->calledPartyNumber) pMemcpy(dest->calledPartyNumber, src->calledPartyNumber, src->calledPartyNumberLength); else return BT_NORESOURCES; } if(PRH_TCS_CC_PARAM_CALLINGPARTYNUMBER_EXISTS(src->bitMask) && src->callingPartyNumber) { dest->callingPartyNumber = (u_int8*)pMalloc(src->callingPartyNumberLength); if(dest->callingPartyNumber) pMemcpy(dest->callingPartyNumber, src->callingPartyNumber, src->callingPartyNumberLength); else return BT_NORESOURCES; } *destRef = dest; } return BT_NOERROR; }
void rdabt_hcit_sharemem_rx_data(void) { u_int16 *head; u_int8 *buff; u_int16 rx_type, rx_len, head_len; struct st_t_dataBuf *rx_buf; adp_data_msg_t data_msg; u_int16 header[2]; u_int8 page; u_int8 wakeup = 0; do{ head = hal_ShareMem_GetHeader(); rx_type = head[0]; rx_len = head[1]; if(rx_type == 6) { buff = hal_ShareMem_GetData(); cmd_rx_page = buff[0]; rdabt_cntx.tx_busy = 0; hal_ShareMem_NextData(1); wakeup = 1; break; } if(rx_type < 2 || rx_type > 4) break; //hal_HstSendEvent(SYS_EVENT,0x10190000+rx_type); //hal_HstSendEvent(SYS_EVENT,rx_len); if (RDABT_NOERROR!=HCI_GetReceiveBuffer(&rx_buf, rx_len)) break; pMemcpy(rx_buf->buf, hal_ShareMem_GetData(), rx_len); /* copy header bytes into PDU buffer*/ rx_buf->dataLen = rx_len; //hal_HstSendEvent(SYS_EVENT,rx_buf->buf[0]+(rx_buf->buf[3]<<16)+(rx_buf->buf[4]<<24)); data_msg.buff = rx_buf; data_msg.type = rx_type; rx_buf->transport = TRANSPORT_UART_ID; RDABT_Send_Message(ADP_DATA_IND, RDABT_ADP, RDABT_HCI, sizeof(adp_data_msg_t), &data_msg); hal_ShareMem_NextData(rx_len); page = hal_ShareMem_GetRxPage(); if(page != event_rx_page) { hal_ShareMem_SendData(&page, 1); header[0] = 0x6; header[1] = 1; hal_ShareMem_SendHeader(header); event_rx_page = page; //break; } //hal_HstSendEvent(SYS_EVENT,page); wakeup = 1; }while(1); if(wakeup) pWakeUpScheduler(); }
void rdabt_reply_rsp_cb(t_bdaddr address, int status) { LINK_PIN_CODE_RESULT_IND_ST mv1; LINK_PIN_CODE_CNF_ST mv2; bt_bm_service_search_req_struct service_msg; bt_bm_service_search_req_struct *service_msgp=&service_msg; kal_uint8 i; u_int8 flag_preset=0; struct st_t_BT_ConnectionEntry * cur=NULL, *next=NULL; bth_dev_struct dev_Info; bonding_role = 0; pincode_sent=1; if (pin_code_ind_timer)//zhou siyou add 20070725 { pTimerCancel(pin_code_ind_timer); pin_code_ind_timer=0; } memset(&dev_Info, 0, sizeof(bth_dev_struct)); kal_prompt_trace(1,"rdabt_reply_rsp_cb, found linkkey, status:%d\n", status); if( status == 0) { MGR_GetNextConnectionRecord(NULL, &next); while(next) { cur = next; if(BD_ADDR_CMP(next->bdAddress, address)) { if( next->linkKey) { dev_Info.bd_addr.lap= BDADDR_Get_LAP(&address); dev_Info.bd_addr.uap = BDADDR_Get_UAP(&address); dev_Info.bd_addr.nap = BDADDR_Get_NAP(&address); dev_Info.KeyType = next->linkKeyType; dev_Info.cod = next->cod; memcpy( dev_Info.linkKey, next->linkKey, 0x10); kal_prompt_trace(1,"rdabt_reply_rsp_cb, found linkkey, cod:%d\n", next->cod); flag_preset=1; } // break; } //else { MGR_GetNextConnectionRecord(cur, &next); } } //if(next && next->linkKey) if(flag_preset) { mv2.result = bth_write_paired_device_info(&dev_Info); } } mv1.type = LINK_BONDING_RESULT_IND; mv1.result = status; mv1.bd_addr.lap= BDADDR_Get_LAP(&address); mv1.bd_addr.uap = BDADDR_Get_UAP(&address); mv1.bd_addr.nap = BDADDR_Get_NAP(&address); mv1.cod = next?next->cod:0; pMemcpy(mv1.linkKey, dev_Info.linkKey, 16); mv1.KeyType = dev_Info.KeyType; // mmi_trace(g_sw_BT,"rdabt_reply_rsp_cb::status=%d", status); // mmi_trace_hex(g_sw_BT,16, dev_Info.linkKey); rdabt_put_message(EXTERNAL_TASK_MASK,LINK_Q,&mv1); mv2.type = LINK_BONDING_CNF; mv2.result = status; mv2.bd_addr = mv1.bd_addr; rdabt_put_message(EXTERNAL_TASK_MASK,LINK_Q,&mv2); if( mv2.result == 0) //modified by tan { service_msgp->bd_addr=mv1.bd_addr; service_msgp->sdap_len = pin_code_sdap.sdap_len; for (i = 0; i < BTBM_ADP_MAX_SDAP_UUID_NO; i++) { service_msgp->sdap_uuid[i] = pin_code_sdap.sdap_uuid[i]; } rdabt_SDP_serviceSearch(service_msgp); } }
prh_t_hu_outcome UT_TP_RFC_BV_07_C(int p1, void *arg) { int ret, dummy; void *conn_handle; t_bdaddr remote_dev; struct host_buf *pdu_buf; int pdu_type; int chan=TEST_REMOTE_CHAN; int ptype; prh_t_rfcomm_control_params ctrl_params; prh_t_hu_outcome outcome=HU_FAILED; u_int8 expected_answer[]={ 0x29, 0x53, 0x01, 0x0C }; u_int8 expected_length=4; ret=PE_SrvRegisterPort("/dev/ptyr5", &chan, UT_RFCOMM_test_connect_cb); if (ret==BT_NOERROR) { pMemcpy(remote_dev.bytes, "\x00\x01\x02\x03\x04\x05", 6); ret=prh_stub_l2cap_setup_l2_connection(remote_dev, RFCOMM_PSM, TEST_CID, &conn_handle); if (ret==BT_NOERROR) { rftest_sendsabm(conn_handle, 0, 1, 1); rftest_dumppdu(); rftest_sendsabm(conn_handle, 10, 1, 1); rftest_takepdu(&pdu_buf, &pdu_type); do { rftest_takepdu(&pdu_buf, &pdu_type); ptype=pdu_buf->data[1]; if (ptype==0xef) /* check is this a UIH frame */ { int type; if ((pdu_buf->data[3] & 0xFC) == PRH_RFCOMM_CC_TYPE_MSC) { pMemset(&ctrl_params, 0, sizeof(ctrl_params)); rftest_sendmsc(conn_handle, 10, 0, &ctrl_params); PE_SrvDisconnectPort(5); } L2_FreeWriteBuffer(pdu_buf); } } while(ptype!=0x53); if (!(pMemcmp(pdu_buf->data, expected_answer, expected_length))) test_outcome=1; L2_FreeWriteBuffer(pdu_buf); } else test_outcome=0; } else test_outcome=0; cuReport("TP_RFC_BV_07_C failed\n", test_outcome==1); return; }
//03-28-2009, add by tan void rdabt_being_bonding_cb(t_bdaddr address, int status) { bth_dev_struct dev_Info; struct st_t_BT_ConnectionEntry * cur=NULL, *next=NULL; bt_bm_bonding_result_ind_struct *param_ptr=NULL; bt_bm_bonding_cnf_struct * bonding_cnf=NULL; u_int8 flag_present=0; kal_prompt_trace(1,"rdabt_being_bonding_cb status = %d\n",status); //status = 1; if( g_PairingFinished == 0) g_PairingFinished = 1; //7-12-2009, add by tan else return; memset(&dev_Info, 0, sizeof(bth_dev_struct)); param_ptr = (bt_bm_bonding_result_ind_struct*)construct_local_para((kal_uint16)sizeof(bt_bm_bonding_result_ind_struct), TD_CTRL); param_ptr->bd_addr.lap= BDADDR_Get_LAP(&address); param_ptr->bd_addr.uap = BDADDR_Get_UAP(&address); param_ptr->bd_addr.nap = BDADDR_Get_NAP(&address); kal_prompt_trace(1,"rdabt_being_bonding_cb\n"); if (wait_bonding_timer) { kal_prompt_trace(1,"wait_bonding_timer be canceled wait_bonding_timer=%d\n",wait_bonding_timer); pTimerCancel(wait_bonding_timer); wait_bonding_timer=0; } MGR_GetNextConnectionRecord(NULL, &next); while(next) { cur = next; if( BD_ADDR_CMP(next->bdAddress, address)) { if( next->linkKey) { kal_prompt_trace(1,"get the device' s info, link_key:%s and cod:%d\n", print_link_key(next->linkKey),next->cod); dev_Info.bd_addr = param_ptr->bd_addr; dev_Info.KeyType = next->linkKeyType; memcpy( dev_Info.linkKey, next->linkKey, 0x10); dev_Info.cod =param_ptr->cod = next->cod; flag_present=1;//zhou siyou add 20070725 } //break; } //else { MGR_GetNextConnectionRecord(cur, &next); } } //if(next && next->linkKey) if(flag_present) { bth_write_paired_device_info(&dev_Info); status = 0; // kal_prompt_trace(1,"write the device info into a file, status:%d (0 indicates succeed)\n", status_tem); } param_ptr->result = status; pMemcpy(param_ptr->linkKey, dev_Info.linkKey, 16); param_ptr->KeyType = dev_Info.KeyType; bonding_cnf = (bt_bm_bonding_cnf_struct *)construct_local_para((kal_uint16)sizeof(bt_bm_bonding_cnf_struct), TD_CTRL); bonding_cnf->result = status; bonding_cnf->bd_addr = param_ptr->bd_addr; rdabt_send_msg_up(MOD_MMI, MSG_ID_BT_BM_BONDING_RESULT_IND, (void *)param_ptr, NULL); rdabt_send_msg_up(MOD_MMI, MSG_ID_BT_BM_BE_BONDING_CNF, (void*)bonding_cnf, NULL);//zhou siyou add 200728 if(deviceName != NULL) { pFree(deviceName); deviceName = NULL; nameLen = 0; } return ; }
/************************************************************************************************* * FUNCTION :- prh_mgr_store_inquiry_entry * * DESCRIPTION :- This function stores an inquiry result in the inq db. If the device is already * in the database the parameters will be updates otherwise a new entry will be * added to the inq db. * NOTE:inquiryresult passed in is one set of page parameters, there may be many * in a single hci event * ************************************************************************************************/ struct st_t_BT_InquiryInfo *prh_mgr_store_inquiry_entry(u_int8 *inquiryResult) { struct st_t_BT_InquiryInfo *current; extern u_int32 prh_mgr_inqdb_num_entries; // char err_str[40]={0}; if(inquiryResult == NULL) return NULL; pMutexLock(prh_mgr_inqdb_list_lock); current=prh_mgr_inqdb_head; pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: linklist is NULL? %d\n", prh_mgr_inqdb_head?1:0)); while (current) { if (BD_ADDR_CMP(current->bdAddress,*(t_bdaddr*)(inquiryResult+0))) /* check alignment correctness here */ break; current=current->next; } #if pDEBUG if (!current) { pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: cannot find existing entry for device %s\n",prh_mgr_printBDAddress(*(t_bdaddr*)(inquiryResult+0)))); } #endif if (current) { if(current->entryUsage) { /* entry already exists, but is in use, so cannot be updated */ pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: cannot find existing entry for device %s\n",prh_mgr_printBDAddress(*(t_bdaddr*)(inquiryResult+0)))); pMutexUnlock(prh_mgr_inqdb_list_lock); return current; } else { prh_mgr_unlink_inquiry_entry(current); } } else { pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: prh_mgr_inqdb_num_entries=%d\n", prh_mgr_inqdb_num_entries)); if (prh_mgr_inqdb_num_entries<(u_int32)HOST_INQDB_MAX_DEVICE_ENTRIES) { /* alloc a new record */ current=pMalloc(sizeof(struct st_t_BT_InquiryInfo)); if (!current) { pMutexUnlock(prh_mgr_inqdb_list_lock); return NULL; } current->deviceName = NULL; #if HOST_INQDB_CULL_THRESHOLD!=0 if (!prh_mgr_inqdb_num_entries) /* we are adding to an empty database */ prh_mgr_inqdb_timer_handle=pTimerCreate(HOST_INQDB_CULL_GRANULARITY,prh_mgr_cull_inquiry_db,NULL,pTIMER_ONESHOT); #endif prh_mgr_inqdb_num_entries++; } else { /* find the oldest non-inuse record */ current=prh_mgr_inqdb_tail; while (current) { if (current->entryUsage) current=current->prev; else break; } if (!current) { /* no available entry */ pMutexUnlock(prh_mgr_inqdb_list_lock); pDebugPrintfEX((pLOGNOTICE,pLOGMANAGER,"prh_mgr_store_inquiry_entry: prh_mgr_inqdb_num_entries==HOST_INQDB_MAX_DEVICE_ENTRIES (%d) and all entries in use\n",HOST_INQDB_MAX_DEVICE_ENTRIES)); return NULL; } prh_mgr_unlink_inquiry_entry(current); } current->entryAge=1; /* only modified when an entry did not already exist for this adress */ current->nameRetrieved = 0; } //Lu added /* fill out the parameters */ pMemcpy(¤t->bdAddress,inquiryResult+0,6); current->pageScanRepetitionMode=inquiryResult[6]; current->pageScanPeriodMode=inquiryResult[7]; current->pageScanMode=inquiryResult[8]; current->classOfDevice=inquiryResult[9]|(inquiryResult[10]<<8)|(inquiryResult[11]<<16); current->clockOffset=inquiryResult[12]|(inquiryResult[13]<<8); /* Do not fill in current->deviceName until RemoteNameRequest is complete */ current->entryUsage=1; /* entry starts marked as 'in-use' */ /* add this new record (to the head of the list) */ current->next=prh_mgr_inqdb_head; current->prev=NULL; if (current->next) current->next->prev=current; prh_mgr_inqdb_head=current; if (!prh_mgr_inqdb_tail) prh_mgr_inqdb_tail=current; pDebugPrintfEX((pLOGDEBUG,pLOGMANAGER,"prh_mgr_store_inquiry_entry: current->entryAge=%d, current->classOfDevice=0x%x\n", current->entryAge,current->classOfDevice)); pMutexUnlock(prh_mgr_inqdb_list_lock); return current; }
/*********************************************************************** * * FUNCTION NAME: OBEX_SuggestSync * DESCRIPTION: This function will send a PUSH command to the IrMC Client * KNOWN ISSUES: none. * * ***********************************************************************/ APIDECL1 t_api APIDECL2 OBEX_SuggestSync(u_int32 tid_s, u_int8 type, char* pAny, u_int8 length,t_obex_command_handler handler) { t_DataBuf* buff; // object name is " t e l e c o m / p u s h . t x t "; // \r\n // "telecom/pb.vcf" // "telecom/cal.vcs" // "telecom/note.vnt" // "telecom/inmsg.vmg" // "telecom/outmsg.vmg" // "telecom/sentmsg.vmg"f // "telecom/rtc.txt" // "default" u_int8 *buffer; u_int8 offset_len; u_int16 t_offset; u_int8 lcv; u_int8 obj_name[34]; pMemcpy(obj_name," t e l e c o m / p u s h . t x t ",34); buffer = pMalloc(165 + length); offset_len = 0; if(type & 1) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/pb.vcf\r\n",16); offset_len += 16; } if(type & 2) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/cal.vcf\r\n",17); offset_len += 17; } if(type & 4) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/note.vcf\r\n",18); offset_len += 18; } if(type & 8) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/inmsg.vcf\r\n",19); offset_len += 19; } if(type & 16) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/outmgs.vcf\r\n",20); offset_len += 20; } if(type & 32) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/sentmgs.vcf\r\n",21); offset_len += 21; } if(type & 64) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "telecom/rtc.vcf\r\n",17); offset_len += 17; } if(!type) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , "default\r\n",9); offset_len += 9; } if(pAny) { pMemcpy(buffer + offset_len ,"SYNC:",5); offset_len += 5; pMemcpy(buffer + offset_len , pAny ,length); offset_len += length; buffer[offset_len++] = '\r'; buffer[offset_len++] = '\n'; } OBEX_GetWriteBuffer(300,&buff); /* buff = (t_DataBuf*)host_buf_alloc(300); host_buf_reserve_header((struct host_buf*)buff,20); */ t_offset = 3; for(lcv = 0; lcv < 33; lcv+=2) { obj_name[lcv] = 0; } OBEX_CreateStringHeader(OBEX_NAME,(u_int16)16,(u_int16*)obj_name,buff,&t_offset); OBEX_Create4ByteHeader(OBEX_LENGTH,offset_len,buff, &t_offset); OBEX_CreateSequenceHeader(OBEX_BODY,offset_len,buffer,buff,&t_offset); OBEX_CreateSequenceHeader(OBEX_END_BODY,0,0,buff,&t_offset); OBEX_Put(tid_s,0x01,t_offset,buff,handler); return BT_NOERROR; }
APIDECL1 t_api APIDECL2 TCS_TLRegister(u_int8 flag, struct st_t_TCS_callbacks *callbacks, t_bdaddr *GWBDAddress, u_int8 connectToGW, void (*callback)(t_api status)) { t_api status; int i; #if (PRH_TCS_TERMINAL && PRH_TCS_GATEWAY) tcsMode = PRH_TCS_MODE_TERMINAL; #endif if( !(PRH_TCS_ENABLE_TCSCORDLESS(flag)) && !(PRH_TCS_ENABLE_TCSBIN(flag)) ) return BT_INVALIDPARAM; /* Use flags to register for TCSBIN and TCSCORDLESS psms */ if(BT_NOERROR != (status = prh_tcs_init(flag))) return status; if(BT_NOERROR != (status = prh_tcs_register_connectionCallbacks(prh_tcs_cc_core_TLconnectIndCallback, prh_tcs_cc_core_TLdisconnectIndCallback))) return status; if(!callbacks) return BT_INVALIDPARAM; /* Currently only allowing one TL instance, so return BT_NORESOURCES */ if(TCSInstance.callbacks) return BT_NORESOURCES; TCSInstance.callbacks = (struct st_t_TCS_callbacks*)pMalloc(sizeof(struct st_t_TCS_callbacks)); if(!TCSInstance.callbacks) return BT_NORESOURCES; pMemcpy(TCSInstance.callbacks, (struct st_t_TCS_callbacks*)callbacks, sizeof(struct st_t_TCS_callbacks)); if(PRH_TCS_ENABLE_TCSCORDLESS(flag)) { /* For receiving broadcast data from GW */ status = L2_EnableConnectionlessTraffic(PRH_TCS_PSM_TCSCORDLESS); if(status != BT_NOERROR) { /* 4 now take no action as we still want to continue even though we can't get broadcast info. may want to review this when a definite scheme (re broadcast)for call setup is in place ie if broadcast all the time then no point in continuing here*/ } if(GWBDAddress) pMemcpy(&(TCSInstance.GWBDAddress.bytes), GWBDAddress->bytes, 6); for(i=0; i<PRH_TCS_MAX_CALLS_PER_DEVICE; i++) TCSInstance.callInstance[i] = NULL; if(connectToGW) { if(!callback) return BT_INVALIDPARAM; registerCompleteCB = callback; /* NULL is passed as callInstance because no call is being initiated */ prh_tcs_connect_device_control(TCSInstance.GWBDAddress, PRH_TCS_PSM_TCSCORDLESS, NULL, prh_tcs_cc_callback_L2ConnComplete); return BT_PENDING; } } return BT_NOERROR; }