Exemplo n.º 1
0
        private static async Task <RfcommServiceProvider> CreateProviderAsync(RfcommServiceId serviceId)
        {
            RfcommServiceProvider provider = new RfcommServiceProvider();

            provider.serviceId = serviceId;
            return(provider);
        }
Exemplo n.º 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));
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 5
0
 private static async Task <RfcommServiceProvider> DoCreateAsync(RfcommServiceId serviceId)
 {
     return(new RfcommServiceProvider(serviceId.Uuid));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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));
 }
Exemplo n.º 9
0
 internal RfcommDeviceService(BluetoothDevice device, RfcommServiceId service)
 {
     _device  = device;
     _service = service;
 }
Exemplo n.º 10
0
 private static string GetDeviceSelectorImpl(RfcommServiceId serviceId)
 {
     return("bluetoothService:" + serviceId.Uuid.ToString());
 }
Exemplo n.º 11
0
        private static async Task <RfcommServiceProvider> DoCreateAsync(RfcommServiceId serviceId)
        {
            var provider = await Windows.Devices.Bluetooth.Rfcomm.RfcommServiceProvider.CreateAsync(serviceId);

            return(new RfcommServiceProvider(provider));
        }
Exemplo n.º 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);
 }
Exemplo n.º 14
0
 private static string GetDeviceSelectorImpl(RfcommServiceId serviceId)
 {
     return(Windows.Devices.Bluetooth.Rfcomm.RfcommDeviceService.GetDeviceSelector(serviceId));
 }
Exemplo n.º 15
0
 internal RfcommDeviceService(DeviceInformation deviceInformation)
 {
     _device  = new BluetoothDevice(deviceInformation._deviceInfo);
     _service = RfcommServiceId.FromUuid(deviceInformation._service);
 }
Exemplo n.º 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));
        }