Crate rf24ble

Source
Expand description

§rf24ble-rs

Crates.io Version docs.rs Crates.io MSRV CHANGELOG

This crate uses the rf24-rs crate to make the nRF24L01 imitate a Bluetooth-Low-Emissions (BLE) beacon. A BLE beacon can send data (referred to as advertisements) to any BLE compatible device (ie smart devices with Bluetooth 4.0 or later) that is listening.

Original research was done by Dmitry Grinberg and his write-up (including C source code) can be found here. As this technique can prove invaluable in certain project designs, the code here has been adapted to work with Rust.

§Example

See the example located in the nRF24/rf24-rs repository.

§Limitations

Because the nRF24L01 wasn’t designed for BLE advertising, it has some limitations that users should beware.

  1. The maximum payload length is shortened to 18 bytes (when not broadcasting a device name nor the radio’s PA level). This is calculated as:

    32 (nRF24L01 maximum) - 6 (MAC address) - 5 (required flags) - 3 (CRC checksum) = 18

    Use the helper function FakeBle::len_available() to determine if your payload will transmit.

  2. The channels that BLE use are limited to the following three:

    • 2.402 GHz
    • 2.426 GHz
    • 2.480 GHz.

    For convenience, use FakeBle::hop_channel() (when radio is in TX mode only) to switch between these frequencies.

  3. CRC length is disabled in the nRF24L01 firmware because BLE specifications require 3 bytes, and the nRF24L01 firmware can only handle a maximum of 2. Thus, we append the required 3 bytes of the calculated CRC24 into the payload.

  4. Address length of a BLE packet only uses 4 bytes.

  5. The auto-ack (automatic acknowledgment) feature of the nRF24L01 is useless when transmitting to BLE devices, thus the automatic re-transmit and custom ACK payloads features are useless because they both depend on the automatic acknowledgments feature.

  6. Dynamic payloads feature of the nRF24L01 isn’t compatible with BLE specifications.

  7. BLE specifications only allow using 1 Mbps RF data rate, so that too has been hard coded.

  8. Only the “on data sent” (tx_ds) & “on data ready” (rx_dr) events will have an effect on the interrupt (IRQ) pin. The “on data fail” is never triggered when the auto-ack feature is disabled.

Modules§

data_manipulation
A module that holds functions related to manipulating data in accordance with BLE specs.
services
A module to contain all compatible BLE services.

Structs§

BleChannels
A namespace of methods to manage the supported range of BLE channels.
FakeBle
A struct that implements BLE functionality.

Constants§

BLE_CHANNEL
The supported channels used amongst BLE devices.

Functions§

ble_config
Returns a RadioConfig object tailored for OTA compatibility with BLE specifications.