Giter Site home page Giter Site logo

jiaoxianjun / btle Goto Github PK

View Code? Open in Web Editor NEW
668.0 56.0 127.0 3.81 MB

Bluetooth Low Energy (BLE) packet sniffer and transmitter for both standard and non standard (raw bit) based on Software Defined Radio (SDR).

Home Page: http://sdr-x.github.io/

License: Apache License 2.0

C 77.57% CMake 6.37% MATLAB 12.02% Forth 4.04%
ble hackrf bladerf sdr dsp sniffer security bluetooth-low-energy software-defined-radio baseband angle-of-arrival indoor-positioning wireless-sensor-networks wireless-communication wireless-security rf protocol-parser protocol-analyser packet-sniffer

btle's Introduction

BTLE

BTLE is a free and open-source Software Defined Radio Bluetooth Low Energy (BLE) software suite.

It includes:

  • btle_rx - BLE sniffer. Besides sniff broadcasting/fixed channel, it can also track channel hopping of a communication link.
  • btle_tx - Universal BLE packet transmitter. Besides BLE standard, it supports also raw bit mode to generate arbitrary GFSK packet. In this way, you can test non-standard protocol or standard under discussion before chip in the market.

Features

  • PHY and upper layer are implemented in software (C language). Full Software Defined Radio Flexibility.
  • BLE standard 1Mbps GFSK PHY.
  • 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.

Hardware

Build and Quick test

Make sure your SDR hardware environment (driver/lib) has been setup correctly before run this project.

git clone https://github.com/JiaoXianjun/BTLE.git
cd BTLE/host
mkdir build
cd build
cmake ../                   (default. for HackRF)
cmake ../ -DUSE_BLADERF=1   (only for bladeRF)

make
./btle-tools/src/btle_rx

Above command sniffs on channel 37. You should see many packets on screen if you have BLE devices (phone/pad/laptop) around.

./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).

To have a faster operation sequence on HACKRF, use following:

#define TRANSFER_COUNT 4
#define TRANSFER_BUFFER_SIZE 4096

in hackrf/host/libhackrf/src/hackrf.c. Then re-compile the HACKRF lib and re-install it. Don't forget to re-compile BTLE to take the HACKRF lib change.

Besides the tools, matlab directory includes algorithm evaluation and other useful scirpts

btle_rx usage

-h --help

Print all arguments/usages.

-c --chan

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

-g --gain

Rx gain in dB. HACKRF rxvga default 6, valid 0 - 62. bladeRF default is max rx gain 66dB (valid 0 - 66). 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.

-l --lnaGain

LNA gain in dB (HackRF only). Default 32, valid 0 - 40. Gain should be tuned very carefully to ensure best performance under your circumstance.

-b --amp

Enable amp (HackRF only). Default off.

-a --access

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 --crcinit

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

-v --verbose

Verbose mode. Print more information when there is error

-r --raw

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

-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).

-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.

-s --filename

Store packets to pcap file.

btle_tx usage

btle_tx packet1 packet2 ... packetX ...  rN

or

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

packetX 

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

rN

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

packetX string format

channel_number-packet_type-field-value-field-value-...-Space-value

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:

37-iBeacon-AdvA-010203040506-UUID-B9407F30F5F8466EAFF925556B57FE6D-Major-0008-Minor-0009-TxPower-C5-Space-100
37

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

iBeacon

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

AdvA

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

UUID

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

Major

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

Minor

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

Txpower

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

Space

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

Demos

See a comparison with TI's packet sniffer here: http://sdr-x.github.io/BTLE-SNIFFER/

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

Appendix: Packet descriptor examples of btle_tx for all formats


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

37-RAW-aad6be898e8dc3ce338c4cb1207730144f9474e0e15eedb378c3bc

ADVERTISING CHANNEL packets (channel 37 for example):

37-IBEACON-AdvA-010203040506-UUID-B9407F30F5F8466EAFF925556B57FE6D-Major-0008-Minor-0009-TxPower-C5
37-ADV_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-AdvData-00112233445566778899AABBCCDDEEFF
37-ADV_DIRECT_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-InitA-0708090A0B0C
37-ADV_NONCONN_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-AdvData-00112233445566778899AABBCCDDEEFF
37-ADV_SCAN_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-AdvData-00112233445566778899AABBCCDDEEFF
37-SCAN_REQ-TxAdd-1-RxAdd-0-ScanA-010203040506-AdvA-0708090A0B0C
37-SCAN_RSP-TxAdd-1-RxAdd-0-AdvA-010203040506-ScanRspData-00112233445566778899AABBCCDDEEFF
37-CONNECT_REQ-TxAdd-1-RxAdd-0-InitA-010203040506-AdvA-0708090A0B0C-AA-01020304-CRCInit-050607-WinSize-08-WinOffset-090A-Interval-0B0C-Latency-0D0E-Timeout-0F00-ChM-0102030405-Hop-3-SCA-4

