Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. sdp_record_t *sdpRecord;
  2. sdp_session_t *sdpSession;
  3. uint8_t rfcommChannel = 30;
  4. uint8_t svc_uuid_int[] = { 0xB9, 0xDE, 0xC6, 0xD2, 0x29, 0x30, 0x43, 0x38, 0xA0, 0x79, 0xAA, 0xE5, 0x60, 0x05, 0x32, 0x38 };
  5. const char* service_name = "SmartCam";
  6. const char* service_dsc = "Smartphone Webcam";
  7. const char* service_prov = "Deion";
  8.  
  9. uuid_t root_uuid, l2cap_uuid, rfcomm_uuid, svc_uuid;
  10. sdp_list_t *l2cap_list = 0,
  11. *rfcomm_list = 0,
  12. *root_list = 0,
  13. *proto_list = 0,
  14. *access_proto_list = 0;
  15. sdp_data_t* channel = 0, *psm = 0;
  16.  
  17. sdpRecord = sdp_record_alloc();
  18.  
  19. // set the general service ID
  20. sdp_uuid128_create(&svc_uuid, &svc_uuid_int);
  21. sdp_set_service_id(sdpRecord, svc_uuid);
  22.  
  23. // make the service record publicly browsable
  24. sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
  25. root_list = sdp_list_append(0, &root_uuid);
  26. sdp_set_browse_groups(sdpRecord, root_list);
  27.  
  28. // set l2cap information
  29. sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
  30. l2cap_list = sdp_list_append(0, &l2cap_uuid);
  31. proto_list = sdp_list_append(0, l2cap_list);
  32.  
  33. // set rfcomm information
  34. sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
  35. channel = sdp_data_alloc(SDP_UINT8, &rfcommChannel);
  36. rfcomm_list = sdp_list_append(0, &rfcomm_uuid);
  37. sdp_list_append(rfcomm_list, channel);
  38. sdp_list_append(proto_list, rfcomm_list);
  39.  
  40. // attach protocol information to service record
  41. access_proto_list = sdp_list_append(0, proto_list);
  42. sdp_set_access_protos(sdpRecord, access_proto_list);
  43.  
  44. // set the name, provider, and description
  45. sdp_set_info_attr(sdpRecord, service_name, service_prov, service_dsc);
  46.  
  47. int err = 0;
  48.  
  49. // connect to the local SDP server, register the service record
  50. sdpSession = sdp_connect(BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY);
  51. err = sdp_record_register(sdpSession, sdpRecord, 0);
  52. if(err)
  53. {
  54. perror("sdp_record_register");
  55.  
  56. }
  57.  
  58. // cleanup
  59. sdp_data_free(channel);
  60. sdp_list_free(l2cap_list, 0);
  61. sdp_list_free(rfcomm_list, 0);
  62. sdp_list_free(root_list, 0);
  63. sdp_list_free(access_proto_list, 0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement