You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+16-10Lines changed: 16 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,11 @@
1
1
# BluetoothDevicePairing
2
-
Console utility to discover and pair or connect to Bluetooth and Bluetooth Low Energy devices.
2
+
Console utility to discover and pair Bluetooth and Bluetooth Low Energy devices.
3
+
4
+
# Note on connecting to Bluetooth devices
5
+
If you pair a device which is not already paired, the utility will also connect to it (this is default behaviour of Windows Bluetooth API)<br>
6
+
However, if device is paired but not connected, the pairing will fail.<br>
7
+
Unfortunately, currently it is not possible to simulate what "Connect" button from Windows `Bluetooth and Other devices` dialog does.
8
+
More details can be found here: [How to connect to a paired audio Bluetooth device](https://stackoverflow.com/questions/62502414/how-to-connect-to-a-paired-audio-bluetooth-device-using-windows-uwp-api). Specifically, [here](https://github.com/inthehand/32feet/issues/132#issuecomment-1019786324) I have described my failed attempts to implement this functionality.<br>
3
9
4
10
# System requirements
5
11
Windows 10 1809 (10.0.17763) or higher
@@ -13,19 +19,19 @@ Windows 10 1809 (10.0.17763) or higher
13
19
```
14
20
BluetoothDevicePairing.exe discover
15
21
```
16
-
* Pair and connect to a device using its mac address:
22
+
* Pair a device using its mac address:
17
23
```
18
24
BluetoothDevicePairing.exe pair-by-mac --mac 12:34:56:78:9A:BC --type Bluetooth
The program uses [Windows.Devices.Enumeration API](https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Enumeration?redirectedfrom=MSDN&view=winrt-22000) to work with Bluetooth.
47
-
48
-
## Device pairing by mac
49
-
The utility gets the default bluetooth adapter and generates the bluetooth device id using combination of bluetooth type, adapter mac address and device's mac address. Using this id, it is possible to request to pair or unpair the device.
52
+
The program uses
53
+
*[Windows.Devices.Enumeration API](https://docs.microsoft.com/en-us/uwp/api/Windows.Devices.Enumeration?redirectedfrom=MSDN&view=winrt-22000) to work with Bluetooth.
54
+
*[Costura Fody](https://github.com/Fody/Costura) to create a single file executable.
50
55
51
56
## Device pairing by name
52
-
The utility discovers all available devices (for unpairing only paired devices are checked) and tries to find a device with the required name. After that pairing or unpairing is requested for found device. The command will fail if there are several devices with the same name.
57
+
In order to pair a device by name, the utility starts with discovering all available devices and tries to find a device with the required name. After a device is found its mac address is used to request pairing. The command will fail if there are several devices with the same name.
53
58
54
59
# Return values
55
60
In case of failure the command returns value `-1`. In case of success the `0` is returned.
@@ -60,3 +65,4 @@ In case of failure the command returns value `-1`. In case of success the `0` is
60
65
61
66
# References
62
67
*[Windows.Devices.Enumeration API usage examples](https://github.com/microsoft/Windows-universal-samples/tree/master/Samples/DeviceEnumerationAndPairing)
When the build script builds the project with "TrimMode=link" property, Msbuild produces the following warning which is treated as error because "TreatWarningsAsErrors=true":
12
-
error IL2104: Assembly '<name>' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries
0 commit comments