LinuxCommandLibrary

hciemu

Emulate Bluetooth Host Controller Interface (HCI)

SYNOPSIS

hciemu [-i hciX] [-s BDADDR] [-r {central|peripheral}] [-p PAUSE] [-P] [-l LATENCY] [-t {bredr|le}] [-c CLASS] [-n NAME] [-m MANUFACTURER] [-f FEATURES] [-h]

PARAMETERS

-i, --index hciX
    HCI device index (default hci0)

-s, --address BDADDR
    Local Bluetooth device address

-r, --role ROLE
    Emulated role: central or peripheral

-p, --pause MS
    Pause in milliseconds between events

-P, --pairable
    Enable pairable mode

-l, --latency MS
    Connection latency in milliseconds

-t, --type TYPE
    Controller type: bredr or le

-c, --class CLASS
    Device class (major:minor:service)

-n, --name NAME
    Device name

-m, --manufacturer ID
    Manufacturer ID for advertising

-f, --features FLAGS
    Hex string of supported features

-h, --help
    Show help message

DESCRIPTION

hciemu is a utility from the BlueZ Bluetooth protocol stack for Linux, designed to create virtual Host Controller Interface (HCI) devices. It simulates Bluetooth controllers, enabling developers to test Bluetooth applications, profiles, and services without requiring physical hardware. This is particularly useful for scenarios involving Low Energy (LE) peripherals, GATT servers/clients, or classic Bluetooth connections.

By launching hciemu, users can specify parameters like device address, role (central or peripheral), connection latency, and features, mimicking real-world Bluetooth behavior. The emulated device appears as a standard hciX interface (e.g., hci0), manageable with tools like hciconfig, bluetoothctl, or btmgmt. It supports both BR/EDR and LE modes, pairable configurations, and custom manufacturer data.

Common use cases include automated testing scripts, CI/CD pipelines for Bluetooth apps, and development of custom GATT services. Once started, hciemu runs in the foreground or background, handling HCI events like inquiries, connections, and data exchanges. It pauses between events for realistic timing and can be terminated with Ctrl+C, cleaning up the virtual device.

CAVEATS

Requires root privileges; conflicts with existing hciX devices; limited to single instance per index; not for production use; BlueZ 5.50+ recommended.

INSTALLATION

Part of bluez package; install via apt install bluez or yum install bluez. Source build: ./test/hciemu from BlueZ repo.

EXAMPLE USAGE

hciemu -i hci1 -s AA:BB:CC:DD:EE:FF -r peripheral -t le
Creates hci1 as LE peripheral.

HISTORY

Developed within the BlueZ project (Linux Bluetooth stack) around 2010s for testing. Evolved with BlueZ 5.x releases to support BLE central/peripheral roles and modern LE features. Maintained in BlueZ test utilities.

SEE ALSO

Copied to clipboard