DATA CHANNEL packets (channel 9 for example):

9-LL_DATA-AA-60850A1B-LLID-1-NESN-0-SN-0-MD-0-DATA-XX-CRCInit-A77B22
9-LL_CONNECTION_UPDATE_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-WinSize-02-WinOffset-0e0F-Interval-0450-Latency-0607-Timeout-07D0-Instant-eeff-CRCInit-A77B22
9-LL_CHANNEL_MAP_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-ChM-1FFFFFFFFF-Instant-0201-CRCInit-A77B22
9-LL_TERMINATE_IND-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-ErrorCode-12-CRCInit-A77B22
9-LL_ENC_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-Rand-0102030405060708-EDIV-090A-SKDm-0102030405060708-IVm-090A0B0C-CRCInit-A77B22
9-LL_ENC_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-SKDs-0102030405060708-IVs-01020304-CRCInit-A77B22
9-LL_START_ENC_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22
9-LL_START_ENC_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22
9-LL_UNKNOWN_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-UnknownType-01-CRCInit-A77B22
9-LL_FEATURE_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-FeatureSet-0102030405060708-CRCInit-A77B22
9-LL_FEATURE_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-FeatureSet-0102030405060708-CRCInit-A77B22
9-LL_PAUSE_ENC_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22
9-LL_PAUSE_ENC_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22
9-LL_VERSION_IND-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-VersNr-01-CompId-0203-SubVersNr-0405-CRCInit-A77B22
9-LL_REJECT_IND-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-ErrorCode-00-CRCInit-A77B22

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

37-DISCOVERY-TxAdd-1-RxAdd-0-AdvA-010203040506-FLAGS-02-LOCAL_NAME09-CA-TXPOWER-03-SERVICE03-180D1810-SERVICE_DATA-180D40-MANUF_DATA-0001FF-CONN_INTERVAL-0006 (-SERVICE_SOLI14-1811)

FLAGS: 0x01 LE Limited Discoverable Mode; 0x02 LE General Discoverable Mode
SERVICE:
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

btle's People

Contributors

alick avatar jiaoxianjun avatar jocover avatar john-leitch avatar mike01 avatar muellermartin avatar sdr-x avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

btle's Issues

How to save the sampling data?

I want to save the analog sampling into a txt file,so I add some codes at demod_byte part,but after I do this the data will be damaged and I do not know why,any help will be helpful,thank you very much

Feature request

Any chance you could add support to bluetooth classic? I would love to be able to capturing pairing information without having to spend $20k on hardware.

Or do you know any other projects that can?

How can I generate the CRC table?

Hi Dr. Jiao:
We are learning the BLE PHY layer, and BTLE helps us a lot!
However, we have some trouble to derive the CRC table, it seems that the calculation of the CRC remainder is different from the traditional method because of the bit ordering. So, can you show us how to generate the CRC table or open source the code to generate this table? Thank you very much!
Best regards
Yeming Li

build fails on MAC

To avoid build failure on MAC computer, you should remove those "inline" key words of function.

btle_rx not working with HackRF

Hi,

I've been trying to sniff the advertisement packets for a BLE Beacon as well as a BLE tracker using btle_rx. However I'm unable to capture any data even when specifying the exact channel of advertisement. However, these advertisement packets are being picked up by ubertooth-btle. I have tried changing the gain values and even specifying the frequency instead of the channel with no results. The RX LED of HackRF is lit up while running btle_rx.

Similarly for btle_tx, I've tried to transmitting the samples mentioned in the documentation. I'm unable to get the transmitted packets in ubertooth-btle. In case of iBeacon sample, my phone is unable to see it as well. The TX LED of HackRF is lit when running btle_tx.

Thanks!

Scramble table

Hi I was wondering what the use is for the sample table. It seems needed but I'm unsure how that got calculated.

BladeRF x40 TX

