// 32feet.NET - Personal Area Networking for .NET
//
// InTheHand.Net.Sockets.BluetoothDeviceInfo
//
// Copyright (c) 2003-2022 In The Hand Ltd, All rights reserved.
// This source code is licensed under the MIT License
using InTheHand.Net.Bluetooth;
using System;
using System.Collections.Generic;
namespace InTheHand.Net.Sockets
{
///
/// Provides information about an available device obtained by the client during device discovery.
///
public sealed partial class BluetoothDeviceInfo : IEquatable
{
///
/// Forces the system to refresh the device information.
///
public void Refresh()
{
DoRefresh();
}
///
/// Gets the device identifier.
///
public BluetoothAddress DeviceAddress
{
get
{
return GetDeviceAddress();
}
}
///
/// Gets the name of a device.
///
public string DeviceName
{
get
{
return GetDeviceName();
}
}
///
/// Returns the Class of Device of the remote device.
///
public ClassOfDevice ClassOfDevice
{
get
{
return GetClassOfDevice();
}
}
///
/// Returns a list of services which are already installed for use on the calling machine.
///
public IReadOnlyCollection InstalledServices
{
get
{
return GetInstalledServices();
}
}
///
/// Specifies whether the device is connected.
///
public bool Connected
{
get
{
return GetConnected();
}
}
///
/// Specifies whether the device is authenticated, paired, or bonded.
/// All authenticated devices are remembered.
///
public bool Authenticated
{
get
{
return GetAuthenticated();
}
}
///
/// Enables or disables services for a Bluetooth device.
///
/// Only applies to Windows platform.
///
///
public void SetServiceState(Guid service, bool state)
{
DoSetServiceState(service, state);
}
///
/// Compares two BluetoothDeviceInfo instances for equality.
///
///
///
public bool Equals(BluetoothDeviceInfo other)
{
if (other is null)
return false;
return DeviceAddress == other.DeviceAddress;
}
///
///
///
///
///
public override bool Equals(object obj)
{
if(obj is BluetoothDeviceInfo info)
{
return Equals(info);
}
return false;
}
///
///
///
///
public override int GetHashCode()
{
return DeviceAddress.GetHashCode();
}
}
}