Support us and view this ad

可选:点击以支持我们的网站

免费文章

1. Introduction: The Challenge of Real-Time AoA on BLE Bluetooth Low Energy (BLE) has evolved far beyond simple data streaming. With the introduction of the Bluetooth 5.1 Direction Finding feature, developers can now estimate the Angle of Arrival (AoA) of a signal, enabling sub-meter indoor positioning. However, the standard BLE protocol is not optimized for real-time, high-frequency AoA positioning. The 50 µs CTE (Constant Tone Extension) and the 1 Msym/s symbol rate create a narrow window for IQ sampling. On the nRF52840, the challenge is to design a custom GATT service that can stream IQ samples or computed angles with minimal latency, while coexisting with the BLE stack’s scheduling. This article dives into the design of a custom BLE GATT service that prioritizes low-latency, high-throughput AoA data for real-time tracking. We will cover the packet format, the state machine for CTE switching, a C code snippet for IQ sample collection, and a performance analysis of the system on the nRF52840. 2. Core Technical Principle: CTE Sampling and GATT Notifications The foundation of AoA positioning lies in the CTE. When a BLE packet is transmitted with a CTE, the nRF52840’s radio can be configured to sample the I/Q data of the carrier wave at a rate of 1 MHz. For a standard 50 µs CTE, you can collect up to 50 I/Q samples. The angle is then estimated from the phase difference between these samples across multiple antennas. The critical design decision is the GATT service architecture. Instead of a conventional "write-request-response" model, we use **notifications** with a high connection interval (7.5 ms) and a large ATT MTU (up to 247 bytes). The custom service will expose a single characteristic for AoA data. The key is to minimize the time between the radio’s CTE sample completion and the GATT notification dispatch. Packet Format for the Characteristic: Byte 0: Sequence Number (0-255) Byte 1: Timestamp LSB (1 ms resolution) Byte 2: Timestamp MSB Byte 3: CTE Length (µs) Byte 4-5: Antenna Switch Pattern ID Byte 6-7: Reserved for status flags Byte 8-9: I/Q Sample 0 (I8, Q8) Byte 10-11: I/Q Sample 1 ... Byte N-1: I/Q Sample 24 (max for 50 µs CTE) This format packs 25 I/Q samples (50 bytes) plus an 8-byte header into a 58-byte payload. With an ATT MTU of 247, we can send up to 4 such packets in a single notification, but we limit to 1 to reduce jitter. Timing Diagram (Conceptual): BLE Connection Event (every 7.5 ms) | +---> Radio Rx with CTE (30 µs) | | | +---> CTE Sampling (50 µs) | | | +---> IQ Buffer Full | +---> SWI Interrupt (highest priority) | | | +---> Copy IQ to GATT buffer | +---> Set notification pending flag | +---> BLE Stack (softdevice) processes notification (10-20 µs) | +---> Radio Tx: Notification packet (varies with payload size) The total latency from CTE end to notification over-the-air is approximately 80-100 µs, dominated by the BLE stack’s internal scheduling. 3. Implementation Walkthrough: C Code for IQ Collection and Notification Below is a C code snippet that runs on the nRF52840 under the Nordic SoftDevice. It configures the radio to receive a BLE packet with CTE, samples the IQ data, and triggers a GATT notification. The code assumes the use of the nRF5 SDK 17.1.0 and the ble_advdata and ble_srv_common libraries. #include "nrf.h" #include "nrf_radio.h" #include "nrf_gpio.h" #include "app_timer.h" #include "ble.h" #include "ble_srv_common.h" // Custom GATT service UUID (16-bit) #define BLE_UUID_AOA_SERVICE 0x1800 // Example, use a custom 128-bit UUID #define BLE_UUID_AOA_CHAR 0x2A6E static uint16_t m_conn_handle; static uint16_t m_aoa_char_handle; static uint8_t m_aoa_buffer[64]; static volatile bool m_notify_pending; // Radio configuration for CTE sampling void radio_init_for_cte(void) { NRF_RADIO->FREQUENCY = 8; // 2....

继续阅读完整内容

支持我们的网站,请点击查看下方广告

正在加载广告...

Login