Hi - I am using the btle_tx function with the BladeRF x40. There are no errors, however my packet sniffing tools do not see any packets, nor does my iBeacon scanner. Is there any configuration I am missing or is it because of an API change?

Building for bladerf

Hi I have bladeRF not hackRF. When I follow the instructions to build your code, I get the cmake error:

Could NOT find LIBHACKRF (missing: LIBHACKRF_LIBRARIES LIBHACKRF_INCLUDE_DIR)
Call Stack
/usr/share/cmake-3.0/Modules/FinePacakageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
cmake/modules/FindLIBHACKRF.cmake:52 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
btle-tools/CMakeLists.txt:49 (find_pakage)

Could you advise me how to build this for bladeRF instead of hackRF?

Thanks

Print absolute raw bits 1,0s no parsing

  1. Who are you?
    Application Engineer
  2. What is your own modification (if any)?
    None
  3. Environments: OS type/version, BTLE repo branch and commit revision
    Ubuntu Latest. BTLE main branch
  4. Board/hardware type
    HACKRF
  5. Detailed commands/steps to reproduce the issue, and the related error message, screenshot, etc
    NONE
  6. Your debug efforts and results (if any)
    NA
  7. Any other thing we need to know for helping you better?
    NA

This is not an issues, but you do not have discussions enabled, so I will ask my question here.
Question 1.
How would I modify your code in order to be able to print a bit stream of BLE traffic , absolute zero parsing ?. Or for more general purpose, how can I print the bits of what ever rf signal hackrf is giving me. ? Essentialy I am trying to demodulate a signal very similar to BLE and I need to see the raw data to make sure we are transmitting properly. Your work here seems like it can do the job I am just unsure how to do so.
Question 2.
I noticed the -r flag for btle_rx but is that really absolute raw? or are you parsing header and aa because is see it displayed there.?

cannot run the source code with gdb in Eclipse

I tried to import the project as a makefile project in eclipse. I am trying to use gdb to know the details of BLE scanner.

16:14:16 **** Incremental Build of configuration Release for project ble ****
make all
Building file: ../src/btle_rx.c
Invoking: GCC C Compiler
gcc -I/usr/local/src/hackrf/host/libhackrf/src -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/btle_rx.d" -MT"src/btle_rx.o" -o "src/btle_rx.o" "../src/btle_rx.c"
../src/btle_rx.c: In function ‘parse_ll_pdu_payload_byte’:
../src/btle_rx.c:1411:7: warning: ‘ctrl_pdu_type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
int ctrl_pdu_type;
^
../src/btle_rx.c: In function ‘receiver’:
../src/btle_rx.c:1982:27: warning: ‘ll_pdu_type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
print_ll_pdu_payload((void *)(&ll_data_pdu_payload), ll_pdu_type, ll_ctrl_pdu_type, payload_len, crc_flag);
^
../src/btle_rx.c:1975:28: warning: ‘adv_pdu_type’ may be used uninitialized in this function [-Wmaybe-uninitialized]
print_adv_pdu_payload((void *)(&adv_pdu_payload), adv_pdu_type, payload_len, crc_flag);
^
Finished building: ../src/btle_rx.c

