BluetoothDevice Classe
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Représente un appareil Bluetooth.
Les exemples d’applications qui utilisent cette classe incluent l’énumération et l’exemple de jumelage d’appareils etl’exemple de conversation RFCOMM Bluetooth.
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
- Héritage
- Attributs
- Implémente
Configuration requise pour Windows
| Configuration requise | Description |
|---|---|
| Famille d’appareils |
Windows 10 (introduit dans 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduit dans v1.0)
|
| Fonctionnalités de l’application |
bluetooth
|
Remarques
Historique des versions
| Version de Windows | Version du SDK | Valeur ajoutée |
|---|---|---|
| 1511 | 10586 | Informations sur l'appareil |
| 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 |
Propriétés
| Nom | Description |
|---|---|
| BluetoothAddress |
Obtient l’adresse de l’appareil. |
| BluetoothDeviceId |
Obtient l’ID d’appareil Bluetooth. |
| ClassOfDevice |
Obtient la classe Bluetooth des informations d’appareil de l’appareil. |
| ConnectionStatus |
Obtient l’état de connexion de l’appareil. |
| DeviceAccessInformation |
Objet DeviceAccessInformation actuel pour l’appareil. Permet de vérifier et de surveiller les modifications d’accès apportées à l’appareil. |
| DeviceId |
Obtient l’ID d’appareil provenant de la Windows.Devices.Enumeration.DeviceInformation.Id |
| DeviceInformation |
Obtient l’objet DeviceInformation pour l’appareil Bluetooth. |
| HostName |
Obtient le nom d’hôte de l’appareil. |
| Name |
Obtient le nom de l’appareil. |
| RfcommServices |
Obtient la liste en lecture seule des services RFCOMM pris en charge par l’appareil. Important L’API RfcommServices est déconseillée et elle n’est peut-être pas disponible dans les versions ultérieures de Windows. Utilisez plutôt GetRfcommServicesAsync. |
| SdpRecords |
Obtient la liste en lecture seule des enregistrements SDP (Service Discovery Protocol) pour l’appareil. |
| WasSecureConnectionUsedForPairing |
Obtient une valeur booléenne indiquant si le BluetoothDevice a été associé à l’aide d’une connexion sécurisée. |
Méthodes
| Nom | Description |
|---|---|
| Close() |
Ferme l’appareil Bluetooth. |
| Dispose() |
Effectue des tâches définies par l’application associées à la libération, à la libération ou à la réinitialisation des ressources non managées. |
| FromBluetoothAddressAsync(UInt64) |
Renvoie un objet BluetoothDevice pour l’adresse BluetoothAddress donnée. |
| FromHostNameAsync(HostName) |
Retourne un objet BluetoothDevice identifié par le nom d’hôte donné. |
| FromIdAsync(String) |
Retourne un objet BluetoothDevice identifié par deviceId donné. |
| GetDeviceSelector() |
Obtient une chaîne AQS (Advanced Query Syntax) pour identifier les instances de cet appareil. Cette chaîne est transmise à la méthode FindAllAsync ou CreateWatcher. |
| GetDeviceSelectorFromBluetoothAddress(UInt64) |
Crée une chaîne de filtre AQS (Advanced Query Syntax) à partir d’une adresse 64 bits qui représente un appareil Bluetooth. La chaîne AQS est passée à la méthode CreateWatcher pour renvoyer une collection d’objets DeviceInformation . |
| GetDeviceSelectorFromClassOfDevice(BluetoothClassOfDevice) |
Crée une chaîne de filtre AQS (Advanced Query Syntax) à partir d’un objet BluetoothClassOfDevice . La chaîne AQS est passée à la méthode CreateWatcher pour renvoyer une collection d’objets DeviceInformation . |
| GetDeviceSelectorFromConnectionStatus(BluetoothConnectionStatus) |
Crée une chaîne de filtre AQS (Advanced Query Syntax) qui contient une requête pour les appareils Bluetooth avec le BluetoothConnectionStatus indiqué. La chaîne AQS est passée à la méthode CreateWatcher pour renvoyer une collection d’objets DeviceInformation avec l’état de connexion Bluetooth indiqué. |
| GetDeviceSelectorFromDeviceName(String) |
Crée une chaîne de filtre AQS (Advanced Query Syntax) qui contient une requête pour le nom de l’appareil Bluetooth. La chaîne AQS est passée à la méthode CreateWatcher pour renvoyer une collection d’objets DeviceInformation contenant le nom d’appareil Bluetooth spécifié. |
| GetDeviceSelectorFromPairingState(Boolean) |
Crée une chaîne de filtre AQS (Advanced Query Syntax) qui contient une requête pour les appareils Bluetooth associés ou non appairés. La chaîne AQS est passée à la méthode CreateWatcher pour renvoyer une collection d’objets DeviceInformation . |
| GetRfcommServicesAsync() |
Récupère tous les services Rfcomm sur l’appareil Bluetooth distant. |
| GetRfcommServicesAsync(BluetoothCacheMode) |
Récupère tous les services Rfcomm mis en cache sur l’appareil Bluetooth distant. |
| GetRfcommServicesForIdAsync(RfcommServiceId, BluetoothCacheMode) |
Récupère tous les services Rfcomm mis en cache sur l’appareil Bluetooth distant correspondant au RfcommServiceId spécifié. |
| GetRfcommServicesForIdAsync(RfcommServiceId) |
Récupère tous les services Rfcomm sur l’appareil Bluetooth distant correspondant au RfcommServiceId spécifié. |
| RequestAccessAsync() |
Utilisé pour demander un accès explicite à l’appareil Bluetooth. Cela appelle le consentement de l’appareil et doit être appelé sur le thread d’interface utilisateur. |
Événements
| Nom | Description |
|---|---|
| ConnectionStatusChanged |
Se produit lorsque l’état de connexion de l’appareil a changé. |
| NameChanged |
Se produit lorsque le nom de l’appareil a changé. |
| SdpRecordsChanged |
Se produit lorsque la liste des enregistrements SDP pour l’appareil a changé. |