Exemple #1
0
        private static async Task <RfcommServiceProvider> CreateProviderAsync(RfcommServiceId serviceId)
        {
            RfcommServiceProvider provider = new RfcommServiceProvider();

            provider.serviceId = serviceId;
            return(provider);
        }
Exemple #2
0
        /// <summary>
        /// Gets a RfcommServiceProvider object from an RFCOMM service id.
        /// </summary>
        /// <param name="serviceId"></param>
        /// <returns></returns>
        public static Task <RfcommServiceProvider> CreateAsync(RfcommServiceId serviceId)
        {
            if (serviceId == null)
            {
                throw new ArgumentNullException("serviceId");
            }

            return(DoCreateAsync(serviceId));
        }
Exemple #3
0
        public override bool Equals(object obj)
        {
            RfcommServiceId other = obj as RfcommServiceId;

            if (other != null)
            {
                return(this.Uuid == other.Uuid);
            }

            return(base.Equals(obj));
        }
Exemple #4
0
        private static async Task <RfcommDeviceService> FromIdAsyncImpl(string deviceId)
        {
            if (deviceId.StartsWith("BLUETOOTH#"))
            {
                var parts  = deviceId.Split('#');
                var addr   = parts[1];
                var uuid   = parts[2];
                var device = await BluetoothDevice.FromBluetoothAddressAsync(ulong.Parse(addr, NumberStyles.HexNumber));

                var service = RfcommServiceId.FromUuid(new Guid(uuid));

                return(new RfcommDeviceService(device, service));
            }

            return(null);
        }
Exemple #5
0
 private static async Task <RfcommServiceProvider> DoCreateAsync(RfcommServiceId serviceId)
 {
     return(new RfcommServiceProvider(serviceId.Uuid));
 }
Exemple #6
0
        /// <summary>
        /// Creates a RfcommServiceId object from a 128-bit service id.
        /// </summary>
        /// <param name="uuid">The 128-bit service id.</param>
        /// <returns>The <see cref="RfcommServiceId"/> object.</returns>
        public static RfcommServiceId FromUuid(Guid uuid)
        {
            RfcommServiceId serviceId = new RfcommServiceId(uuid);

            return(serviceId);
        }
 private static string GetDeviceSelectorImpl(RfcommServiceId serviceId)
 {
     return(string.Empty);
 }
Exemple #8
0
 /// <summary>
 /// Gets an Advanced Query Syntax (AQS) string for identifying instances of an RFCOMM service.
 /// </summary>
 /// <param name="serviceId">The service id for which to query.</param>
 /// <returns>An AQS string for identifying RFCOMM service instances.</returns>
 public static string GetDeviceSelector(RfcommServiceId serviceId)
 {
     return(GetDeviceSelectorImpl(serviceId));
 }
Exemple #9
0
 internal RfcommDeviceService(BluetoothDevice device, RfcommServiceId service)
 {
     _device  = device;
     _service = service;
 }
Exemple #10
0
 private static string GetDeviceSelectorImpl(RfcommServiceId serviceId)
 {
     return("bluetoothService:" + serviceId.Uuid.ToString());
 }
        private static async Task <RfcommServiceProvider> DoCreateAsync(RfcommServiceId serviceId)
        {
            var provider = await Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider.CreateAsync(serviceId);

            return(new RfcommServiceProvider(provider));
        }
Exemple #12
0
 /// <summary>
 /// Gets a RfcommServiceProvider object from a DeviceInformation Id for a RFCOMM service instance.
 /// </summary>
 /// <param name="serviceId">The RfcommServiceId to be hosted locally.</param>
 /// <returns>The RfcommServiceProvider object that represents the local RFCOMM service instance.</returns>
 public static IAsyncOperation <RfcommServiceProvider> CreateAsync(RfcommServiceId serviceId)
 {
     return(CreateProviderAsync(serviceId).AsAsyncOperation <RfcommServiceProvider>());
 }
 private static async Task <RfcommServiceProvider> DoCreateAsync(RfcommServiceId serviceId)
 {
     return(null);
 }
Exemple #14
0
 private static string GetDeviceSelectorImpl(RfcommServiceId serviceId)
 {
     return(Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService.GetDeviceSelector(serviceId));
 }
Exemple #15
0
 internal RfcommDeviceService(DeviceInformation deviceInformation)
 {
     _device  = new BluetoothDevice(deviceInformation._deviceInfo);
     _service = RfcommServiceId.FromUuid(deviceInformation._service);
 }
Exemple #16
0
        private static async Task <RfcommServiceProvider> DoCreateAsync(RfcommServiceId serviceId)
        {
            var serverSocket = BluetoothAdapter.Default.Adapter.ListenUsingRfcommWithServiceRecord(serviceId.ToString(), Java.Util.UUID.NameUUIDFromBytes(serviceId.Uuid.ToByteArray()));

            return(new RfcommServiceProvider(serverSocket));
        }