@rf24/rf24
    Preparing search index...

    Class FakeBle

    A class to use the nRF24L01 as a Fake BLE beacon.

    Note

    This implementation is subject to Limitations.

    Use bleConfig to properly configure the radio for BLE compatibility.

    import { bleConfig, FakeBle, RF24 } from "@rf24/rf24";

    const radio = new RF24(22, 0);
    radio.begin();
    radio.withConfig(bleConfig());
    const ble = new FakeBle(radio);

    radio.printDetails();
    Index

    Constructors

    • Create an Fake BLE device using the given RF24 instance.

      Parameters

      Returns FakeBle

    Accessors

    • get macAddress(): number[]

      Returns number[]

    • set macAddress(address: Uint8Array): void

      Set or get the BLE device's MAC address.

      A MAC address is required by BLE specifications. Use this attribute to uniquely identify the BLE device.

      Parameters

      • address: Uint8Array

      Returns void

    • get name(): string | null

      Returns string | null

    • set name(name: string): void

      Set or get the BLE device's name for included in advertisements.

      Setting a BLE device name will occupy more bytes from the 18 available bytes in advertisements. The exact number of bytes occupied is the length of the given name string plus 2.

      The maximum supported name length is 10 bytes. So, up to 12 bytes (10 + 2) will be used in the advertising payload.

      Parameters

      • name: string

      Returns void

    • get showPaLevel(): boolean

      Returns boolean

    • set showPaLevel(enable: number | boolean): void

      Enable or disable the inclusion of the radio's PA level in advertisements.

      Enabling this feature occupies 3 bytes of the 18 available bytes in advertised payloads.

      Parameters

      • enable: number | boolean

      Returns void

    Methods

    • Hop the radio's current channel to the next BLE compliant frequency.

      Use this function after FakeBle.send to comply with BLE specifications. This is not required, but it is recommended to avoid bandwidth pollution.

      This function should not be called in RX mode. To ensure proper radio behavior, the caller must ensure that the radio is in TX mode.

      Returns void

    • How many bytes are available in an advertisement payload?

      The hypothetical parameter shall be the same value passed to FakeBle.send.

      In addition to the given hypothetical payload length, this function also accounts for the current state of FakeBle.name and FakeBle.showPaLevel.

      If the returned value is less than 0, then the hypothetical payload will not be broadcasted.

      Parameters

      • hypothetical: Uint8Array

      Returns number

    • Read the first available payload from the radio's RX FIFO and decode it into a BlePayload.

      Warning

      The payload must be decoded while the radio is on the same channel that it received the data. Otherwise, the decoding process will fail.

      Use RF24.available to check if there is data in the radio's RX FIFO.

      If the payload was somehow malformed or incomplete, then this function returns an undefined value.

      Returns BlePayload | null

    • Send a BLE advertisement

      The buf parameter takes a buffer that has been already formatted for BLE specifications.

      See our convenient API to

      For a custom/proprietary BLE service, the given buf must adopt compliance with BLE specifications. For example, a buffer of n bytes shall be formed as follows:

      index value
      0 n - 1
      1 0xFF
      2 ... n - 1 custom data

      Parameters

      • buf: Uint8Array

      Returns boolean