Inspect, connect to and scan for Bluetooth devices, and watch them connect and disconnect.
The module offers two kinds of object, because macOS identifies them in two different ways:
HSBluetoothDevice: a device macOS knows by its Bluetooth address, such as headphones, a
keyboard or a mouse paired with this Mac. These have battery levels and system-wide
connect/disconnect events.
HSBluetoothPeripheral: a Bluetooth Low Energy (BLE) peripheral, found by scan(), which
Hammerspoon can connect to itself to read and write its GATT characteristics. macOS gives
these a UUID identifier instead of revealing their address.
macOS asks the user for Bluetooth permission the first time this module talks to Bluetooth.
Use hs.permissions.checkBluetooth() to see whether it has been granted.
Inspect, connect to and scan for Bluetooth devices, and watch them connect and disconnect.
The module offers two kinds of object, because macOS identifies them in two different ways:
HSBluetoothDevice: a device macOS knows by its Bluetooth address, such as headphones, a keyboard or a mouse paired with this Mac. These have battery levels and system-wide connect/disconnect events.HSBluetoothPeripheral: a Bluetooth Low Energy (BLE) peripheral, found byscan(), which Hammerspoon can connect to itself to read and write its GATT characteristics. macOS gives these a UUIDidentifierinstead of revealing their address.macOS asks the user for Bluetooth permission the first time this module talks to Bluetooth. Use
hs.permissions.checkBluetooth()to see whether it has been granted.