Logo

dev-resources.site

for different kinds of informations.

Handling Bluetooth Programmatically on Windows

Published at
8/26/2023
Categories
bluetooth
windows
cli
Author
cppshane
Categories
3 categories in total
bluetooth
open
windows
open
cli
open
Author
8 person written this
cppshane
open
Handling Bluetooth Programmatically on Windows

I use a command to connect to my Pixel Buds now, and switch between Bluetooth devices. It's pretty convenient, especially if you're still on Windows 10, with its buggy Bluetooth auto-connection.

Install Bluetooth Command Line Tools

This is the CLI tool provided by bluetoothinstaller.com, which has provided a humble suite of Bluetooth quality of life tools since 2009.

Connecting to a Bluetooth Device

You can connect by associating a COM service with a Bluetooth device. This is done via the btcom command.

btcom {-c|-r} {-b BluetoothAddress | -n FriendlyName} [-s {sp|dun|GUID|UUID}]

  -c  Create association between COM port and a remote service (Enable non-COM service).
  -r  Remove association between COM port and a remote service (Disable non-COM service).
  -s  Remote service to use (Default is Serial Port Service)
  -b  Bluetooth address of remote device in (XX:XX:XX:XX:XX:XX) format. 
  -n  Friendly name of remote device.
  -h  Prints this help screen.
Enter fullscreen mode Exit fullscreen mode

You'll need to figure out the specific COM services that you want to hook into. Windows connects headsets via two COM services: A2DP (110b) and HFP (111e), so you may need to connect to both for it to work properly.

If you're having issues connecting (-c), try disconnecting (-r) the device first. This has worked effectively for me, although it will generally take a few seconds longer to connect.

Connect

btcom -n "Shane's Pixel Buds" -c -s110e
btcom -n "Shane's Pixel Buds" -c -s110b
Enter fullscreen mode Exit fullscreen mode

Disconnect

btcom -n "Shane's Pixel Buds" -r -s110e
btcom -n "Shane's Pixel Buds" -r -s110b
Enter fullscreen mode Exit fullscreen mode

What Bluetooth Devices Are Available?

The Friendly Name for my Pixel Buds is "Shane's Pixel Buds". You can list available Bluetooth devices and COM services using btdiscovery command. This will list the ID as well as the Friendly Name.

btdiscovery [-i Seconds] [-b BluetoothAddress | -n FriendlyName] [-d Format] [-s [Format]]

  -i  Set the length of inquiry to the specified number of seconds.
  -b  Bluetooth address of remote device in (XX:XX:XX:XX:XX:XX) format.
  -n  Friendly name of temote device.
  -d  Set output format for the list of discovered devices.
  -s  Make service discovery. Optionally set output format for the list of services.
  -h  Prints help screen.
Enter fullscreen mode Exit fullscreen mode
bluetooth Article's
30 articles in total
Favicon
Building a BLE Real-Time macOS Menu Bar App
Favicon
"Why is it, when something happens, it is always you TWO?"- troubleshooting Bluetooth and Wi-Fi devices on Debian 12
Favicon
πŸŽ‰ The Fun Beginner’s Guide to Bluetooth on Void Linux πŸŽ‰
Favicon
Automated Session Control with Bluetooth: An Insight into ble-lock-session
Favicon
Capturing the perfect (radio) wave
Favicon
How the Web Bluetooth API Enhances Passkeys
Favicon
High-Power Bluetooth LE Modules and Their Applications
Favicon
Broadcast Audio URI
Favicon
What's the Difference of BLE Connection Roles: Central vs. Peripheral?
Favicon
Embedded Rust Bluetooth on ESP: BLE Scanner
Favicon
RF-star Introduces CC2642R-Q1 Automotive Grade BLE Module for PEPS, PaaK, and BMS
Favicon
How To Use The Web Bluetooth API
Favicon
Unraveling the Wonders of Bluetooth: Connecting the World Wirelessly
Favicon
Bluetooth Bring-Up in AOSP
Favicon
How to disable the Lock key on a non-Mac Bluetooth Keyboard
Favicon
Passkeys Bluetooth: Cross-Platform Authentication
Favicon
a2dp-sink profile Protocol not available
Favicon
Handling Bluetooth Programmatically on Windows
Favicon
Developing a Bluetooth Low energy-based application
Favicon
Interacting with Shimmer3 using Node SerialPort
Favicon
TOP 5 ALL-IN-ONE BEST PRINTERS & SCANNERS FOR 2023
Favicon
From PulseAudio to PipeWire
Favicon
Struggling to fix: Bluetooth connection failed: protocol not available?
Favicon
Bluetooth LE cihazlarla çalışma
Favicon
Demystifying machine learning via Bluetooth with Arduino
Favicon
Interacting with Polar Verity Sense using Web Bluetooth
Favicon
Hacking Nespresso Expert Machine To Brew Coffee Using Custom Applications Via Bluetooth
Favicon
A Rundown of IoT Communication Protocols β€” and Expert Tips for Choosing One for Your Project
Favicon
How to choose in your smart home,is Bluetooth, ZigBee, or WiFi
Favicon
Using Web Bluetooth in an Electron App in 2022

Featured ones: