BluetoothDevice Kelas

Definisi

Mewakili perangkat Bluetooth.

Aplikasi sampel yang menggunakan kelas ini termasuk enumerasi perangkat dan sampel pemasangan dan sampel obrolan Bluetooth RFCOMM.

public ref class BluetoothDevice sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class BluetoothDevice final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class BluetoothDevice : System.IDisposable
Public NotInheritable Class BluetoothDevice
Implements IDisposable
Warisan
Object Platform::Object IInspectable BluetoothDevice
Atribut
Penerapan

Persyaratan Windows

Rangkaian perangkat
Windows 10 (diperkenalkan dalam 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v1.0)
Kemampuan aplikasi
bluetooth

Keterangan

Riwayat versi

Versi Windows Versi SDK Nilai ditambahkan
1511 10586 DeviceInformation
1511 10586 GetDeviceSelectorFromBluetoothAddress
1511 10586 GetDeviceSelectorFromClassOfDevice
1511 10586 GetDeviceSelectorFromConnectionStatus
1511 10586 GetDeviceSelectorFromDeviceName
1511 10586 GetDeviceSelectorFromPairingState
1607 14393 DeviceAccessInformation
1607 14393 GetRfcommServicesAsync
1607 14393 GetRfcommServicesAsync(BluetoothCacheMode)
1607 14393 GetRfcommServicesForIdAsync(RfcommServiceId)
1607 14393 GetRfcommServicesForIdAsync(RfcommServiceId,BluetoothCacheMode)
1607 14393 RequestAccessAsync
1709 16299 BluetoothDeviceId
1803 17134 WasSecureConnectionUsedForPairing

Properti

BluetoothAddress

Mendapatkan alamat perangkat.

BluetoothDeviceId

Mendapatkan ID perangkat bluetooth.

ClassOfDevice

Mendapatkan informasi Kelas Perangkat Bluetooth perangkat.

ConnectionStatus

Mendapatkan status koneksi perangkat.

DeviceAccessInformation

Objek DeviceAccessInformation saat ini untuk perangkat. Digunakan untuk memeriksa dan memantau perubahan akses ke perangkat.

DeviceId

Mendapatkan ID perangkat yang berasal dari Windows.Devices.Enumeration.DeviceInformation.Id

DeviceInformation

Mendapatkan objek DeviceInformation untuk perangkat Bluetooth.

HostName

Mendapatkan HostName perangkat.

Name

Mendapatkan Nama perangkat.

RfcommServices

Mendapatkan daftar layanan RFCOMM baca-saja yang didukung oleh perangkat.

Penting

API RfcommServices tidak digunakan lagi, dan mungkin tidak tersedia di versi Windows yang akan datang. Sebagai gantinya, gunakan GetRfcommServicesAsync.

SdpRecords

Mendapatkan daftar rekaman Service Discovery Protocol (SDP) baca-saja untuk perangkat.

WasSecureConnectionUsedForPairing

Mendapatkan boolean yang menunjukkan apakah BluetoothDevice dipasangkan menggunakan Koneksi Aman.

Metode

Close()

Menutup perangkat Bluetooth.

Dispose()

Melakukan tugas yang ditentukan aplikasi yang terkait dengan membebaskan, melepaskan, atau mereset sumber daya yang tidak terkelola.

FromBluetoothAddressAsync(UInt64)

Mengembalikan objek BluetoothDevice untuk BluetoothAddress yang diberikan.

FromHostNameAsync(HostName)

Mengembalikan objek BluetoothDevice yang diidentifikasi oleh HostName yang diberikan.

FromIdAsync(String)

Mengembalikan objek BluetoothDevice yang diidentifikasi oleh DeviceId yang diberikan.

GetDeviceSelector()

Mendapatkan string Advanced Query Syntax (AQS) untuk mengidentifikasi instans perangkat ini. String ini diteruskan ke metode FindAllAsync atau CreateWatcher.

GetDeviceSelectorFromBluetoothAddress(UInt64)

Membuat string filter Advanced Query Syntax (AQS) dari alamat 64-bit yang mewakili perangkat Bluetooth. String AQS diteruskan ke metode CreateWatcher untuk mengembalikan kumpulan objek DeviceInformation .

GetDeviceSelectorFromClassOfDevice(BluetoothClassOfDevice)

Membuat string filter Advanced Query Syntax (AQS) dari objek BluetoothClassOfDevice . String AQS diteruskan ke metode CreateWatcher untuk mengembalikan kumpulan objek DeviceInformation .

GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus)

Membuat string filter Advanced Query Syntax (AQS) yang berisi kueri untuk perangkat Bluetooth dengan BluetoothConnectionStatus yang ditunjukkan. String AQS diteruskan ke metode CreateWatcher untuk mengembalikan kumpulan objek DeviceInformation dengan status koneksi Bluetooth yang ditunjukkan.

GetDeviceSelectorFromDeviceName(String)

Membuat string filter Advanced Query Syntax (AQS) yang berisi kueri untuk nama perangkat Bluetooth. String AQS diteruskan ke metode CreateWatcher untuk mengembalikan kumpulan objek DeviceInformation yang berisi nama perangkat Bluetooth yang ditentukan.

GetDeviceSelectorFromPairingState(Boolean)

Membuat string filter Advanced Query Syntax (AQS) yang berisi kueri untuk perangkat Bluetooth yang dipasangkan atau tidak dipasangkan. String AQS diteruskan ke metode CreateWatcher untuk mengembalikan kumpulan objek DeviceInformation .

GetRfcommServicesAsync()

Mengambil semua Layanan Rfcomm pada Perangkat Bluetooth jarak jauh.

GetRfcommServicesAsync(BluetoothCacheMode)

Mengambil semua Layanan Rfcomm yang di-cache pada Perangkat Bluetooth jarak jauh.

GetRfcommServicesForIdAsync(RfcommServiceId)

Mengambil semua Layanan Rfcomm pada Perangkat Bluetooth Jarak Jauh yang cocok dengan RfcommServiceId yang ditentukan.

GetRfcommServicesForIdAsync(RfcommServiceId, BluetoothCacheMode)

Mengambil semua Layanan Rfcomm yang di-cache pada Perangkat Bluetooth Jarak Jauh yang cocok dengan RfcommServiceId yang ditentukan.

RequestAccessAsync()

Digunakan untuk meminta akses eksplisit ke perangkat Bluetooth. Ini memanggil Persetujuan Perangkat dan harus dipanggil pada utas UI.

Acara

ConnectionStatusChanged

Terjadi ketika status koneksi perangkat telah berubah.

NameChanged

Terjadi ketika nama perangkat telah berubah.

SdpRecordsChanged

Terjadi ketika daftar catatan SDP untuk perangkat telah berubah.

Berlaku untuk

Lihat juga