Skip to content
Bluetooth Low Energy (BLE) packet sniffer and generator for both standard and non standard (raw bit).
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc add ibeacon.pdf Feb 23, 2019
host remove lld format warning Mar 9, 2019
matlab scanner sniffer works Nov 1, 2015
usrp_replay_example Update Apr 6, 2017
LICENSE Create LICENSE Feb 23, 2019


BTLE is a free and open-source Bluetooth Low Energy (BLE) software suite developed by Xianjun Jiao.

It includes:

  • btle_rx - a complete BLE sniffer. Besides sniff broadcasting/fixed channel, it also can track channel hopping of a communication link.
  • btle_tx - a universal BLE packet generator. Besides BLE standard, it also supports raw bit mode to generate arbitrary GFSK packet. In this way, you can test private protocol or planned standard feature even before ASIC is ready.

This project is based on HackRF and bladeRF. See compatible version of HackRF and bladeRF libraries.


  • PHY and upper layer are implemented in software (C language). Full Software Defined Radio Flexibility.
  • BLE standard 1Mbps GFSK PHY rate.
  • All ADV and DATA channel link layer packet formats in Core_V4.0 (Chapter 2&3, PartB, Volume 6) are supported.
  • Sniffer is capable to parse and track channel hopping pattern automatically, not limited to broadcasting channel or fixed channel.


  • HackRF
  • bladeRF

Build and Quick test


git clone
cd BTLE/host
mkdir build
cd build
cmake ../                   (default. for HackRF)
cmake ../ -DUSE_BLADERF=1   (for bladeRF)

without -DUSE_BLADERF=1 in above cmake means HACKRF will be used by default


Above command sniffs on channel 37. You should see many packets on screen.

./btle-tools/src/btle_tx 37-DISCOVERY-TxAdd-1-RxAdd-0-AdvA-010203040506-LOCAL_NAME09-SDR/Bluetooth/Low/Energy r500 

Above command transmits discovery packets on ADV channel. You should see a device with name "SDR/Bluetooth/Low/Energy" in another BLE sniffer App (such as LightBlue).

MAY NOT BE NECESSARY: To support fast/realtime sender and scanner/sniffer, I have changed:

lib_device->transfer_count to 4

lib_device->buffer_size to 4096

in hackrf driver: hackrf.c. You should also do that change to your HackRF driver source code and re-compile, re-install

btle_rx usage

btle_rx -c chan -g gain -a access_addr -k crc_init -v -r
-c chan 

Channel number. Default value 37 (one of ADV channels). Valid value 0~39 (all ADV and DATA channels).

-g gain

VGA gain. default value 6. valid value 0~62. LNA has been set to maximum 40dB internally. Gain should be tuned very carefully to ensure best performance under your circumstance. Suggest test from low gain, because high gain always causes severe distortion and get you nothing.

-a access_addr

Access address. Default 8e89bed6 for ADV channel 37 38 39. You should specify correct value for data channel according to captured connection setup procedure.

-k crc_init

Default 555555 for ADV channel. You should specify correct value for data channel according to captured connection setup procedure.


Verbose mode. Print more information when there is error


Raw mode. After access addr is detected, print out following raw 42 bytes (without descrambling, parsing)

-o --hop

This will turn on data channel tracking (frequency hopping) after link setup information is captured in ADV_CONNECT_REQ packet on ADV channel.

-f --freq_hz (need argument)

This frequency (Hz) will override channel setting (In case someone want to work on freq other than BTLE. More general purpose).

-m --access_mask (need argument)

If a bit is 1 in this mask, corresponding bit in access address will be taken into packet existing decision (In case someone want a shorter/sparser unique word to do packet detection. More general purpose).

btle_tx usage

btle_tx packet1 packet2 ... packetX ...  rN


btle_tx packets.txt

packets.txt is a text file which has command line parameters (packet1 packet2 ... rN) text. One parameter one line. A line start with "#" is regarded as comment. See packets.txt example


is one string which describes one packet. All packets compose a packets sequence.


means the sequence will be repeated for N times. If it is not specified, the sequence will only be sent once.

packetX string format


Each descriptor string starts with BTLE channel number (0~39), then followed by packet_type (RAW/iBeacon/ADV_IND/ADV_DIRECT_IND/etc. See all format examples AT THE END: Appendix ), then followed by field-value pair which is packet_type specific, at last there is Space-value pair (optional) where the value specifies how many millisecond will be waited after this packet sent.

DO NOT use space character " " in a command line packet descriptor. You CAN use space in the txt file packet descriptor.

