Urgent! The returned value has changed. It's urgent.
Source: Internet
Author: User
Urgent! The returned value has changed. For more information, see Linux general technology-Linux technology and application. I am a newbie. I just compiled a program today, but the returned value has changed. Ask the experts for help!
The following code is attached:
# Include
# Include
# Include
Int sdp_ch (char * bdaddr)
{
Uuid_t svc_uuid;
Int err;
Bdaddr_t target;
Sdp_list_t * response_list = NULL, * search_list, * attrid_list;
Sdp_session_t * session = 0;
Uint32_t class = 0;
Int num;
Int turn_d;
/* Hard code your remote bdaddr here */
Char serv_class_ID [] = "0x1106";/* obex push service identifier */
// Char bdaddr [] = "00: 15: 83: B9: 78: A6";/* remote bdaddress (Pls change for yours )*/
Str2ba (bdaddr, & target); // compute (1)
If (! Strncasecmp (serv_class_ID, "0x", 2 )){
Int num;
/* This is a UUID16, just convert to int */
Sscanf (serv_class_ID + 2, "% X", & num );
Class = num;
// Printf ("Service Class 0x % X \ n", class );
}
If (class ){
If (class & 0xffff0000 ){
Sdp_uuid32_create (& svc_uuid, class );
// Printf ("Creating a 32 bit uuid \ n ");
}
Else {
Uint16_t class16 = class & 0 xffff;
Sdp_uuid16_create (& svc_uuid, class16 );
// Printf ("Creating a 16 bit uuid \ n ");
}
}
Else
// Printf ("You have no class: 0) \ n ");
// Connect to the SDP server running on the remote machine
Session = sdp_connect (BDADDR_ANY, & target, SDP_RETRY_IF_BUSY); // --------------------- (2)
// Specify the UUID of the application we're re searching
// Specify that we want a list of all the matching applications 'bubutes
Uint32_t range = 0x0000ffff;
Attrid_list = sdp_list_append (NULL, & range); // -------------------------------------- (4)
// Get a list of service records that have UUID 0x1106
Err = sdp_service_search_attr_req (session, search_list ,\
SDP_ATTR_REQ_RANGE, attrid_list, & response_list); // ------------------------------- (5)
Sdp_list_t * r = response_list; // -------------- response_list has the record have UUID 0x1106
// Go through each of the service records
For (; r = r-> next ){
Sdp_record_t * rec = (sdp_record_t *) r-> data;
Sdp_record_print (rec );
// Printf ("Service RecHandle: 0x % x \ n", rec-> handle );
Sdp_list_t * proto_list;
// Get a list of the protocol sequences
If (sdp_get_access_protos (rec, & proto_list) = 0 ){
Sdp_list_t * p = proto_list;
// Go through each protocol sequence
For (; p = p-> next ){
Sdp_list_t * PPS = (sdp_list_t *) p-> data;
// Go through each protocol list of the protocol sequence
For (; pds = pds-> next ){
// Check the protocol attributes
Sdp_data_t * d = (sdp_data_t *) pds-> data;
Int proto = 0;
For (; d = d-> next ){
Switch (d-> dtd ){
Case SDP_UUID16:
Case SDP_UUID32:
Case SDP_UUID128:
Proto = sdp_uuid_to_proto (& d-> val. uuid );
Turn_d = d-> val. int8;
Break;
Case SDP_UINT8:
If (proto = RFCOMM_UUID ){
// Printf ("rfcomm channel: % d \ n", d-> val. int8 );
}
Turn_d = d-> val. int8;
Printf ("% d --- 1", turn_d); // ---------------------- the output is 3
Break;
}
}
}
Sdp_list_free (sdp_list_t *) p-> data, 0 );
}
Sdp_list_free (proto_list, 0 );
}
// Printf ("found service record 0x % x \ n", rec-> handle );
Sdp_record_free (rec );
}
Sdp_close (session );
Printf ("% d ---- 2 \ n", turn_d); // -------------------- the output is 25
Return turn_d;
}
Int main ()
{
Int I;
Char bdaddr [] = "00: 15: 83: B9: 78: A6 ";
I = sdp_channel (bdaddr );
Printf ("-- % d -- \ n", I); // ------------------------- the output is 25
}
Running result:
3------1
25-----2
-- 25 --
Please give me some advice on what went wrong. Hurry up !!!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service