/**************************************************************************** NAME connectionHandleSdpOpenSearchCfm DESCRIPTION Handle the response to the open SDP session request RETURNS void */ void connectionHandleSdpOpenSearchCfm(connectionSdpState *state, const SDC_OPEN_SEARCH_CFM_T *cfm) { if(state->sdpLock == connectionGetCmTask()) { /* Request was internal, start SDP Ping */ uint8* sdp_ptr = (uint8 *) SdpPingServiceRequest; if (cfm->result == SDC_OPEN_SEARCH_OK) ConnectionSdpServiceSearchRequest(connectionGetCmTask(), &state->sdpServerAddr, 1, sizeof(SdpPingServiceRequest), sdp_ptr); } else if(state->sdpLock) { /* Send a response message up to the client */ MAKE_CL_MESSAGE(CL_SDP_OPEN_SEARCH_CFM); message->status = connectionConvertSdpOpenStatus(cfm->result); MessageSend(state->sdpLock, CL_SDP_OPEN_SEARCH_CFM, message); } /* Check if the open search succeeded */ if (cfm->result != SDC_OPEN_SEARCH_OK) { /* Reset the resource lock */ state->sdpLock = 0; /* Reset the stored address */ BdaddrSetZero(&state->sdpServerAddr); } }
void ConnectionInitEx(Task theAppTask, const msg_filter *msgFilter) { theCm.msgFilter = msgFilter; /* Turn on extended bluestack prims */ VmUseExtendedBluestackPrimitives(); /* Initialise the Connection Library Task, all upstream messages sent by Bluestack will be handled by this task */ theCm.task.handler = connectionBluestackHandler; /* If a task is already registered to receive BlueStack prims then we panic! */ if (MessageBlueStackTask(connectionGetCmTask())) { CL_DEBUG(("ERROR - task already registered\n")); } /* Init the resource locks */ initLocks(); /* Store the application task */ theCm.theAppTask = theAppTask; /* Start the initialisation process */ MessageSend(connectionGetCmTask(), CL_INTERNAL_INIT_REQ, NO_PAYLOAD); }
/**************************************************************************** NAME connectionHandleSdpOpenSearchRequest DESCRIPTION Send a request to BlueSTack to open an SDP search session RETURNS void */ void connectionHandleSdpOpenSearchRequest(connectionSdpState *state, const CL_INTERNAL_SDP_OPEN_SEARCH_REQ_T *req) { /* Check the state of the resource lock */ if (!state->sdpLock) { /* Resource free, set the lock */ state->sdpLock = req->theAppTask; /* Store the address of the device we're opening the search to */ state->sdpServerAddr = req->bd_addr; /* Send the request to BlueStack */ { MAKE_PRIM_T(SDC_OPEN_SEARCH_REQ); connectionConvertBdaddr_t(&prim->bd_addr, &req->bd_addr); VmSendSdpPrim(prim); } } else if(req->theAppTask != connectionGetCmTask()) { /* Resource busy so queue up the request */ MAKE_CL_MESSAGE(CL_INTERNAL_SDP_OPEN_SEARCH_REQ); COPY_CL_MESSAGE(req, message); MessageSendConditionallyOnTask(connectionGetCmTask(), CL_INTERNAL_SDP_OPEN_SEARCH_REQ, message, &state->sdpLock); } }
void connectionHandleRfcommEstablishCfm(const RFC_ESTABLISH_CFM_T* cfm) { /* Get the connection instance data keyed by server channel and mux id */ conn_instance *conn = getRfcommConnection(NULL, cfm->mux_id, cfm->server_chan); if(conn) { if(cfm->result_code == RFC_SUCCESS) { /* Move to the modem status phase */ conn->config.rfcomm.state = modem_status_phase; /* Send modem status signal, data cannot be exchanged until both sides have exchanged modem status signals */ startControlPhase(conn); } else if (cfm->result_code == DLC_ALREADY_EXISTS) { /* Send a cfm to the app indicating an error has ocurred*/ sendRfcommConnectionCfm(conn->config.rfcomm.app_task, rfcomm_connect_channel_already_open, INVALID_SERVER_CHANNEL, 0, 0); /* Cancel the connect timeout and clean up the connection state data. */ (void) MessageCancelFirst(connectionGetCmTask(), CL_INTERNAL_RFCOMM_CONNECT_TIMEOUT_IND); (void) deleteRfcommConnection(NULL, cfm->mux_id, cfm->server_chan); } else if (cfm->result_code == REMOTE_REFUSAL) { /* Connection establishment failed, clean up */ endConnection(conn); /* Inform the app of the failure */ sendRfcommConnectionCfm(conn->config.rfcomm.app_task, rfcomm_connect_rejected, INVALID_SERVER_CHANNEL, 0, 0); /* Cancel the connect timeout and clean up the connection state data. */ (void) MessageCancelFirst(connectionGetCmTask(), CL_INTERNAL_RFCOMM_CONNECT_TIMEOUT_IND); (void) deleteRfcommConnection(NULL, cfm->mux_id, cfm->server_chan); } else { /* Connection establishment failed, clean up */ endConnection(conn); /* Inform the app of the failure */ sendRfcommConnectionCfm(conn->config.rfcomm.app_task, rfcomm_connect_failed, INVALID_SERVER_CHANNEL, 0, 0); /* Cancel the connect timeout and clean up the connection state data. */ (void) MessageCancelFirst(connectionGetCmTask(), CL_INTERNAL_RFCOMM_CONNECT_TIMEOUT_IND); (void) deleteRfcommConnection(NULL, cfm->mux_id, cfm->server_chan); } } /* This could happen if the connect timeout has triggered and cleaned up the connection state entry and then we get an RFC_ESTABLISH_CFM indicating the remote end failed to respond. We should just ignore this cfm. */ }
void ConnectionSmAuthoriseResponse(const bdaddr* bd_addr, dm_protocol_id protocol_id, uint32 channel, bool incoming, bool authorised) { #ifdef CONNECTION_DEBUG_LIB if ((protocol_id != protocol_l2cap) && (protocol_id != protocol_rfcomm)) { CL_DEBUG(("ConnectionSmAuthoriseResponse - Out of range protocol id 0x%x\n", protocol_id)); } if((protocol_id == protocol_rfcomm) && ((channel < RFCOMM_SERVER_CHANNEL_MIN) || (channel > RFCOMM_SERVER_CHANNEL_MAX))) { CL_DEBUG(("cd ..Out of range RFCOMM server channel 0x%lx\n", channel)); } if(bd_addr == NULL) { CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void*)bd_addr)); } #endif { MAKE_CL_MESSAGE(CL_INTERNAL_SM_AUTHORISE_RES); message->bd_addr = *bd_addr; message->protocol_id = protocol_id; message->channel = channel; message->incoming = incoming; message->authorised = authorised; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_AUTHORISE_RES, message); } }
void ConnectionSmUnRegisterOutgoingService(const bdaddr* bd_addr, dm_protocol_id protocol_id, uint32 channel) { #ifdef CONNECTION_DEBUG_LIB if ((protocol_id != protocol_l2cap) && (protocol_id != protocol_rfcomm)) { CL_DEBUG(("Out of range protocol id 0x%x\n", protocol_id)); } /* TODO: Check if we should check channel range for outgoing service channel */ if((protocol_id == protocol_rfcomm) && ((channel < RFCOMM_SERVER_CHANNEL_MIN) || (channel > RFCOMM_SERVER_CHANNEL_MAX)) ) { CL_DEBUG(("Out of range RFCOMM server channel 0x%lx\n", channel)); } if(bd_addr == NULL) { CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void*)bd_addr)); } #endif { MAKE_CL_MESSAGE(CL_INTERNAL_SM_UNREGISTER_OUTGOING_REQ); message->bd_addr = *bd_addr; message->protocol_id = protocol_id; message->channel = channel; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_UNREGISTER_OUTGOING_REQ, message); } }
void ConnectionSmUserConfirmationResponse(const bdaddr* bd_addr, bool confirm) { MAKE_CL_MESSAGE(CL_INTERNAL_SM_USER_CONFIRMATION_REQUEST_RES); message->bd_addr = *bd_addr; message->confirm = confirm; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_USER_CONFIRMATION_REQUEST_RES, message); }
void ConnectionRfcommDeallocateChannel(Task theAppTask, uint8 local_server_channel) { MAKE_CL_MESSAGE(CL_INTERNAL_RFCOMM_UNREGISTER_REQ); message->theAppTask = theAppTask; message->local_server_channel = local_server_channel; MessageSend(connectionGetCmTask(), CL_INTERNAL_RFCOMM_UNREGISTER_REQ, message); }
void ConnectionSmRegisterIncomingService(dm_protocol_id protocol_id, uint32 channel, dm_security_level security_level) { /* Check params are within allowed values - debug build only */ #ifdef CONNECTION_DEBUG_LIB if ((protocol_id != protocol_l2cap) && (protocol_id != protocol_rfcomm)) { CL_DEBUG(("Out of range protocol id 0x%x\n", protocol_id)); } if((protocol_id == protocol_rfcomm) && ((channel < RFCOMM_SERVER_CHANNEL_MIN) || (channel > RFCOMM_SERVER_CHANNEL_MAX))) { CL_DEBUG(("Out of range RFCOMM server channel 0x%lx\n", channel)); } if (security_level >= secl_level_unknown) { CL_DEBUG(("Out of range security level 0x%x\n", security_level)); } #endif { MAKE_CL_MESSAGE(CL_INTERNAL_SM_REGISTER_REQ); message->protocol_id = protocol_id; message->channel = channel; message->outgoing_ok = FALSE; message->security_level = security_level; message->psm = 0; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_REGISTER_REQ, message); } }
void ConnectionSyncRegister(Task theAppTask) { /* Send an internal register request message */ MAKE_CL_MESSAGE(CL_INTERNAL_SYNC_REGISTER_REQ); message->theAppTask = theAppTask; MessageSend(connectionGetCmTask(), CL_INTERNAL_SYNC_REGISTER_REQ, message); }
/**************************************************************************** NAME connectionHandleReadInquiryTx DESCRIPTION This function will initiate a read of the inquiry tx power of the device RETURNS void */ void connectionHandleReadInquiryTx(connectionReadInfoState* infoState, connectionInquiryState *state, const CL_INTERNAL_DM_READ_INQUIRY_TX_REQ_T *req) { /* Check command supported by firmware */ if(infoState->version != bluetooth_unknown) { /* Check the state of the task lock before doing anything */ if (!state->inquiryLock) { /* One request at a time */ state->inquiryLock = req->theAppTask; /* Issue request to read the inquiry tx */ { MAKE_PRIM_C(DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_REQ); VmSendDmPrim(prim); } } else { /* Remote name request currently being performed, queue up the request */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_READ_INQUIRY_TX_REQ); COPY_CL_MESSAGE(req, message); MessageSendConditionallyOnTask(connectionGetCmTask(), CL_INTERNAL_DM_READ_INQUIRY_TX_REQ, message, &state->inquiryLock); } } else { /* Tell the app this is unsupported */ MAKE_CL_MESSAGE(CL_DM_READ_INQUIRY_TX_CFM); message->status = hci_error_unsupported_feature; message->tx_power = 0; MessageSend(req->theAppTask, CL_DM_READ_INQUIRY_TX_CFM, message); } }
void ConnectionSetLinkSupervisionTimeout(Sink sink, uint16 timeout) { MAKE_CL_MESSAGE(CL_INTERNAL_DM_SET_LINK_SUPERVISION_TIMEOUT_REQ); message->sink = sink; message->timeout = timeout; MessageSend(connectionGetCmTask(), CL_INTERNAL_DM_SET_LINK_SUPERVISION_TIMEOUT_REQ, message); }
void ConnectionSmRegisterOutgoingService(Task theAppTask, const bdaddr* bd_addr, dm_protocol_id protocol_id, uint32 channel, dm_security_out security) { MAKE_CL_MESSAGE(CL_INTERNAL_SM_REGISTER_OUTGOING_REQ); #ifdef CONNECTION_DEBUG_LIB if ((protocol_id != protocol_l2cap) && (protocol_id != protocol_rfcomm)) { CL_DEBUG(("Out of range protocol id 0x%x\n", protocol_id)); } else if ((protocol_id == protocol_rfcomm) && !theAppTask) { CL_DEBUG(("App task undefined for RFCOMM\n")); } if(bd_addr == NULL) { CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void*)bd_addr)); } /* Are any bits other then valid dm_security_in bits are set. */ if (security & ~sec_out_bitmask) { CL_DEBUG(("Invalid dm_security_out bits set 0x%x\n", (security & ~sec_out_bitmask))); } #endif message->theAppTask = theAppTask; message->bd_addr = *bd_addr; message->protocol_id = protocol_id; message->remote_channel = channel; message->outgoing_security_level = security; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_REGISTER_OUTGOING_REQ, message); }
void ConnectionWriteClassOfDevice(uint32 cod) { /* All requests are sent through the internal state handler */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_WRITE_CLASS_OF_DEVICE_REQ); message->class_of_device = cod; MessageSend(connectionGetCmTask(), CL_INTERNAL_DM_WRITE_CLASS_OF_DEVICE_REQ, message); }
void ConnectionReadLocalVersion(Task theAppTask) { /* All requests are sent through the internal state handler */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_READ_LOCAL_VERSION_REQ); message->theAppTask = theAppTask; MessageSend(connectionGetCmTask(), CL_INTERNAL_DM_READ_LOCAL_VERSION_REQ, message); }
void ConnectionSmSendKeypressNotificationRequest(const bdaddr* bd_addr, cl_sm_keypress_type type) { MAKE_CL_MESSAGE(CL_INTERNAL_SM_SEND_KEYPRESS_NOTIFICATION_REQ); message->bd_addr = *bd_addr; message->type = type; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_SEND_KEYPRESS_NOTIFICATION_REQ, message); }
void ConnectionSdpAttributeSearchRequest(Task appTask, const bdaddr *bd_addr, uint16 max_num_recs, uint32 service_hdl, uint16 size_attribute_list, const uint8 *attribute_list) { #ifdef CONNECTION_DEBUG_LIB if (size_attribute_list == 0) CL_DEBUG(("sdp - attribute search pattern not supplied\n")); if (max_num_recs == 0) CL_DEBUG(("sdp - max number of attribute bytes set to zero\n")); if(bd_addr == NULL) CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void*)bd_addr)); #endif { MAKE_CL_MESSAGE(CL_INTERNAL_SDP_ATTRIBUTE_SEARCH_REQ); message->theAppTask = appTask; message->bd_addr = *bd_addr; message->service_handle = service_hdl; message->size_attribute_list = size_attribute_list; if (size_attribute_list) { message->attribute_list = (uint8 *)PanicUnlessMalloc(size_attribute_list); memcpy(message->attribute_list, attribute_list, size_attribute_list); } else message->attribute_list = 0; message->max_num_attr = max_num_recs; MessageSend(connectionGetCmTask(), CL_INTERNAL_SDP_ATTRIBUTE_SEARCH_REQ, message); } }
/**************************************************************************** NAME connectionHandleReadEirDataRequest DESCRIPTION Handles request for Reading the Extended Inquiry Data. RETURNS void */ void connectionHandleReadEirDataRequest(connectionReadInfoState *infoState, connectionInquiryState *state, const CL_INTERNAL_DM_READ_EIR_DATA_REQ_T *req) { if(infoState->version >= bluetooth2_1) { /* Check the state of the task lock before doing anything */ if (!state->inquiryLock) { state->inquiryLock = req->task; { MAKE_PRIM_C(DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_REQ); VmSendDmPrim(prim); } } else { /* Inquiry currently being performed, queue up the request */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_READ_EIR_DATA_REQ); COPY_CL_MESSAGE(req, message); MessageSendConditionallyOnTask(connectionGetCmTask(), CL_INTERNAL_DM_READ_EIR_DATA_REQ, message, &state->inquiryLock); } } else { /* Not supported, tell the app */ MAKE_CL_MESSAGE(CL_DM_READ_EIR_DATA_CFM); message->status = hci_error_unsupported_feature; message->fec_required = FALSE; message->size_eir_data = 0; message->eir_data[0] = 0; MessageSend(state->inquiryLock, CL_DM_READ_EIR_DATA_CFM, message); } }
void ConnectionSmIoCapabilityResponse(const bdaddr* bd_addr, cl_sm_io_capability io_capability, bool force_mitm, bool bonding, bool oob_data_present, uint8* oob_hash_c, uint8* oob_rand_r) { #ifdef CONNECTION_DEBUG_LIB if(bd_addr == NULL) { CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void*)bd_addr)); } #endif { MAKE_CL_MESSAGE(CL_INTERNAL_SM_IO_CAPABILITY_REQUEST_RES); message->bd_addr = *bd_addr; message->io_capability = io_capability; message->bonding = bonding; message->mitm = force_mitm; if(oob_data_present) { message->oob_data_present = 1; message->oob_hash_c = PanicUnlessMalloc(CL_SIZE_OOB_DATA); message->oob_rand_r = PanicUnlessMalloc(CL_SIZE_OOB_DATA); memcpy(message->oob_hash_c, oob_hash_c, CL_SIZE_OOB_DATA); memcpy(message->oob_rand_r, oob_rand_r, CL_SIZE_OOB_DATA); } else { message->oob_data_present = 0; message->oob_hash_c = NULL; message->oob_rand_r = NULL; } MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_IO_CAPABILITY_REQUEST_RES, message); } }
void ConnectionReadClassOfDevice(Task theAppTask) { /* Create internal message and sent to the CL */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_READ_CLASS_OF_DEVICE_REQ); message->theAppTask = theAppTask; MessageSend(connectionGetCmTask(), CL_INTERNAL_DM_READ_CLASS_OF_DEVICE_REQ, message); }
void ConnectionClearParameterCache(const bdaddr *addr) { /* Send an internal message requesting this action */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_CLEAR_PARAM_CACHE_REQ); message->bd_addr = *addr; MessageSend(connectionGetCmTask(), CL_INTERNAL_DM_CLEAR_PARAM_CACHE_REQ, message); }
void ConnectionSdpCloseSearchRequest(Task appTask) { /* Send an internal message */ MAKE_CL_MESSAGE(CL_INTERNAL_SDP_CLOSE_SEARCH_REQ); message->theAppTask = appTask; MessageSend(connectionGetCmTask(), CL_INTERNAL_SDP_CLOSE_SEARCH_REQ, message); }
void ConnectionInquire(Task theAppTask, uint32 inquiry_lap, uint8 max_responses, uint16 timeout, uint32 class_of_device) { /* Check params are within allowed values - debug build only */ #ifdef CONNECTION_DEBUG_LIB if ((inquiry_lap <0x9E8B00) || (inquiry_lap > 0x9E8B3F)) { CL_DEBUG(("Out of range inquiry_lap 0x%lx\n", inquiry_lap)); } if ((timeout < HCI_INQUIRY_LENGTH_MIN) || (timeout > HCI_INQUIRY_LENGTH_MAX)) { CL_DEBUG(("Out of range timeout 0x%x\n", timeout)); } #endif { /* Post an internal message so we can check the state machine */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_INQUIRY_REQ); message->theAppTask = theAppTask; message->inquiry_lap = inquiry_lap; message->max_responses = max_responses; message->timeout = timeout; message->class_of_device = class_of_device; MessageSendConditionally(connectionGetCmTask(), CL_INTERNAL_DM_INQUIRY_REQ, message, (const uint16 *)&theCm.inqState.inquiryLock); } }
/**************************************************************************** NAME connectionHandleReadRemoteSupportedFeaturesRequest DESCRIPTION Request to read the supported features of a remote device. RETURNS void */ void connectionHandleReadRemoteSupportedFeaturesRequest(connectionReadInfoState *state, const CL_INTERNAL_DM_READ_REMOTE_SUPP_FEAT_REQ_T *req) { /* Check the resource lock */ if (!state->stateInfoLock) { bdaddr addr; /* Check we got a valid addr */ if (!SinkGetBdAddr(req->sink, &addr)) { /* Send an error to the app as it didn't pass in a valid sink */ sendRemoteSupportedFeaturesCfm(req->theAppTask, hci_error_no_connection, 0, req->sink); } else { /* Response not outstanding so issue request */ MAKE_PRIM_C(DM_HCI_READ_REMOTE_FEATURES); connectionConvertBdaddr_t(&prim->bd_addr, &addr); VmSendDmPrim(prim); /* Set the lock */ state->stateInfoLock = req->theAppTask; state->sink = req->sink; } } else { /* Lock set so queue up the request */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_READ_REMOTE_SUPP_FEAT_REQ); COPY_CL_MESSAGE(req, message); MessageSendConditionallyOnTask(connectionGetCmTask(), CL_INTERNAL_DM_READ_REMOTE_SUPP_FEAT_REQ, message, &state->stateInfoLock); } }
void connectionHandleRfcommRegisterCfm(connectionRfcommState *rfcommState, const RFC_REGISTER_CFM_T *cfm) { connection_lib_status status = fail; /* Cancel the message checking we got a register cfm from BlueStack */ (void) MessageCancelFirst(connectionGetCmTask(), CL_INTERNAL_RFCOMM_REGISTER_TIMEOUT_IND); if(rfcommState->registerLock) { if(cfm->accept) { map_id id, new_id; id.channel = INVALID_SERVER_CHANNEL; new_id.channel = cfm->server_chan; /* Update the task map with the registered server channel. */ connectionUpdateTaskMap(conn_rfcomm, id, new_id); status = success; } else { /* Delete task map entry the rfcomm register failed */ deleteTaskMap(INVALID_SERVER_CHANNEL); } /* Send register cfm message to Client application */ sendRfcommRegisterCfm(rfcommState->registerLock, status, status==success?cfm->server_chan:0x00); /* Reset lock */ rfcommState->registerLock = 0; } }
void ConnectionSdpServiceSearchRequest(Task appTask, const bdaddr *bd_addr, uint16 max_num_recs, uint16 size_srch_pttrn, const uint8 *search_pattern) { #ifdef CONNECTION_DEBUG_LIB if (size_srch_pttrn == 0) CL_DEBUG(("sdp - search pattern not supplied\n")); if (max_num_recs == 0) CL_DEBUG(("sdp - max number of records set to zero\n")); if(bd_addr == NULL) CL_DEBUG(("Out of range Bluetooth Address 0x%p\n", (void*)bd_addr)); #endif { /* Create an internal message and send it */ MAKE_CL_MESSAGE(CL_INTERNAL_SDP_SERVICE_SEARCH_REQ); message->theAppTask = appTask; message->bd_addr = *bd_addr; message->max_responses = max_num_recs; message->length = size_srch_pttrn; if (size_srch_pttrn) { message->search_pattern = (uint8 *)PanicUnlessMalloc(size_srch_pttrn); memcpy(message->search_pattern, search_pattern, size_srch_pttrn); } else message->search_pattern = 0; MessageSend(connectionGetCmTask(), CL_INTERNAL_SDP_SERVICE_SEARCH_REQ, message); } }
void ConnectionRfcommDisconnectResponse(Sink sink) { /* Send an internal message */ MAKE_CL_MESSAGE(CL_INTERNAL_RFCOMM_DISCONNECT_RSP); message->sink = sink; MessageSend(connectionGetCmTask(), CL_INTERNAL_RFCOMM_DISCONNECT_RSP, message); }
/**************************************************************************** NAME sendSearchRequest DESCRIPTION Decide whather a search request primitive can be sent to BlueStack or not RETURNS sdp_search_req - see typedef above */ static sdp_search_req sendSearchRequest(Task theAppTask, const connectionSdpState *state, const bdaddr *bd_addr) { /* Check the first lock */ if (state->sdpLock) { /* SDP search session open or non search primitive sent to BlueStack */ if (BdaddrIsZero(&state->sdpServerAddr)) { /* SDP search session not open but another prim is currently being handled (sdpLock set) so we can't start the search yet */ return sdp_lock_set; } else { /* Addr set - SDP search session open */ if (state->sdpSearchLock) { /* Search currently active so can't start another one */ return sdp_search_lock_set; } else { /* SDP session open but no active search */ if (BdaddrIsSame(&state->sdpServerAddr, bd_addr)) { /* SDP search session open to the device we want to search so we can just start our search */ return sdp_start_search; } else { /* SDP search session open to a different device so we can't do our search until this session is closed. */ return sdp_session_open_other_dev; } } } } else { /* Check if we currently have a search active, block internal requests if sdpLock not set */ if (state->sdpSearchLock || theAppTask == connectionGetCmTask()) { /* Search currently active */ return sdp_search_lock_set; } else { /* No search currently active */ return sdp_start_search; } } }
void ConnectionSmSetTrustLevel(const bdaddr* bd_addr, uint16 trusted) { /* Update the Trusted Device List */ MAKE_CL_MESSAGE(CL_INTERNAL_SM_SET_TRUST_LEVEL_REQ) message->bd_addr = *bd_addr; message->trusted = trusted; MessageSend(connectionGetCmTask(), CL_INTERNAL_SM_SET_TRUST_LEVEL_REQ, message); }
void ConnectionReadBtVersion(Task theAppTask) { /* All requests are sent through the internal state handler */ MAKE_CL_MESSAGE(CL_INTERNAL_DM_SET_BT_VERSION_REQ); message->theAppTask = theAppTask; message->version = BT_VERSION_CURRENT; MessageSendConditionallyOnTask(connectionGetCmTask(), CL_INTERNAL_DM_SET_BT_VERSION_REQ, message, &theCm.infoState.stateInfoLock); }