@rf24/rf24
Version:
A npm package binding the nRF24/rf24-rs rust project.
1,141 lines (1,125 loc) • 36.9 kB
TypeScript
/* auto-generated by NAPI-RS */
/* eslint-disable */
/**
* A BLE data service for broadcasting a battery's remaining charge (as a percentage).
*
* Conforms to Battery Level format as defined in
* [GATT Specifications Supplement](https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=502132&vId=542989).
*
* @group BLE Service Data Classes
*/
export declare class BatteryService {
constructor()
get data(): number
/** The battery charge level (as a percentage integer) data. */
set data(value: number)
/** Transform the service data into a BLE compliant buffer that is ready for broadcasting. */
get buffer(): Buffer
}
/** A structure to represent received BLE data. */
export declare class BlePayload {
/** The transmitting device's MAC address. */
get macAddress(): Buffer
/** The transmitting device's PA (Power Amplitude) level. */
get txPower(): number | null
/** The transmitting device's short name. */
get shortName(): string | null
/** The transmitting device's remaining battery charge level. */
get batteryCharge(): BatteryService | null
/** The transmitting device's temperature measurement. */
get temperature(): TemperatureService | null
/** The transmitting device's advertised URL. */
get url(): UrlService | null
}
/**
* A class to use the nRF24L01 as a Fake BLE beacon.
*
* > [!NOTE]
* > This implementation is subject to
* > [Limitations](https://docs.rs/rf24ble-rs/latest/rf24ble/index.html#limitations).
*
* Use {@link bleConfig} to properly configure the radio for
* BLE compatibility.
*
* ```ts
* 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();
* ```
*/
export declare class FakeBle {
/** Create an Fake BLE device using the given RF24 instance. */
constructor(radio: RF24)
/**
* 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.
*/
set name(name: string)
get name(): string | null
/**
* 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.
*/
set macAddress(address: Uint8Array)
get macAddress(): number[]
/**
* 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.
*/
set showPaLevel(enable: boolean | number)
get showPaLevel(): boolean
/**
* How many bytes are available in an advertisement payload?
*
* The `hypothetical` parameter shall be the same value passed to {@link FakeBle.send}.
*
* In addition to the given `hypothetical` payload length, this function also
* accounts for the current state of {@link FakeBle.name} and
* {@link FakeBle.showPaLevel}.
*
* If the returned value is less than `0`, then the `hypothetical` payload will not
* be broadcasted.
*/
lenAvailable(hypothetical: Uint8Array): number
/**
* Hop the radio's current channel to the next BLE compliant frequency.
*
* Use this function after {@link 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.
*/
hopChannel(): void
/**
* Send a BLE advertisement
*
* The `buf` parameter takes a buffer that has been already formatted for
* BLE specifications.
*
* See our convenient API to
* - advertise a Battery's remaining change level: {@link BatteryService}
* - advertise a Temperature measurement: {@link TemperatureService}
* - advertise a URL: {@link UrlService}
*
* 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 |
*/
send(buf: Uint8Array): boolean
/**
* Read the first available payload from the radio's RX FIFO
* and decode it into a {@link 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 {@link 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.
*/
read(): BlePayload | null
}
/** An object to configure the radio. */
export declare class RadioConfig {
/**
* Instantiate a {@link RadioConfig} object with library defaults.
*
* | feature | default value |
* |--------:|:--------------|
* | {@link RadioConfig.channel} | `76` |
* | {@link RadioConfig.addressLength} | `5` |
* | {@link RadioConfig.paLevel} | {@link PaLevel.Max} |
* | {@link RadioConfig.lnaEnable} | `true` |
* | {@link RadioConfig.crcLength} | {@link CrcLength.Bit16} |
* | {@link RadioConfig.dataRate} | {@link DataRate.Mbps1} |
* | {@link RadioConfig.payloadLength} | `32` |
* | {@link RadioConfig.dynamicPayloads} | `false` |
* | {@link RadioConfig.autoAck} | `0x3F` (enabled for pipes 0 - 5) |
* | {@link RadioConfig.ackPayloads} | `false` |
* | {@link RadioConfig.askNoAck} | `false` |
* | {@link RadioConfig.autoRetryDelay} | `5` |
* | {@link RadioConfig.autoRetryCount} | `15` |
* | {@link RadioConfig.txAddress} | `[0xE7, 0xE7, 0xE7, 0xE7, 0xE7]` |
* | {@link RadioConfig.getRxAddress} | See below table about [Default RX addresses](#default-rx-pipes-configuration) |
* | {@link RadioConfig.rxDr} | `true` |
* | {@link RadioConfig.txDs} | `true` |
* | {@link RadioConfig.txDf} | `true` |
*
* #### Default RX pipes' configuration
*
* | pipe number | state | address |
* |-------------|--------|-------------|
* | 0[^1] | closed | `[0xE7, 0xE7, 0xE7, 0xE7, 0xE7]` |
* | 1 | open | `[0xC2, 0xC2, 0xC2, 0xC2, 0xC2]` |
* | 2[^2] | closed | `0xC3` |
* | 3[^2] | closed | `0xC4` |
* | 4[^2] | closed | `0xC5` |
* | 5[^2] | closed | `0xC6` |
*
* [^1]: The RX address default value is the same as pipe 0 default TX address.
* [^2]: Remember, pipes 2 - 5 share the same 4 LSBytes as the address on pipe 1.
*/
constructor()
get channel(): number
/**
* Set the channel (over the air frequency).
*
* This value is clamped to range [0, 125].
* The radio's frequency can be determined by the following equation:
* ```text
* frequency (in Hz) = channel + 2400
* ```
*/
set channel(value: number)
get payloadLength(): number
/**
* The payload length for statically sized payloads.
*
* This value can not be set larger than 32 bytes.
* See {@link RF24.payloadLength | `RF24.payloadLength()`}.
*/
set payloadLength(value: number)
get addressLength(): number
/**
* The address length.
*
* This value is clamped to range [2, 5].
*/
set addressLength(value: number)
get crcLength(): CrcLength
/**
* The Cyclical Redundancy Checksum (CRC) length.
*
* See {@link RF24.crcLength}.
*/
set crcLength(value: CrcLength)
get paLevel(): PaLevel
/**
* The Power Amplitude (PA) level.
*
* See {@link RF24.paLevel | `RF24.paLevel()`}.
*/
set paLevel(value: PaLevel)
get lnaEnable(): boolean
/**
* Enable or disable the chip's Low Noise Amplifier (LNA) feature.
*
* This value may not be respected depending on the radio module used.
* Consult the radio's manufacturer for accurate details.
*/
set lnaEnable(value: boolean | number)
get dataRate(): DataRate
/**
* The Data Rate (over the air).
*
* See {@link RF24.dataRate}.
*/
set dataRate(value: DataRate)
get autoAck(): number
/**
* Enable or disable auto-ACK feature.
*
* The given value (in binary form) is used to control the auto-ack feature for each pipe.
* Bit 0 controls the feature for pipe 0. Bit 1 controls the feature for pipe 1. And so on.
*
* To enable the feature for pipes 0, 1 and 4:
* ```js
* let config = new RadioConfig();
* config.auto_ack = 0b010011;
* ```
* If enabling the feature for any pipe other than 0, then the pipe 0 should also have the
* feature enabled because pipe 0 is used to transmit automatic ACK packets in RX mode.
*/
set autoAck(value: number)
/**
* The auto-retry feature's `delay` set by
* {@link RadioConfig.setAutoRetries}.
*/
get autoRetryDelay(): number
/**
* The auto-retry feature's `count` set by
* {@link RadioConfig.setAutoRetries}.
*/
get autoRetryCount(): number
/**
* Set the auto-retry feature's `delay` and `count` parameters.
*
* See {@link RF24.setAutoRetries}.
*/
setAutoRetries(delay: number, count: number): void
get dynamicPayloads(): boolean
/**
* Enable or disable dynamically sized payloads.
*
* Enabling this feature nullifies the utility of {@link RadioConfig.payloadLength}.
*
* This feature is enabled automatically when enabling ACK payloads
* via {@link RadioConfig.ackPayloads}.
*/
set dynamicPayloads(value: boolean | number)
get ackPayloads(): boolean
/**
* Enable or disable custom ACK payloads for auto-ACK packets.
*
* ACK payloads require the {@link RadioConfig.autoAck}
* and {@link RadioConfig.dynamicPayloads}
* to be enabled. If ACK payloads are enabled, then this function also enables those
* features (for all pipes).
*/
set ackPayloads(value: boolean | number)
get askNoAck(): boolean
/**
* Allow disabling auto-ack per payload.
*
* See `askNoAck` parameter for
* {@link RF24.send} and {@link RF24.write} ({@link WriteConfig.askNoAck}).
*/
set askNoAck(value: boolean | number)
get rxDr(): boolean
/**
* Enable or disable the "RX Data Ready" event triggering the radio's IRQ.
*
* See {@link StatusFlags.rxDr}.
*/
set rxDr(value: boolean | number)
get txDs(): boolean
/**
* Enable or disable the "TX Data Sent" event triggering the radio's IRQ.
*
* See {@link StatusFlags.txDs}.
*/
set txDs(value: boolean | number)
get txDf(): boolean
/**
* Enable or disable the "TX Data Failed" event triggering the radio's IRQ.
*
* See {@link StatusFlags.txDf}.
*/
set txDf(value: boolean | number)
/**
* Is a specified RX pipe open (`true`) or closed (`false`)?
*
* The value returned here is controlled by
* {@link RadioConfig.setRxAddress} (to open a pipe)
* and {@link RadioConfig.closeRxPipe}.
*/
isRxPipeEnabled(pipe: number): boolean
/**
* Set the address of a specified RX `pipe` for receiving data.
*
* This does nothing if the given `pipe` is greater than `8`.
* For pipes 2 - 5, the 4 LSBytes are used from address set to pipe 1 with the
* MSByte from the given `address`.
*
* See also {@link RadioConfig.txAddress}.
*/
setRxAddress(pipe: number, address: Buffer): void
/** Get the address for a specified `pipe` set by {@link RadioConfig.setRxAddress}. */
getRxAddress(pipe: number): Buffer
/**
* Set the TX address.
*
* Only pipe 0 can be used for TX operations (including auto-ACK packets during RX operations).
*/
set txAddress(value: Buffer)
get txAddress(): Buffer
/**
* Close a RX pipe from receiving data.
*
* This is only useful if pipe 1 should be closed instead of open
* (after constructing {@link RadioConfig}).
*/
closeRxPipe(pipe: number): void
}
/** This class provides the user facing API to interact with a nRF24L01 transceiver. */
export declare class RF24 {
/**
* Construct an object to control the radio.
*
* @param cePin - The GPIO pin number connected to the radio's CE pin.
* @param csPin - The identifying number for the SPI bus' CS pin;
* also labeled as "CEx" (where "x" is this parameter's value) on many
* Raspberry Pi pin diagrams. See {@link HardwareConfig.devSpiBus} for more detail.
* @param hardwareConfig - Optional parameters to fine tune hardware configuration
* (like SPI bus number and GPIO chip number).
*
* @group Basic
*/
constructor(cePin: number, csPin: number, hardwareConfig?: HardwareConfig | undefined | null)
/**
* Initialize the radio on the configured hardware (as specified to {@link RF24} constructor).
*
* @throws A Generic Error if a hardware failure caused problems
* (includes a message to describe what problem was detected).
*
* This is the same as {@link RF24.withConfig},
* but this function also
*
* - detects if the radio is a plus variant ({@link RF24.isPlusVariant})
* - checks for data corruption across the SPI lines (MOSI, MISO, SCLK)
*
* @group Basic
*/
begin(): void
/**
* Reconfigure the radio with the specified `config`.
*
* > [!WARNING]
* > It is strongly encouraged to call {@link RF24.begin}
* > after constructing the RF24 object.
* >
* > Only use this function subsequently to quickly switch between different
* > network settings.
*
* @group Configuration
*/
withConfig(config: RadioConfig): void
/**
* Set the radio's CE pin HIGH (`true`) or LOW (`false`).
*
* This is only exposed for advanced use of TX FIFO during
* asynchronous TX operations. It is highly encouraged to use
* {@link RF24.asRx} or {@link RF24.asTx}
* to ensure proper radio behavior when entering RX or TX mode.
*
* @group Advanced
*/
cePin(value: boolean | number): void
/**
* Is the radio in active RX mode?
*
* @group Basic
*/
get isRx(): boolean
/**
* Put the radio into active RX mode.
*
* Conventionally, this should be called after setting the RX addresses via
* {@link RF24.openRxPipe}.
*
* This function will restore the cached RX address set to pipe 0.
* This is done because the {@link RF24.asTx} will appropriate the
* RX address on pipe 0 for auto-ack purposes.
*
* @group Basic
*/
asRx(): void
/**
* Puts the radio into an inactive TX mode.
*
* This must be called at least once before calling {@link RF24.send} or
* {@link RF24.write}.
*
* For auto-ack purposes, this function will also restore
* the cached `txAddress` to the RX pipe 0.
*
* The datasheet recommends idling the radio in an inactive TX mode.
*
* > [!NOTE]
* > This function will also flush the TX FIFO when ACK payloads are enabled
* > (via {@link RF24.ackPayloads}).
*
* @param txAddress - If specified, then this buffer will be
* cached and set as the new TX address.
*
* @group Basic
*/
asTx(txAddress?: Buffer | undefined | null): void
/**
* Blocking function that loads a given `buf` into the TX FIFO, waits for a response
* (if auto-ack is enabled), then returns a Boolean describing success.
*
* @param buf - The buffer of bytes to transmit.
* @param askNoAck - A flag to disable the auto-ack feature for the given payload in `buf`.
* This has no effect if auto-ack is disabled or
* {@link RF24.allowAskNoAck} is not enabled.
*
* @returns A boolean that describes if transmission is successful or not.
* This will always return true if auto-ack is disabled.
*
* @group Basic
*/
send(buf: Buffer, askNoAck?: boolean | number): boolean
/**
* A non-blocking function that uploads a given `buf` to the radio's TX FIFO.
*
* This is a helper function to {@link RF24.send}.
* Use this in combination with {@link RF24.update} and
* {@link RF24.getStatusFlags}
* to determine if transmission was successful.
*
* @param buf - The buffer of bytes to load into the TX FIFO.
*
* @returns A Boolean that describes if the given `buf` was successfully loaded
* into the TX FIFO. Remember, the TX FIFO has only 3 levels ("slots").
*
* @group Advanced
*/
write(buf: Buffer, writeConfig?: WriteConfig | undefined | null): boolean
/**
* Read data from the radio's RX FIFO.
*
* Use {@link RF24.available} to determine if there is data ready to read from the RX FIFO.
*
* @param len - An optional number of bytes to read from the FIFO. This is capped at `32`.
* If not specified, then the length of the next available payload is used (which automatically
* respects if dynamic payloads are enabled).
*
* Use {@link RF24.dynamicPayloads} for dynamically sized
* payload or {@link RF24.payloadLength} for statically sized
* payloads.
*
* @group Basic
*/
read(len?: number | undefined | null): Buffer
/**
* A blocking function to resend a failed payload in the TX FIFO.
*
* This is similar to {@link RF24.send} but specifically for
* failed transmissions.
*
* @group Basic
*/
resend(): boolean
/**
* A non-blocking function to restart a failed transmission.
*
* This is a helper function to {@link RF24.resend}.
* Use {@link RF24.update} and
* {@link RF24.getStatusFlags} to determine if
* retransmission was successful.
*
* @group Advanced
*/
rewrite(): void
/**
* Get the Automatic Retry Count (ARC) of attempts made during the last transmission.
*
* This resets with every new transmission. The returned value is meaningless if the
* auto-ack feature is disabled.
*
* Use {@link RF24.setAutoRetries} to configure the
* automatic retries feature.
*
* @group Advanced
*/
getLastArc(): number
/**
* Is this radio a nRF24L01+ variant?
*
* The bool that this attribute returns is only valid _after_ calling
* {@link RF24.begin}.
*
* @group Configuration
*/
get isPlusVariant(): boolean
/**
* Was the Received Power Detection (RPD) trigger?
*
* This flag is asserted during an RX session (after a mandatory 130 microseconds
* duration) if a signal stronger than -64 dBm was detected.
*
* Note that if a payload was placed in RX mode, then that means
* the signal used to transmit that payload was stronger than either
*
* * -82 dBm in 2 Mbps {@link DataRate}
* * -85 dBm in 1 Mbps {@link DataRate}
* * -94 dBm in 250 Kbps {@link DataRate}
*
* Sensitivity may vary based of the radio's model and manufacturer.
* The information above is stated in the nRF24L01+ datasheet.
*
* @group Advanced
*/
get rpd(): boolean
/**
* Start a constant carrier wave
*
* This functionality is meant for hardware tests (in conjunction with {@link RF24.rpd}).
* Typically, this behavior is required by government agencies to enforce regional restrictions.
*
* @param level - The Power Amplitude level to use when transmitting.
* @param channel - The channel (radio's frequency) used to transmit.
* The channel should not be changed while transmitting because it can cause
* undefined behavior.
*
* @group Advanced
*/
startCarrierWave(level: PaLevel, channel: number): void
/**
* Stop the constant carrier wave started via {@link RF24.startCarrierWave}.
*
* This function leaves the radio in a configuration that may be undesired or
* unexpected because of the setup involved in {@link RF24.startCarrierWave}.
* The {@link PaLevel} and `channel` passed to {@link RF24.startCarrierWave} are
* still set.
* If {@link RF24.isPlusVariant} returns `true`, the following features are all disabled:
*
* - auto-ack
* - CRC
* - auto-retry
*
* @group Advanced
*/
stopCarrierWave(): void
/**
* Enable or disable the LNA feature.
*
* This is enabled by default (regardless of chip variant).
* See {@link PaLevel} for effective behavior.
*
* On nRF24L01+ modules with a builtin antenna, this feature is always enabled.
* For clone's and module's with a separate PA/LNA circuit (external antenna),
* this function may not behave exactly as expected. Consult the radio module's
* manufacturer.
*
* @group Configuration
*/
setLna(enable: boolean | number): void
/**
* Enable or disable the custom ACK payloads attached to auto-ack packets.
*
* > [!IMPORTANT]
* > This feature requires dynamically sized payloads.
* > This attribute will enable {@link RF24.dynamicPayloads}
* > automatically when needed. This attribute will not disable
* > {@link RF24.dynamicPayloads}.
*
* @group Configuration
*/
set ackPayloads(enable: boolean | number)
/** @group Configuration */
get ackPayloads(): boolean
/**
* Enable or disable the auto-ack feature for all pipes.
*
* > [!NOTE]
* > This feature requires CRC to be enabled.
* > See {@link RF24.crcLength} for more detail.
*
* @group Configuration
*/
setAutoAck(enable: boolean | number): void
/**
* Enable or disable the auto-ack feature for a specified `pipe`.
*
* @group Configuration
*/
setAutoAckPipe(enable: number, pipe: number): void
/**
* Allow disabling the auto-ack feature for individual payloads.
*
* @param enable - Setting this to `true` will allow the `askNoAck` parameter to
* take effect. See {@link RF24.send} and
* {@link WriteConfig.askNoAck} for more detail.
*
* @group Configuration
*/
allowAskNoAck(enable: boolean | number): void
/**
* Upload a given ACK packet's payload (`buf`) into the radio's TX FIFO.
*
* This feature requires {@link RF24.ackPayloads}
* to be enabled.
*
* @param pipe - The pipe number that (when data is received) will be responded
* with the given payload (`buf`).
* @param buf - The payload to attach to the auto-ack packet when responding to
* data received on specified `pipe`.
*
* @returns A boolean value that describes if the payload was successfully uploaded
* to the TX FIFO. Remember, the TX FIFO only has 3 levels ("slots").
*
* @group Advanced
*/
writeAckPayload(pipe: number, buf: Buffer): boolean
/**
* Configure the automatic retry feature.
*
* This feature is part of the auto-ack feature, thus the auto-ack feature is
* required for this function to have any effect.
*
* @param delay - This value is clamped to the range [0, 15]. This value is
* translated to microseconds with the formula `250 + (delay * 250) = microseconds`.
* Meaning, the effective range of `delay` is [250, 4000].
* @param count - The number of attempt to retransmit when no ACK packet was
* received (after transmitting). This value is clamped to the range [0, 15].
*
* @group Configuration
*/
setAutoRetries(delay: number, count: number): void
/**
* Set the channel (frequency) that the radio uses to transmit and receive.
*
* @param channel - This value is clamped to the range [0, 125].
*
* This value can be roughly translated into a frequency with the formula:
* ```text
* frequency (in Hz) = channel + 2400
* ```
*
* @group Basic
*/
set channel(channel: number)
/** @group Basic */
get channel(): number
/** @group Configuration */
get crcLength(): CrcLength
/**
* Get/set the {@link CrcLength} used for all outgoing and incoming
* transmissions.
*
* > [!NOTE]
* > If disabled ({@link CrcLength.Disabled})
* > while auto-ack feature is enabled, then this function's returned value does not reflect
* > the fact that CRC is forcefully enabled by the radio's firmware (needed by the
* > auto-ack feature).
*
* @group Configuration
*/
set crcLength(crcLength: CrcLength)
/** @group Configuration */
get dataRate(): DataRate
/**
* Get/set the {@link DataRate} used for all incoming and outgoing transmissions.
*
* @group Configuration
*/
set dataRate(dataRate: DataRate)
/**
* Is there a payload available in the RX FIFO?
*
* Use {@link RF24.read} to get the payload data.
*
* @group Basic
*/
available(): boolean
/**
* Similar to {@link RF24.available} but also returns the
* pipe that received the next available payload.
*
* @group Basic
*/
availablePipe(): AvailablePipe
/**
* Discard all 3 levels of the radio's RX FIFO.
*
* @group Advanced
*/
flushRx(): void
/**
* Discard all 3 levels of the radio's TX FIFO.
*
* This is automatically called by {@link RF24.asTx}
* when ACK payloads are enabled (via {@link RF24.ackPayloads}).
*
* @group Advanced
*/
flushTx(): void
/**
* Get the state of the specified FIFO.
*
* @param aboutTx - True returns data about the TX FIFO.
* False returns data about the RX FIFO.
*
* @group Advanced
*/
getFifoState(aboutTx: boolean | number): FifoState
/** @group Configuration */
get paLevel(): PaLevel
/**
* Get/set the Power Amplitude (PA) level used for all transmissions (including
* auto ack packet).
*
* @param paLevel - The {@link PaLevel} to use.
*
* @group Configuration
*/
set paLevel(paLevel: PaLevel)
/**
* Get/set the statically sized payload length.
*
* This configuration is not used if dynamic payloads are enabled.
* Use {@link RF24.getDynamicPayloadLength}
* instead if dynamically sized payloads are enabled (via
* {@link RF24.dynamicPayloads}).
*
* @group Configuration
*/
set payloadLength(length: number)
/** @group Configuration */
get payloadLength(): number
/**
* Enable or disable the dynamically sized payloads feature.
*
* @param enable - If set to `true`, the statically sized payload length (set via
* {@link RF24.payloadLength}) are not used.
*
* @group Configuration
*/
set dynamicPayloads(enable: boolean | number)
/** @group Configuration */
get dynamicPayloads(): boolean
/**
* Get the length of the next available payload in the RX FIFO.
*
* If dynamically sized payloads are not enabled (via
* {@link RF24.dynamicPayloads}), then use {@link RF24.payloadLength}.
*
* @group Advanced
*/
getDynamicPayloadLength(): number
/**
* Open a specific pipe for receiving from the given address.
*
* It is highly recommended to avoid using pipe 0 to receive because it is also
* used to transmit automatic acknowledgements.
*
* > [!NOTE]
* > Only pipes 0 and 1 actually use up to 5 bytes of the given address.
* > Pipes 2 - 5 only use the first byte of the given address and last 4
* > bytes of the address set to pipe 1.
*
* @param pipe - The pipe number to receive data. This must be in range [0, 5],
* otherwise this function does nothing.
* @param address - The address to receive data from.
*
* @group Basic
*/
openRxPipe(pipe: number, address: Buffer): void
/**
* Close the specified pipe from receiving transmissions.
*
* Use {@link RF24.openRxPipe} to set the address for a
* specific pipe.
*
* @param pipe - The pipe to close. This must be in range [0, 5], otherwise this function
* does nothing.
*
* @group Basic
*/
closeRxPipe(pipe: number): void
/**
* Set the address length (applied to all pipes).
*
* @param length - The address length is clamped to the range [2, 5].
*
* @group Configuration
*/
set addressLength(length: number)
/** @group Configuration */
get addressLength(): number
/** @group Configuration */
get power(): boolean
/**
* Control the radio's powered level.
*
* This is just a convenience attribute that calls {@link RF24.powerUp}
* or {@link RF24.powerDown}.
*
* Use {@link RF24.isRx} to determine if the radio is in RX or TX mode.
*
* @group Configuration
*/
set power(enable: number)
/**
* Power Down the radio.
*
* No transmissions can be received when the radio is powered down.
*
* @group Configuration
*/
powerDown(): void
/**
* Power up the radio.
*
* @param delay - The number of nanoseconds to wait for the radio to finish
* powering up. If not specified, the default wait time defaults to 5 milliseconds.
*
* @group Configuration
*/
powerUp(delay?: number | undefined | null): void
/** @group Configuration */
get txDelay(): number
/**
* The driver will delay for this duration (32 bit unsigned int of microseconds)
* when {@link RF24.asTx} is called.
*
* If the auto-ack feature is disabled, then this can be set as low as 0.
* If the auto-ack feature is enabled, then set to 100 microseconds minimum on
* generally faster devices (like RPi).
*
* This value cannot be negative.
*
* Since this value can be optimized per the radio's data rate, this value is
* automatically adjusted when changing {@link RF24.dataRate}.
* If setting this to a custom value be sure, to set it *after*
* changing the radio's data rate.
*
* > [!WARNING]
* > If set to 0, then the concurrent outgoing ACK packet (when auto-ack is enabled)
* > may fail to transmit when exiting RX mode with {@link RF24.asTx}.
*
* @group Configuration
*/
set txDelay(value: number)
/**
* Configure the IRQ pin to reflect the specified {@link StatusFlags}.
*
* @param flags - If no value is given, then all flags are reflected by the IRQ pin.
*
* @group Configuration
*/
setStatusFlags(flags?: StatusFlags | undefined | null): void
/**
* Reset the specified {@link StatusFlags}.
*
* @param flags - If no value is given, then all flags are reset.
*
* @group Advanced
*/
clearStatusFlags(flags?: StatusFlags | undefined | null): void
/**
* Update the cached value of Status flags.
*
* Use {@link RF24.getStatusFlags} to get the updated values.
*
* @group Advanced
*/
update(): void
/**
* Get the current state of the {@link StatusFlags}.
*
* > [!NOTE]
* > This function simply returns the value of the flags that was cached
* > from the last SPI transaction. It does not actually update the values
* > (from the radio) before returning them.
* >
* > Use {@link RF24.update} to update them first.
*
* @group Advanced
*/
getStatusFlags(): StatusFlags
/**
* Print helpful debug information to stdout.
*
* @group Configuration
*/
printDetails(): void
}
/**
* A BLE data service that broadcasts a temperature (in Celsius)
*
* Conforms to the Health Thermometer Measurement format as defined in
* [GATT Specifications Supplement](https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=502132&vId=542989).
*
* @group BLE Service Data Classes
*/
export declare class TemperatureService {
constructor()
get data(): number
/** The temperature measurement (in Celsius) data. */
set data(value: number)
/** Transform the service data into a BLE compliant buffer that is ready for broadcasting. */
get buffer(): Buffer
}
/**
* A BLE data service for broadcasting a URL.
*
* Conforms to specifications defined by [Google's EddyStone][eddystone] data format.
*
* [eddystone]: https://github.com/google/eddystone
*
* @group BLE Service Data Classes
*/
export declare class UrlService {
constructor()
get paLevel(): number
/** The predicted PA (Power Amplitude) level at 1 meter radius. */
set paLevel(value: number)
get data(): string
/** The URL to be broadcasted. */
set data(value: string)
/** Transform the service data into a BLE compliant buffer that is ready for broadcasting. */
get buffer(): Buffer
}
/** The return type for {@link RF24.availablePipe} */
export interface AvailablePipe {
/** Is RX data available in the RX FIFO? */
available: boolean
/**
* The pipe number that received the next available payload in the RX FIFO.
*
* This shall be considered an invalid value if `available` is false.
*/
pipe: number
}
/**
* Returns a {@link RadioConfig} object tailored for
* OTA compatibility with BLE specifications.
*
* > [!NOTE]
* > This configuration complies with inherent
* > [Limitations](https://docs.rs/rf24ble-rs/latest/rf24ble/index.html#limitations).
*/
export declare function bleConfig(): RadioConfig
/**
* The length of a CRC checksum that is used (if any).
*
* Cyclical Redundancy Checking (CRC) is commonly used to ensure data integrity.
*/
export declare const enum CrcLength {
/** Represents no CRC checksum is used */
Disabled = 0,
/** Represents CRC 8 bit checksum is used */
Bit8 = 1,
/** Represents CRC 16 bit checksum is used */
Bit16 = 2
}
/** How fast data moves through the air. Units are in bits per second (bps). */
export declare const enum DataRate {
/** Represents 1 Mbps */
Mbps1 = 0,
/** Represents 2 Mbps */
Mbps2 = 1,
/** Represents 250 Kbps */
Kbps250 = 2
}
/** The possible states of a FIFO. */
export declare const enum FifoState {
/** Represent the state of a FIFO when it is full. */
Full = 0,
/** Represent the state of a FIFO when it is empty. */
Empty = 1,
/** Represent the state of a FIFO when it is not full but not empty either. */
Occupied = 2
}
/**
* Optional configuration parameters to fine tune instantiating the {@link RF24} object.
* Pass this object as third parameter to {@link RF24} constructor.
*/
export interface HardwareConfig {
/**
* The GPIO chip number: `/dev/gpiochipN` where `N` is this value.
*
* @defaultValue `0`, but needs to be `4` on RPi5 (or newer).
* This may also need to be specified for nVidia's hardware offerings.
*/
devGpioChip?: number
/**
* The SPI bus number: `/dev/spidevX.Y` where `X` is this value
* and `Y` is the `csPin` required parameter to {@link RF24} constructor
*
* @defaultValue `0`, but can be as high as `3` depending on the number of
* SPI buses available/exposed on the board.
*/
devSpiBus?: number
/**
* The SPI speed in Hz used to communicate with the nRF24L01 over SPI.
*
* @defaultValue `10000000` (10 MHz) which is the radio's maximum
* supported speed. Lower this to 6 or 4 MHz when using long wires or
* if builtin pull-up resistors are weak.
*/
spiSpeed?: number
}
/**
* Power Amplifier level. The units dBm (decibel-milliwatts or dB<sub>mW</sub>)
* represents a logarithmic signal loss.
*/
export declare const enum PaLevel {
/**
* | nRF24L01 | Si24R1 with<br>LNA Enabled | Si24R1 with<br>LNA Disabled |
* |:--------:|:--------------------------:|:---------------------------:|
* | -18 dBm | -6 dBm | -12 dBm |
*/
Min = 0,
/**
* | nRF24L01 | Si24R1 with<br>LNA Enabled | Si24R1 with<br>LNA Disabled |
* |:--------:|:--------------------------:|:---------------------------:|
* | -12 dBm | 0 dBm | -4 dBm |
*/
Low = 1,
/**
* | nRF24L01 | Si24R1 with<br>LNA Enabled | Si24R1 with<br>LNA Disabled |
* |:--------:|:--------------------------:|:---------------------------:|
* | -6 dBm | 3 dBm | 1 dBm |
*/
High = 2,
/**
* | nRF24L01 | Si24R1 with<br>LNA Enabled | Si24R1 with<br>LNA Disabled |
* |:--------:|:--------------------------:|:---------------------------:|
* | 0 dBm | 7 dBm | 4 dBm |
*/
Max = 3
}
/**
* The return type for {@link RF24.getStatusFlags}
* and optional parameters for {@link RF24.setStatusFlags}
* and {@link RF24.clearStatusFlags}.
*/
export interface StatusFlags {
/**
* A flag to describe if RX Data Ready to read.
*
* @defaultValue `false`
*/
rxDr?: boolean
/**
* A flag to describe if TX Data Sent.
*
* @defaultValue `false`
*/
txDs?: boolean
/**
* A flag to describe if TX Data Failed.
*
* @defaultValue `false`
*/
txDf?: boolean
}
/** An optional configuration for {@link RF24.write} */
export interface WriteConfig {
/**
* Set to `true` if you want to disable auto-ACK feature for the individual
* payload (required `buf` parameter to {@link RF24.write}).
*
* @defaultValue `false`. Be sure to set {@link RF24.allowAskNoAck} to `true`
* at least once beforehand, otherwise this option will have no affect at all.
*/
askNoAck?: boolean
/**
* Set to `true` to assert the radio's CE pin (and begin active TX mode) after the payload is
* uploaded to the TX FIFO.
*
* Only set this to false if filling the TX FIFO (maximum 3 level stack) before entering
* active TX mode. Setting this option to false does not deactivate the radio's CE pin.
*
* @defaultValue `true`
*/
startTx?: boolean
}