Building file: ../src/btle_tx.c
Invoking: GCC C Compiler
gcc -I/usr/local/src/hackrf/host/libhackrf/src -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/btle_tx.d" -MT"src/btle_tx.o" -o "src/btle_tx.o" "../src/btle_tx.c"
../src/btle_tx.c: In function ‘main’:
../src/btle_tx.c:4266:5: warning: ‘num_packet’ may be used uninitialized in this function [-Wmaybe-uninitialized]
for (i=0; i<num_packet; i++) {
^
Finished building: ../src/btle_tx.c

Building target: ble
Invoking: GCC C Linker
gcc -L/usr/local/include/libhackrf/ -o "ble" ./src/btle_rx.o ./src/btle_tx.o
./src/btle_tx.o: In function sigint_callback_handler': btle_tx.c:(.text+0x160): multiple definition of sigint_callback_handler'
./src/btle_rx.o:btle_rx.c:(.text+0x50): first defined here
./src/btle_tx.o:(.bss+0xf04): multiple definition of do_exit' ./src/btle_rx.o:(.bss+0x0): first defined here ./src/btle_tx.o: In function init_board':
btle_tx.c:(.text+0x2c0): multiple definition of init_board' ./src/btle_rx.o:btle_rx.c:(.text+0x190): first defined here ./src/btle_tx.o: In function open_board':
btle_tx.c:(.text+0x360): multiple definition of open_board' ./src/btle_rx.o:btle_rx.c:(.text+0x270): first defined here ./src/btle_tx.o: In function exit_board':
btle_tx.c:(.text+0x460): multiple definition of exit_board' ./src/btle_rx.o:btle_rx.c:(.text+0x3b0): first defined here ./src/btle_tx.o: In function close_board':
btle_tx.c:(.text+0x490): multiple definition of close_board' ./src/btle_rx.o:btle_rx.c:(.text+0x3e0): first defined here ./src/btle_tx.o: In function toupper_str':
btle_tx.c:(.text+0xa40): multiple definition of toupper_str' ./src/btle_rx.o:btle_rx.c:(.text+0x840): first defined here ./src/btle_tx.o: In function octet_hex_to_bit':
btle_tx.c:(.text+0xa90): multiple definition of octet_hex_to_bit' ./src/btle_rx.o:btle_rx.c:(.text+0x890): first defined here ./src/btle_tx.o: In function int_to_bit':
btle_tx.c:(.text+0xb60): multiple definition of int_to_bit' ./src/btle_rx.o:btle_rx.c:(.text+0x920): first defined here ./src/btle_tx.o: In function convert_hex_to_bit':
btle_tx.c:(.text+0xbc0): multiple definition of convert_hex_to_bit' ./src/btle_rx.o:btle_rx.c:(.text+0x1070): first defined here ./src/btle_tx.o: In function crc_update':
btle_tx.c:(.text+0x3600): multiple definition of crc_update' ./src/btle_rx.o:btle_rx.c:(.text+0x16a0): first defined here ./src/btle_tx.o: In function crc24_byte':
btle_tx.c:(.text+0x3640): multiple definition of crc24_byte' ./src/btle_rx.o:btle_rx.c:(.text+0x16e0): first defined here ./src/btle_tx.o: In function scramble_byte':
btle_tx.c:(.text+0x3820): multiple definition of scramble_byte' ./src/btle_rx.o:btle_rx.c:(.text+0x1720): first defined here ./src/btle_tx.o: In function disp_bit':
btle_tx.c:(.text+0x4a10): multiple definition of disp_bit' ./src/btle_rx.o:btle_rx.c:(.text+0x1190): first defined here ./src/btle_tx.o: In function disp_bit_in_hex':
btle_tx.c:(.text+0x4ab0): multiple definition of disp_bit_in_hex' ./src/btle_rx.o:btle_rx.c:(.text+0x1230): first defined here ./src/btle_tx.o: In function disp_hex':
btle_tx.c:(.text+0x4b40): multiple definition of disp_hex' ./src/btle_rx.o:btle_rx.c:(.text+0x12c0): first defined here ./src/btle_tx.o: In function disp_hex_in_bit':
btle_tx.c:(.text+0x4b90): multiple definition of disp_hex_in_bit' ./src/btle_rx.o:btle_rx.c:(.text+0x1310): first defined here ./src/btle_tx.o: In function save_phy_sample':
btle_tx.c:(.text+0xd070): multiple definition of save_phy_sample' ./src/btle_rx.o:btle_rx.c:(.text+0x13d0): first defined here ./src/btle_tx.o: In function save_phy_sample_for_matlab':
btle_tx.c:(.text+0xd130): multiple definition of save_phy_sample_for_matlab' ./src/btle_rx.o:btle_rx.c:(.text+0x1570): first defined here ./src/btle_tx.o: In function main':
btle_tx.c:(.text.startup+0x0): multiple definition of main' ./src/btle_rx.o:btle_rx.c:(.text.startup+0x0): first defined here ./src/btle_rx.o: In function init_board':
btle_rx.c:(.text+0x194): undefined reference to hackrf_init' btle_rx.c:(.text+0x203): undefined reference to hackrf_error_name'
./src/btle_rx.o: In function board_set_freq': btle_rx.c:(.text+0x232): undefined reference to hackrf_set_freq'
btle_rx.c:(.text+0x243): undefined reference to hackrf_error_name' ./src/btle_rx.o: In function open_board':
btle_rx.c:(.text+0x287): undefined reference to hackrf_open' btle_rx.c:(.text+0x298): undefined reference to hackrf_set_freq'
btle_rx.c:(.text+0x2b2): undefined reference to hackrf_set_sample_rate' btle_rx.c:(.text+0x2c9): undefined reference to hackrf_set_baseband_filter_bandwidth'
btle_rx.c:(.text+0x2de): undefined reference to hackrf_set_vga_gain' btle_rx.c:(.text+0x2ed): undefined reference to hackrf_set_lna_gain'
btle_rx.c:(.text+0x313): undefined reference to hackrf_error_name' btle_rx.c:(.text+0x34b): undefined reference to hackrf_error_name'
btle_rx.c:(.text+0x363): undefined reference to hackrf_error_name' btle_rx.c:(.text+0x37b): undefined reference to hackrf_error_name'
btle_rx.c:(.text+0x393): undefined reference to hackrf_error_name' ./src/btle_rx.o: In function exit_board':
btle_rx.c:(.text+0x3bc): undefined reference to hackrf_exit' ./src/btle_rx.o: In function close_board':
btle_rx.c:(.text+0x3ef): undefined reference to hackrf_stop_rx' btle_rx.c:(.text+0x3fd): undefined reference to hackrf_close'
btle_rx.c:(.text+0x413): undefined reference to hackrf_error_name' btle_rx.c:(.text+0x443): undefined reference to hackrf_error_name'
./src/btle_rx.o: In function run_board': btle_rx.c:(.text+0x47a): undefined reference to hackrf_stop_rx'
btle_rx.c:(.text+0x48f): undefined reference to hackrf_start_rx' btle_rx.c:(.text+0x4ab): undefined reference to hackrf_error_name'
btle_rx.c:(.text+0x4d3): undefined reference to hackrf_error_name' ./src/btle_rx.o: In function config_run_board':
btle_rx.c:(.text+0x525): undefined reference to hackrf_init' btle_rx.c:(.text+0x591): undefined reference to hackrf_open'
btle_rx.c:(.text+0x5a7): undefined reference to hackrf_set_freq' btle_rx.c:(.text+0x5c2): undefined reference to hackrf_set_sample_rate'
btle_rx.c:(.text+0x5da): undefined reference to hackrf_set_baseband_filter_bandwidth' btle_rx.c:(.text+0x5f0): undefined reference to hackrf_set_vga_gain'
btle_rx.c:(.text+0x600): undefined reference to hackrf_set_lna_gain' btle_rx.c:(.text+0x618): undefined reference to hackrf_stop_rx'
btle_rx.c:(.text+0x631): undefined reference to hackrf_start_rx' btle_rx.c:(.text+0x653): undefined reference to hackrf_error_name'
btle_rx.c:(.text+0x683): undefined reference to hackrf_error_name' btle_rx.c:(.text+0x6c3): undefined reference to hackrf_error_name'
btle_rx.c:(.text+0x6eb): undefined reference to hackrf_error_name' btle_rx.c:(.text+0x713): undefined reference to hackrf_error_name'
./src/btle_rx.o:btle_rx.c:(.text+0x743): more undefined references to hackrf_error_name' follow ./src/btle_rx.o: In function stop_close_board':
btle_rx.c:(.text+0x7bf): undefined reference to hackrf_stop_rx' btle_rx.c:(.text+0x7cd): undefined reference to hackrf_close'
btle_rx.c:(.text+0x7da): undefined reference to hackrf_exit' btle_rx.c:(.text+0x803): undefined reference to hackrf_error_name'
btle_rx.c:(.text+0x82b): undefined reference to hackrf_error_name' ./src/btle_rx.o: In function receiver_controller':
btle_rx.c:(.text+0x3ebd): undefined reference to hackrf_set_freq' btle_rx.c:(.text+0x3fcb): undefined reference to hackrf_set_freq'
btle_rx.c:(.text+0x42a6): undefined reference to hackrf_error_name' btle_rx.c:(.text+0x4379): undefined reference to hackrf_set_freq'
btle_rx.c:(.text+0x4472): undefined reference to hackrf_error_name' ./src/btle_tx.o: In function init_board':
btle_tx.c:(.text+0x2c4): undefined reference to hackrf_init' btle_tx.c:(.text+0x333): undefined reference to hackrf_error_name'
./src/btle_tx.o: In function open_board': btle_tx.c:(.text+0x367): undefined reference to hackrf_open'
btle_tx.c:(.text+0x380): undefined reference to hackrf_set_freq' btle_tx.c:(.text+0x39a): undefined reference to hackrf_set_sample_rate'
btle_tx.c:(.text+0x3b1): undefined reference to hackrf_set_txvga_gain' btle_tx.c:(.text+0x3c3): undefined reference to hackrf_error_name'
btle_tx.c:(.text+0x3eb): undefined reference to hackrf_error_name' btle_tx.c:(.text+0x413): undefined reference to hackrf_error_name'
btle_tx.c:(.text+0x43b): undefined reference to hackrf_error_name' ./src/btle_tx.o: In function exit_board':
btle_tx.c:(.text+0x471): undefined reference to hackrf_exit' ./src/btle_tx.o: In function close_board':
btle_tx.c:(.text+0x49e): undefined reference to hackrf_stop_tx' btle_tx.c:(.text+0x4b0): undefined reference to hackrf_close'
btle_tx.c:(.text+0x4c3): undefined reference to hackrf_error_name' btle_tx.c:(.text+0x4f3): undefined reference to hackrf_error_name'
./src/btle_tx.o: In function tx_one_buf': btle_tx.c:(.text+0x594): undefined reference to hackrf_open'
btle_tx.c:(.text+0x5b1): undefined reference to hackrf_set_freq' btle_tx.c:(.text+0x5cf): undefined reference to hackrf_set_sample_rate'
btle_tx.c:(.text+0x5ea): undefined reference to hackrf_set_txvga_gain' btle_tx.c:(.text+0x611): undefined reference to hackrf_start_tx'
btle_tx.c:(.text+0x63d): undefined reference to hackrf_is_streaming' btle_tx.c:(.text+0x65c): undefined reference to hackrf_stop_tx'
btle_tx.c:(.text+0x67b): undefined reference to hackrf_stop_tx' btle_tx.c:(.text+0x68d): undefined reference to hackrf_close'
btle_tx.c:(.text+0x6f4): undefined reference to hackrf_error_name' btle_tx.c:(.text+0x722): undefined reference to hackrf_error_name'
btle_tx.c:(.text+0x761): undefined reference to hackrf_error_name' btle_tx.c:(.text+0x780): undefined reference to hackrf_error_name'
btle_tx.c:(.text+0x7a4): undefined reference to hackrf_error_name' ./src/btle_tx.o:btle_tx.c:(.text+0x7c6): more undefined references to hackrf_error_name' follow
./src/btle_tx.o: In function main': btle_tx.c:(.text.startup+0x123): undefined reference to hackrf_open'
btle_tx.c:(.text.startup+0x13e): undefined reference to hackrf_set_freq' btle_tx.c:(.text.startup+0x15a): undefined reference to hackrf_set_sample_rate'
btle_tx.c:(.text.startup+0x173): undefined reference to hackrf_set_txvga_gain' btle_tx.c:(.text.startup+0x198): undefined reference to hackrf_start_tx'
btle_tx.c:(.text.startup+0x1cd): undefined reference to hackrf_is_streaming' btle_tx.c:(.text.startup+0x1ec): undefined reference to hackrf_stop_tx'
btle_tx.c:(.text.startup+0x209): undefined reference to hackrf_stop_tx' btle_tx.c:(.text.startup+0x21d): undefined reference to hackrf_close'
btle_tx.c:(.text.startup+0x408): undefined reference to hackrf_error_name' btle_tx.c:(.text.startup+0x45e): undefined reference to hackrf_error_name'
btle_tx.c:(.text.startup+0x499): undefined reference to hackrf_error_name' btle_tx.c:(.text.startup+0x4be): undefined reference to hackrf_error_name'
btle_tx.c:(.text.startup+0x4e6): undefined reference to hackrf_error_name' ./src/btle_tx.o:btle_tx.c:(.text.startup+0x50e): more undefined references to hackrf_error_name' follow
collect2: error: ld returned 1 exit status
make: *** [ble] Error 1

16:14:19 Build Finished (took 3s.29ms)

segmentation fault

i get a segmentation fault when trying to execute btle_rx

execve("/usr/local/bin/btle_rx", ["btle_rx"], [/* 45 vars */]) = 0
brk(0)                                  = 0x9d16000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7748000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=167542, ...}) = 0
mmap2(NULL, 167542, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb771f000
close(3)                                = 0
open("/usr/lib/libhackrf.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220\26\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=21916, ...}) = 0
mmap2(NULL, 24780, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7718000
mmap2(0xb771d000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4000) = 0xb771d000
close(3)                                = 0
open("/lib/libm.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300E\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=275868, ...}) = 0
mmap2(NULL, 278688, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb76d3000
mmap2(0xb7716000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x42000) = 0xb7716000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0r\207\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1665088, ...}) = 0
mmap2(NULL, 1674924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb753a000
mmap2(0xb76cc000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x191000) = 0xb76cc000
mmap2(0xb76d1000, 7852, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb76d1000
close(3)                                = 0
open("/lib/libusb-1.0.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\0/\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=83728, ...}) = 0
mmap2(NULL, 86684, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7524000
mmap2(0xb7538000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x13000) = 0xb7538000
close(3)                                = 0
open("/lib/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\237N\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=96676, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7523000
mmap2(NULL, 107212, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7508000
mprotect(0xb751e000, 4096, PROT_NONE)   = 0
mmap2(0xb751f000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x16000) = 0xb751f000
mmap2(0xb7521000, 4812, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7521000
close(3)                                = 0
open("/lib/libudev.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\0\0\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=75168, ...}) = 0
mmap2(NULL, 79924, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb74f4000
mmap2(0xb7506000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x11000) = 0xb7506000
close(3)                                = 0
open("/lib/librt.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\1\1\1\3\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0@\30\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=26456, ...}) = 0
mmap2(NULL, 29240, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb74ec000
mmap2(0xb74f2000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x5000) = 0xb74f2000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb74eb000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb74ea000
set_thread_area({entry_number:-1, base_addr:0xb74ea700, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0 (entry_number:6)
mprotect(0xb76cc000, 12288, PROT_READ)  = 0
mprotect(0xb751f000, 4096, PROT_READ)   = 0
mprotect(0xb74f2000, 4096, PROT_READ)   = 0
mprotect(0xb7506000, 4096, PROT_READ)   = 0
mprotect(0xb7538000, 4096, PROT_READ)   = 0
mprotect(0xb7716000, 4096, PROT_READ)   = 0
mprotect(0xb771d000, 4096, PROT_READ)   = 0
mprotect(0x8050000, 4096, PROT_READ)    = 0
mprotect(0xb776d000, 4096, PROT_READ)   = 0
munmap(0xb771f000, 167542)              = 0
set_tid_address(0xb74ea768)             = 7789
set_robust_list(0xb74ea770, 12)         = 0
rt_sigaction(SIGRTMIN, {0xb750c960, [], SA_SIGINFO}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb750c9d8, [], SA_RESTART|SA_SIGINFO}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
getrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
uname({sys="Linux", node="pentoo", ...}) = 0
fstat64(1, {st_mode=S_IFREG|0644, st_size=5257, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7747000
--- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_MAPERR, si_addr=0x6} ---
+++ killed by SIGSEGV +++

my system is Linux pentoo 4.0.8-pentoo #1 SMP Sat Nov 28 18:30:44 UTC 2015 i686 Intel(R) Atom(TM) CPU Z550 @ 2.00GHz GenuineIntel GNU/Linux

To explain function demod_bits()

Hi Xianjun,
Function demod_bits(a, num_bits, sample_per_symbol) implements the way how ADC samples is converted to bits.

1: Could you explain why the following code is able to determine the bit is 0 or 1:

if (I0*Q1 - I1*Q0) > 0
        bits(k) = 1; 

2: If sample_per_symbol is 4, just the first two samples are used to determine the bit value of the symbol as showed in function demo_bits(). What's the purpose of the other two samples? Will they be just discarded?

why I can not achieve the hopping?

I run the program first:
btle_rx -c chan -g gain -a access_addr -k crc_init -o
I can see the adv data,then I connect my phone with bluetooth modules,but I can not see the hopping data,any help will be appreciated.

Is it possible to transmit ble packets faster?

  1. Who are you?
    Graduate student
  2. What is your own modification (if any)?
    None
  3. Environments: OS type/version, BTLE repo branch and commit revision
    Ubuntu Latest. BTLE main branch
  4. Board/hardware type
    HackRF
  5. Detailed commands/steps to reproduce the issue, and the related error message, screenshot, etc
    btle_tx
  6. Your debug efforts and results (if any)
    NA
  7. Any other thing we need to know for helping you better?
    NA

I found the Space paras to control the time interval between packets. However, there exists a lower bound of around 295ms, leading to a minimum delay of about 0.3s. Assigning spacing of larger than this will work but a smaller space seems useless. I'm asking whether it would be possible to have lower limits and transmit the next packet even faster? How to possibly achieve that?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.