{"id":13376313,"url":"https://github.com/jiaoxianjun/btle","last_synced_at":"2025-05-15T03:06:55.237Z","repository":{"id":19115103,"uuid":"22344046","full_name":"JiaoXianjun/BTLE","owner":"JiaoXianjun","description":"Bluetooth Low Energy (BLE) packet sniffer and transmitter for both standard and non standard (raw bit) based on Software Defined Radio (SDR).","archived":false,"fork":false,"pushed_at":"2024-11-08T15:00:50.000Z","size":13472,"stargazers_count":792,"open_issues_count":16,"forks_count":144,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-05-15T03:06:47.482Z","etag":null,"topics":["angle-of-arrival","baseband","bladerf","ble","bluetooth-low-energy","dsp","hackrf","indoor-positioning","packet-sniffer","protocol-analyser","protocol-parser","rf","sdr","security","sniffer","software-defined-radio","wireless-communication","wireless-security","wireless-sensor-networks"],"latest_commit_sha":null,"homepage":"http://sdr-x.github.io/","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"apache/cordova-plugin-contacts","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JiaoXianjun.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-07-28T13:48:37.000Z","updated_at":"2025-05-08T02:49:17.000Z","dependencies_parsed_at":"2023-01-11T20:30:48.429Z","dependency_job_id":"620b045f-5ea6-4ea0-a9ac-12c8a45c2d12","html_url":"https://github.com/JiaoXianjun/BTLE","commit_stats":{"total_commits":251,"total_committers":10,"mean_commits":25.1,"dds":"0.19123505976095623","last_synced_commit":"8e97fc67362866a8b66b436847045aac93987cdb"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaoXianjun%2FBTLE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaoXianjun%2FBTLE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaoXianjun%2FBTLE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiaoXianjun%2FBTLE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JiaoXianjun","download_url":"https://codeload.github.com/JiaoXianjun/BTLE/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254264766,"owners_count":22041793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angle-of-arrival","baseband","bladerf","ble","bluetooth-low-energy","dsp","hackrf","indoor-positioning","packet-sniffer","protocol-analyser","protocol-parser","rf","sdr","security","sniffer","software-defined-radio","wireless-communication","wireless-security","wireless-sensor-networks"],"created_at":"2024-07-30T05:02:40.431Z","updated_at":"2025-05-15T03:06:50.209Z","avatar_url":"https://github.com/JiaoXianjun.png","language":"Jupyter Notebook","readme":"BTLE\n========\n\nBTLE is a free and open-source Software Defined Radio Bluetooth Low Energy (BLE) software suite and efforts for [open BTLE chip design](https://github.com/JiaoXianjun/BTLE/tree/master/open_btle_baseband_chip). \n\nIt includes:\n  * BTLE baseband [algorithms description, Python and Verilog implementation, Xilinx FPGA (Vivado 2021.1) and SkyWater 130 PDK (OpenLane2 workflow) results](https://github.com/JiaoXianjun/BTLE/tree/master/open_btle_baseband_chip).\n  * **btle_rx** - BLE sniffer. Besides sniff broadcasting/fixed channel, it can also track channel hopping of a communication link.\n  * **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.\n\nFeatures\n---------------\n\n * PHY and upper layer are implemented in software (C language). Full Software Defined Radio Flexibility. \n * BLE standard 1Mbps GFSK PHY.\n * All ADV and DATA channel link layer packet formats in Core_V4.0 (Chapter 2\u00263, PartB, Volume 6) are supported.\n * Sniffer is capable to parse and track channel hopping pattern automatically, not limited to broadcasting channel or fixed channel.\n\nHardware\n--------\n\n * [HackRF](https://github.com/mossmann/hackrf)\n * [bladeRF](https://github.com/Nuand/bladeRF)\n * [compatible version of HackRF and bladeRF libraries](compatible_hackrf_bladerf_lib.txt)\n\nBuild and Quick test\n------------------\n\nMake sure your SDR hardware environment (driver/lib) has been setup correctly before run this project.\n\n```\ngit clone https://github.com/JiaoXianjun/BTLE.git\ncd BTLE/host\nmkdir build\ncd build\ncmake ../                   (default. for HackRF)\ncmake ../ -DUSE_BLADERF=1   (only for bladeRF)\n\nmake\n./btle-tools/src/btle_rx\n```\nAbove command sniffs on channel 37. You should see many packets on screen if you have BLE devices (phone/pad/laptop) around.\n```\n./btle-tools/src/btle_tx 37-DISCOVERY-TxAdd-1-RxAdd-0-AdvA-010203040506-LOCAL_NAME09-SDR/Bluetooth/Low/Energy r500 \n```\nAbove 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).\n\n**To have a faster operation sequence on HACKRF**, use following:\n```\n#define TRANSFER_COUNT 4\n#define TRANSFER_BUFFER_SIZE 4096\n```\nin 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.\n\n**Besides the tools, [matlab](matlab) directory includes algorithm evaluation and other useful scirpts**\n\nbtle_rx usage\n------------------\n```\n-h --help\n```\nPrint all arguments/usages.\n```\n-c --chan\n```\nChannel number. Default value 37 (one of ADV channels). Valid value 0~39 (all ADV and DATA channels).\n```\n-g --gain\n```\nRx 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.\n```\n-l --lnaGain\n```\nLNA gain in dB (HackRF only). Default 32, valid 0 - 40. Gain should be tuned very carefully to ensure best performance under your circumstance. \n```\n-b --amp\n```\nEnable amp (HackRF only). Default off.\n```\n-a --access\n```\nAccess address. Default 8e89bed6 for ADV channel 37 38 39. You should specify correct value for data channel according to captured connection setup procedure.\n```\n-k --crcinit\n```\nDefault 555555 for ADV channel. You should specify correct value for data channel according to captured connection setup procedure.\n```\n-v --verbose\n```\nVerbose mode. Print more information when there is error\n```\n-r --raw\n```\nRaw mode. After access addr is detected, print out following raw 42 bytes (without descrambling, parsing)\n```        \n-f --freq_hz (need argument)\n```\nThis frequency (Hz) will override channel setting (In case someone want to work on freq other than BTLE. More general purpose).\n```\n-m --access_mask (need argument)\n```\nIf 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).\n```\n-o --hop\n```\nThis will turn on data channel tracking (frequency hopping) after link setup information is captured in ADV_CONNECT_REQ packet on ADV channel.\n```\n-s --filename\n```\nStore packets to pcap file.\n\nbtle_tx usage\n------------------\n```\nbtle_tx packet1 packet2 ... packetX ...  rN\n```\nor \n```\nbtle_tx packets.txt\n```\npackets.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](host/btle-tools/src/packets.txt)\n```\npacketX \n```\nis one string which describes one packet. All packets compose a packets sequence.\n```\nrN\n```\nmeans the sequence will be repeated for N times. If it is not specified, the sequence will only be sent once.\n\npacketX string format\n```    \nchannel_number-packet_type-field-value-field-value-...-Space-value\n```\nEach 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**](#appendix-packet-descriptor-examples-of-btle_tx-for-all-formats) ), 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.\n\n**DO NOT** use space character \" \" in a command line packet descriptor. You CAN use space in the txt file packet descriptor.\n\n**DO NOT** use \"-\" inside each field. \"-\" is magic character which is used to separate different fields in packet descriptor. \n\n\n* **btle_tx example: [Discovery packets](host/btle-tools/src/packets_discovery.txt)**\n\nOpen LightBlue APP (or other BLE sniffer) in your iPhone/device before this command:\n```\n./btle-tools/src/btle_tx ../btle-tools/src/packets_discovery.txt\n```\nYou will see a device named as \"SDR Bluetooth Low Energy\" in your LightBlue APP.\n\nCorresponding Command line:\n```\n./btle-tools/src/btle_tx 37-DISCOVERY-TxAdd-1-RxAdd-0-AdvA-010203040506-LOCAL_NAME09-SDR/Bluetooth/Low/Energy r40\n``` \nNote: space \" \" is replaced by \"/\" because space \" \" is not supported in command line.\n\n\n* **btle_tx example: [Connection establishment](doc/TI-BLE-INTRODUCTION.pdf)**\n```\nbtle_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\n```\nAbove simulates a Connection establishment procedure between device 1 and device 2. Corresponding descriptor file [BTLE/host/btle-tools/src/packets.txt](host/btle-tools/src/packets.txt).\n\nThe 1st packet -- device 1 sends ADV_IND packet in channel 37.\n\nThe 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.\n\nThe 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 )\n\nTime space between packets are 1s (1000ms). Tune TI's packet sniffer to channel 37, then above establishment procedure will be captured.\n\n\n* **btle_tx example: [iBeacon](doc/ibeacon.pdf)**\n```\n./btle-tools/src/btle_tx 37-iBeacon-AdvA-010203040506-UUID-B9407F30F5F8466EAFF925556B57FE6D-Major-0008-Minor-0009-TxPower-C5-Space-100     r100\n```\nAbove command sends iBeacon packet and repeats it 100 times with 100ms time space. Corresponding descriptor file [BTLE/host/btle-tools/src/packets_ibeacon.txt](host/btle-tools/src/packets_ibeacon.txt). You can use a BLE sniffer dongle to see the packet.\n\nThe packet descriptor string:\n```\n37-iBeacon-AdvA-010203040506-UUID-B9407F30F5F8466EAFF925556B57FE6D-Major-0008-Minor-0009-TxPower-C5-Space-100\n```\n```\n37\n```\nchannel 37 (one of BTLE Advertising channel 37 38 39)\n```\niBeacon\n```\npacket format key word which means iBeacon format. (Actually it is ADV_IND format in Core_V4.0.pdf)\n```\nAdvA\n```\nAdvertising address (MAC address) which is set as 010203040506 (See Core_V4.0.pdf)\n```\nUUID\n```\nhere we specify it as Estimote’s fixed UUID: B9407F30F5F8466EAFF925556B57FE6D\n```\nMajor\n```\nmajor number of iBeacon format. (Here it is 0008)\n```\nMinor\n```\nminor number of iBeacon format. (Here it is 0009)\n```\nTxpower\n```\ntransmit power parameter of iBeacon format (Here it is C5)\n```\nSpace\n```\nHow many millisecond will be waited after this packet sent. (Here it is 100ms)\n \nDemos\n------------------\n\nSee a comparison with TI's packet sniffer here: [http://sdr-x.github.io/BTLE-SNIFFER/](http://sdr-x.github.io/BTLE-SNIFFER/)\n\nSee \u003ca href=\"https://youtu.be/9LDPhOF2yyw\"\u003ebtle_rx video demo\u003c/a\u003e or \u003ca href=\"https://vimeo.com/144574631\"\u003ebtle_rx video demo\u003c/a\u003e (in China) and \u003ca href=\"http://youtu.be/Y8ttV5AEb-g\"\u003ebtle_tx video demo 1\u003c/a\u003e or \u003ca href=\"http://v.youku.com/v_show/id_XNzUxMDIzNzAw.html\"\u003ebtle_tx video demo 2\u003c/a\u003e (in China)\n\n# Appendix: Packet descriptor examples of btle_tx for all formats\n------------------\n\nRAW packets: (All bits will be sent to GFSK modulator directly)\n```\n37-RAW-aad6be898e8dc3ce338c4cb1207730144f9474e0e15eedb378c3bc\n```\nADVERTISING CHANNEL packets (channel 37 for example):\n```\n37-IBEACON-AdvA-010203040506-UUID-B9407F30F5F8466EAFF925556B57FE6D-Major-0008-Minor-0009-TxPower-C5\n37-ADV_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-AdvData-00112233445566778899AABBCCDDEEFF\n37-ADV_DIRECT_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-InitA-0708090A0B0C\n37-ADV_NONCONN_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-AdvData-00112233445566778899AABBCCDDEEFF\n37-ADV_SCAN_IND-TxAdd-1-RxAdd-0-AdvA-010203040506-AdvData-00112233445566778899AABBCCDDEEFF\n37-SCAN_REQ-TxAdd-1-RxAdd-0-ScanA-010203040506-AdvA-0708090A0B0C\n37-SCAN_RSP-TxAdd-1-RxAdd-0-AdvA-010203040506-ScanRspData-00112233445566778899AABBCCDDEEFF\n37-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\n```\nDATA CHANNEL packets (channel 9 for example):\n```\n9-LL_DATA-AA-60850A1B-LLID-1-NESN-0-SN-0-MD-0-DATA-XX-CRCInit-A77B22\n9-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\n9-LL_CHANNEL_MAP_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-ChM-1FFFFFFFFF-Instant-0201-CRCInit-A77B22\n9-LL_TERMINATE_IND-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-ErrorCode-12-CRCInit-A77B22\n9-LL_ENC_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-Rand-0102030405060708-EDIV-090A-SKDm-0102030405060708-IVm-090A0B0C-CRCInit-A77B22\n9-LL_ENC_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-SKDs-0102030405060708-IVs-01020304-CRCInit-A77B22\n9-LL_START_ENC_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22\n9-LL_START_ENC_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22\n9-LL_UNKNOWN_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-UnknownType-01-CRCInit-A77B22\n9-LL_FEATURE_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-FeatureSet-0102030405060708-CRCInit-A77B22\n9-LL_FEATURE_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-FeatureSet-0102030405060708-CRCInit-A77B22\n9-LL_PAUSE_ENC_REQ-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22\n9-LL_PAUSE_ENC_RSP-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-CRCInit-A77B22\n9-LL_VERSION_IND-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-VersNr-01-CompId-0203-SubVersNr-0405-CRCInit-A77B22\n9-LL_REJECT_IND-AA-60850A1B-LLID-3-NESN-0-SN-0-MD-0-ErrorCode-00-CRCInit-A77B22\n```\nDiscovery packets: (which can show any name or services in scanner APP, such as LightBlue):\n```\n37-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)\n\nFLAGS: 0x01 LE Limited Discoverable Mode; 0x02 LE General Discoverable Mode\nSERVICE:\n0x02 16-bit Service UUIDs More 16-bit UUIDs available\n0x03 16-bit Service UUIDs Complete list of 16-bit UUIDs available\n0x04 32-bit Service UUIDs More 3a2-bit UUIDs available\n0x05 32-bit Service UUIDs Complete list of 32-bit UUIDs available\n0x06 128-bit Service UUIDs More 128-bit UUIDs available\n0x07 128-bit Service UUIDs Complete list of 128-bit UUIDs available\n```\n","funding_links":[],"categories":["\u003ca id=\"79499aeece9a2a9f64af6f61ee18cbea\"\u003e\u003c/a\u003e浏览嗅探\u0026\u0026流量拦截\u0026\u0026流量分析\u0026\u0026中间人","\u003ca id=\"7bf0f5839fb2827fdc1b93ae6ac7f53d\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"99398a5a8aaf99228829dadff48fb6a7\"\u003e\u003c/a\u003e未分类-Network","\u003ca id=\"32739127f0c38d61b14448c66a797098\"\u003e\u003c/a\u003e嗅探\u0026\u0026Sniff"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiaoxianjun%2Fbtle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiaoxianjun%2Fbtle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiaoxianjun%2Fbtle/lists"}