Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/nextest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ slow-timeout = "10s"
# This is all tests in tests/ folder + unit test for --extra-args.
default-filter = "all()"

# show wich tests were skipped
# show which tests were skipped
status-level = "skip"

# show log output from each test
Expand Down
14 changes: 7 additions & 7 deletions bindings/node/src/radio/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use napi::{bindgen_prelude::Buffer, JsNumber, Result};
#[derive(Debug, Clone, Copy)]
pub struct RadioConfig {
inner: rf24::radio::RadioConfig,
_addr_buf: [u8; 5],
addr_buf: [u8; 5],
}

#[napi]
Expand Down Expand Up @@ -53,7 +53,7 @@ impl RadioConfig {
pub fn new() -> Self {
Self {
inner: rf24::radio::RadioConfig::default(),
_addr_buf: [0u8; 5],
addr_buf: [0u8; 5],
}
}

Expand Down Expand Up @@ -344,8 +344,8 @@ impl RadioConfig {
/// Get the address for a specified `pipe` set by {@link RadioConfig.setRxAddress}.
#[napi]
pub fn get_rx_address(&mut self, pipe: u8) -> Buffer {
self.inner.rx_address(pipe, &mut self._addr_buf);
Buffer::from(self._addr_buf.to_vec())
self.inner.rx_address(pipe, &mut self.addr_buf);
Buffer::from(self.addr_buf.to_vec())
}

/// Set the TX address.
Expand All @@ -359,8 +359,8 @@ impl RadioConfig {

#[napi(getter, js_name = "txAddress")]
pub fn get_tx_address(&mut self) -> Buffer {
self.inner.tx_address(&mut self._addr_buf);
Buffer::from(self._addr_buf.to_vec())
self.inner.tx_address(&mut self.addr_buf);
Buffer::from(self.addr_buf.to_vec())
}

/// Close a RX pipe from receiving data.
Expand All @@ -381,7 +381,7 @@ impl RadioConfig {
pub fn from_inner(config: rf24::radio::RadioConfig) -> Self {
Self {
inner: config,
_addr_buf: [0u8; 5],
addr_buf: [0u8; 5],
}
}
}
15 changes: 14 additions & 1 deletion bindings/node/src/radio/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,10 @@ impl RF24 {

/// Put the radio into active RX mode.
///
/// 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
#[napi]
pub fn as_rx(&mut self) -> Result<()> {
Expand All @@ -212,6 +216,15 @@ impl RF24 {
/// > This function will also flush the TX FIFO when ACK payloads are enabled
/// > (via {@link RF24.ackPayloads}).
///
/// This must be called at least once before calling
/// {@link RF24.send} or {@link RF24.write}.
/// Conventionally, this should be called before setting the TX address via
/// {@link RF24.openTxPipe}.
///
/// For auto-ack purposes, this function will also restore the cached
/// TX address (passed to {@link RF24.openTxPipe})
/// to the RX pipe 0.
///
/// @group Basic
#[napi]
pub fn as_tx(&mut self) -> Result<()> {
Expand Down Expand Up @@ -766,7 +779,7 @@ impl RF24 {
/// Only pipe 0 can be used for transmitting. It is highly recommended to
/// avoid using pipe 0 to receive because of this.
///
/// @param address - The address to receive data from.
/// @param address - The address to transmit data to.
///
/// @group Basic
#[napi]
Expand Down
14 changes: 7 additions & 7 deletions bindings/python/src/radio/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ use std::borrow::Cow;
#[derive(Debug, Clone, Copy)]
pub struct RadioConfig {
inner: rf24::radio::RadioConfig,
_addr_buf: [u8; 5],
addr_buf: [u8; 5],
}

#[pymethods]
Expand All @@ -53,7 +53,7 @@ impl RadioConfig {
pub fn new() -> Self {
Self {
inner: rf24::radio::RadioConfig::default(),
_addr_buf: [0u8; 5],
addr_buf: [0u8; 5],
}
}

Expand Down Expand Up @@ -305,17 +305,17 @@ impl RadioConfig {

/// Get the address for a specified `pipe` set by [`RadioConfig.set_rx_address()`][rf24_py.RadioConfig.set_rx_address].
pub fn get_rx_address(&mut self, pipe: u8) -> Cow<[u8]> {
self.inner.rx_address(pipe, &mut self._addr_buf);
Cow::from(&self._addr_buf)
self.inner.rx_address(pipe, &mut self.addr_buf);
Cow::from(&self.addr_buf)
}

/// Set the TX address.
///
/// Only pipe 0 can be used for TX operations (including auto-ACK packets during RX operations).
#[getter]
pub fn get_tx_address(&mut self) -> Cow<[u8]> {
self.inner.tx_address(&mut self._addr_buf);
Cow::from(&self._addr_buf)
self.inner.tx_address(&mut self.addr_buf);
Cow::from(&self.addr_buf)
}

#[setter]
Expand All @@ -339,7 +339,7 @@ impl RadioConfig {
pub fn from_inner(config: rf24::radio::RadioConfig) -> Self {
Self {
inner: config,
_addr_buf: [0u8; 5],
addr_buf: [0u8; 5],
}
}
}
16 changes: 15 additions & 1 deletion bindings/python/src/radio/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ impl RF24 {
}

/// Put the radio into active RX mode.
///
/// This function will restore the cached RX address set to pipe 0.
/// This is done because the [`RF24.as_tx()`][rf24_py.RF24.as_tx] will
/// appropriate the RX address on pipe 0 for auto-ack purposes.
pub fn as_rx(&mut self) -> PyResult<()> {
self.inner
.as_rx()
Expand All @@ -186,6 +190,16 @@ impl RF24 {
/// Note:
/// This function will also flush the TX FIFO when ACK payloads are enabled
/// (via [`RF24.ack_payloads`][rf24_py.RF24.ack_payloads]).
///
/// This must be called at least once before calling
/// [`RF24.send()`][rf24_py.RF24.send] or
/// [`RF24.write()`][rf24_py.RF24.write].
/// Conventionally, this should be called before setting the TX address via
/// [`RF24.open_tx_pipe()`][rf24_py.RF24.open_tx_pipe].
///
/// For auto-ack purposes, this function will also restore the cached
/// TX address (passed to [`RF24.open_tx_pipe()`][rf24_py.RF24.open_tx_pipe])
/// to the RX pipe 0.
pub fn as_tx(&mut self) -> PyResult<()> {
self.inner
.as_tx()
Expand Down Expand Up @@ -654,7 +668,7 @@ impl RF24 {
/// avoid using pipe 0 to receive because of this.
///
/// Parameters:
/// address: The address to receive data from.
/// address: The address to transmit data to.
pub fn open_tx_pipe(&mut self, address: &[u8]) -> PyResult<()> {
self.inner
.open_tx_pipe(address)
Expand Down
Loading
Loading