internal static NativeMethods.SdpSessionSafeHandle AddRecord(IntPtr rec) { //Console.Write("Hit return to AddRecord> "); //Console.ReadLine(); // BluezError ret; var session = NativeMethods.sdp_connect( StackConsts.BDADDR_ANY, StackConsts.BDADDR_LOCAL, StackConsts.SdpConnectFlags.SDP_RETRY_IF_BUSY); // ret = NativeMethods.sdp_record_register(session, rec, 0); BluezUtils.CheckAndThrow(ret, "sdp_record_register"); return(session); }
List <ServiceRecord> DoSdpQuery(NativeMethods.SdpSessionSafeHandle session, Structs.uuid_t svcUuid, bool rfcommOnly) { var listAllocs = new List <IntPtr>(); IntPtr searchList = BluezUtils.sdp_list_append(IntPtr.Zero, svcUuid, listAllocs); // Attribute pattern IntPtr attridList; StackConsts.sdp_attrreq_type_t reqType; Console.WriteLine("rfcommOnly: " + rfcommOnly); if (rfcommOnly) { const UInt16 ClassListId = (ushort)UniversalAttributeId.ServiceClassIdList; //=1 const UInt16 ProtoDListId = (ushort)UniversalAttributeId.ProtocolDescriptorList; //=4 reqType = StackConsts.sdp_attrreq_type_t.SDP_ATTR_REQ_INDIVIDUAL; attridList = BluezUtils.sdp_list_append(IntPtr.Zero, ClassListId, listAllocs); attridList = BluezUtils.sdp_list_append(attridList, ProtoDListId, listAllocs); } else { const UInt32 allAttributes = 0x0000ffff; reqType = StackConsts.sdp_attrreq_type_t.SDP_ATTR_REQ_RANGE; attridList = BluezUtils.sdp_list_append(IntPtr.Zero, allAttributes, listAllocs); } // Query Console.WriteLine("sdp_service_search_attr_req in:" + " {0}, attrid_list: {1}", searchList, attridList); IntPtr pResponseList; BluezError ret = NativeMethods.sdp_service_search_attr_req(session, searchList, reqType, attridList, out pResponseList); Console.WriteLine("sdp_service_search_attr_req ret: {0}, result: {1}", ret, pResponseList); BluezUtils.CheckAndThrow(ret, "sdp_service_search_attr_req"); // var rList = BuildRecordList(pResponseList); return(rList); }
private void OpenStack() { lock (_lock) { if (_hDevDescr == null) { BluezError ret; int hDevId = NativeMethods.hci_get_route(IntPtr.Zero); // TODO (BlueZ: open specific interface) ret = (BluezError)hDevId; BluezUtils.CheckAndThrow(ret, "hci_get_route"); int hDevDescr = NativeMethods.hci_open_dev(hDevId); ret = (BluezError)hDevDescr; BluezUtils.CheckAndThrow(ret, "hci_open_dev"); if (hDevId < 0 || hDevDescr < 0) { Debug.Fail("should have been detected above"); BluezUtils.Throw(ret, "opening socket"); } _hDevId = hDevId; _hDevDescr = hDevDescr; Console.WriteLine("Id: {0}, DD: {1}", DevId, DevDescr); } } }