void SDP_ProcessPacket(BT_StackConfig_t* const StackState, BT_L2CAP_Channel_t* const Channel, const uint16_t Length, uint8_t* Data) { /* Ensure correct channel PSM before processing the data */ if (Channel->PSM != CHANNEL_PSM_SDP) return; BT_SDP_PDUHeader_t* SDPHeader = (BT_SDP_PDUHeader_t*)Data; /* Dispatch to the correct processing routine for the given SDP packet type */ switch (SDPHeader->PDU) { case SDP_PDU_SERVICESEARCHREQUEST: SDP_ServiceSearch(StackState, Channel, SDPHeader); break; case SDP_PDU_SERVICEATTRIBUTEREQUEST: SDP_ServiceAttribute(StackState, Channel, SDPHeader); break; case SDP_PDU_SERVICESEARCHATTRIBUTEREQUEST: SDP_ServiceSearchAttribute(StackState, Channel, SDPHeader); break; } }
/* This function will issue a service search to obtain the protocol descriptor of a serial port profile compliant service. It will then call the helper function sample results to examine the results. */ void sample_test(void) { u_int32 serial_uuid; t_SDP_Addresses devices; u_int16 criteria; t_SDP_SearchPattern pattern; t_SDP_AttributeIDs attribs; t_bdaddr address; t_SDP_StopRule rule; t_SDP_Results *pResults; address=bd_addr_inq; serial_uuid = 0x1101; /* bd address list to search for */ devices.numItems = 1; devices.addresses = malloc(sizeof(t_bdaddr)); devices.addresses[0] = address; /* device relation criteria */ criteria = SDP_TRUSTED; /* search pattern */ pattern.numItems = 1; pattern.patternUUIDs = malloc(4); pattern.patternUUIDs[0] = serial_uuid; /* attributes to retrieve */ attribs.numItems = 1; attribs.attributeIDs = malloc(4); attribs.attributeIDs[0] = 0x0004; /* protocol decriptor list */ /* stop rule */ rule.maxItems = 10; rule.maxDuration = 30; rule.maxBytes = 250; /* call a service search and do not retrieve the device name */ test_state = 1; SDP_ServiceSearch(&pResults,&devices,&pattern,&attribs,&rule,criteria,test_finish_callback); while(test_state); test_state = 0; /* examine the results */ /* sample_results(pResults->element.attribs.pData); */ SDP_FreeResults(pResults); }