DO NOT use "-" inside each field. "-" is magic character which is used to separate different fields in packet descriptor.

Open LightBlue APP (or other BLE sniffer) in your iPhone/device before this command:

./btle-tools/src/btle_tx ../btle-tools/src/packets_discovery.txt

You will see a device named as "SDR Bluetooth Low Energy" in your LightBlue APP.

Corresponding Command line:

./btle-tools/src/btle_tx 37-DISCOVERY-TxAdd-1-RxAdd-0-AdvA-010203040506-LOCAL_NAME09-SDR/Bluetooth/Low/Energy r40

Note: space " " is replaced by "/" because space " " is not supported in command line.

btle_tx 37-ADV_IND-TxAdd-0-RxAdd-0-AdvA-90D7EBB19299-AdvData-0201050702031802180418-Space-1      37-CONNECT_REQ-TxAdd-0-RxAdd-0-InitA-001830EA965F-AdvA-90D7EBB19299-AA-60850A1B-CRCInit-A77B22-WinSize-02-WinOffset-000F-Interval-0050-Latency-0000-Timeout-07D0-ChM-1FFFFFFFFF-Hop-9-SCA-5-Space-1     9-LL_DATA-AA-60850A1B-LLID-1-NESN-0-SN-0-MD-0-DATA-XX-CRCInit-A77B22-Space-1

Above simulates a Connection establishment procedure between device 1 and device 2. Corresponding descriptor file BTLE/host/btle-tools/src/packets.txt.

The 1st packet -- device 1 sends ADV_IND packet in channel 37.

The 2nd packet -- After device 2 (in scanning state) receives the ADV packet from device 1, device 2 sends CONNECT_REQ packet to request connection setup with device 1. In this request packet, there are device 2 MAC address (InitA), target MAC address (device 1 MAC address AdvA), Access address (AA) which will be used by device 1 in following packet sending in data channel, CRC initialization value for following device 1 sending packet, Hopping channel information (ChM and Hop) for data channel used by device 1, etc.

The 3rd packet -- device 1 send an empty Link layer data PDU in channel 9 (decided by hopping scheme) according to those connection request information received from device 2. ("XX" after field "DATA" means there is no data for this field )

Time space between packets are 1s (1000ms). Tune TI's packet sniffer to channel 37, then above establishment procedure will be captured.

./btle-tools/src/btle_tx 37-iBeacon-AdvA-010203040506-UUID-B9407F30F5F8466EAFF925556B57FE6D-Major-0008-Minor-0009-TxPower-C5-Space-100     r100

Above command sends iBeacon packet and repeats it 100 times with 100ms time space. Corresponding descriptor file BTLE/host/btle-tools/src/packets_ibeacon.txt. You can use a BLE sniffer dongle to see the packet.

The packet descriptor string:


channel 37 (one of BTLE Advertising channel 37 38 39)


packet format key word which means iBeacon format. (Actually it is ADV_IND format in Core_V4.0.pdf)


Advertising address (MAC address) which is set as 010203040506 (See Core_V4.0.pdf)


here we specify it as Estimote’s fixed UUID: B9407F30F5F8466EAFF925556B57FE6D


major number of iBeacon format. (Here it is 0008)


minor number of iBeacon format. (Here it is 0009)


transmit power parameter of iBeacon format (Here it is C5)


How many millisecond will be waited after this packet sent. (Here it is 100ms)


See a comparison with TI's packet sniffer here:

See btle_rx video demo (youtube) or btle_rx video demo (in China) and btle_tx video demo 1 (outside China) or btle_tx video demo 2 (inside China)

Appendix: Packet descriptor examples of btle_tx for all formats

RAW packets: (All bits will be sent to GFSK modulator directly)


ADVERTISING CHANNEL packets (channel 37 for example):


DATA CHANNEL packets (channel 9 for example):


Discovery packets: (which can show any name or services in scanner APP, such as LightBlue):


FLAGS: 0x01 LE Limited Discoverable Mode; 0x02 LE General Discoverable Mode
0x02 16-bit Service UUIDs More 16-bit UUIDs available
0x03 16-bit Service UUIDs Complete list of 16-bit UUIDs available
0x04 32-bit Service UUIDs More 3a2-bit UUIDs available
0x05 32-bit Service UUIDs Complete list of 32-bit UUIDs available
0x06 128-bit Service UUIDs More 128-bit UUIDs available
0x07 128-bit Service UUIDs Complete list of 128-bit UUIDs available
You can’t perform that action at this time.