Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sdp_record_t *sdpRecord;
- sdp_session_t *sdpSession;
- uint8_t rfcommChannel = 30;
- uint8_t svc_uuid_int[] = { 0xB9, 0xDE, 0xC6, 0xD2, 0x29, 0x30, 0x43, 0x38, 0xA0, 0x79, 0xAA, 0xE5, 0x60, 0x05, 0x32, 0x38 };
- const char* service_name = "SmartCam";
- const char* service_dsc = "Smartphone Webcam";
- const char* service_prov = "Deion";
- uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid;
- sdp_list_t *l2cap_list = 0,
- *rfcomm_list = 0,
- *root_list = 0,
- *proto_list = 0,
- *access_proto_list = 0;
- sdp_data_t* channel = 0, *psm = 0;
- sdpRecord = sdp_record_alloc();
- // set the general service ID
- sdp_uuid128_create(&svc_uuid, &svc_uuid_int);
- sdp_set_service_id(sdpRecord, svc_uuid);
- // make the service record publicly browsable
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root_list = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(sdpRecord, root_list);
- // set l2cap information
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- l2cap_list = sdp_list_append(0, &l2cap_uuid);
- proto_list = sdp_list_append(0, l2cap_list);
- // set rfcomm information
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- channel = sdp_data_alloc(SDP_UINT8, &rfcommChannel);
- rfcomm_list = sdp_list_append(0, &rfcomm_uuid);
- sdp_list_append(rfcomm_list, channel);
- sdp_list_append(proto_list, rfcomm_list);
- // attach protocol information to service record
- access_proto_list = sdp_list_append(0, proto_list);
- sdp_set_access_protos(sdpRecord, access_proto_list);
- // set the name, provider, and description
- sdp_set_info_attr(sdpRecord, service_name, service_prov, service_dsc);
- int err = 0;
- // connect to the local SDP server, register the service record
- sdpSession = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY);
- err = sdp_record_register(sdpSession, sdpRecord, 0);
- if(err)
- {
- perror("sdp_record_register");
- }
- // cleanup
- sdp_data_free(channel);
- sdp_list_free(l2cap_list, 0);
- sdp_list_free(rfcomm_list, 0);
- sdp_list_free(root_list, 0);
- sdp_list_free(access_proto_list, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement