Skip to content

Commit

Permalink
feat(vendor HAL command): add Read Radio Register command
Browse files Browse the repository at this point in the history
  • Loading branch information
OueslatiGhaith committed Jan 8, 2024
1 parent 773d99c commit b212b01
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/vendor/command/hal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ pub trait HalCommands {
/// This command returns the value of the RSSI.
async fn read_rssi(&mut self);

// TODO: read_radio_reg
/// This command reads a register value from the RF module
async fn read_radio_reg(&mut self, address: u8);

// TODO: read_raw_rssi

Expand Down Expand Up @@ -268,6 +269,11 @@ impl<T: Controller> HalCommands for T {
self.controller_write(crate::vendor::opcode::HAL_READ_RSSI, &[])
.await;
}

async fn read_radio_reg(&mut self, address: u8) {
self.controller_write(crate::vendor::opcode::HAL_READ_RADIO_REG, &[address])
.await;
}
}

/// Potential errors from parameter validation.
Expand Down
10 changes: 10 additions & 0 deletions src/vendor/event/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ pub enum VendorReturnParameters {
/// command.
HalReadRssi(u8),

/// Parameters returned by the [HAL Read Radio Register](crate::vendor::command::hal::HalCommands::read_radio_reg)
/// command.
HalReadRadioReg(u8),

/// Status returned by the
/// [GAP Set Non-Discoverable](crate::vendor::command::gap::GapCommands::gap_set_nondiscoverable)
/// command.
Expand Down Expand Up @@ -297,6 +301,12 @@ impl VendorReturnParameters {
require_len!(&bytes[3..], 1);
bytes[3]
})),
crate::vendor::opcode::HAL_READ_RADIO_REG => {
Ok(VendorReturnParameters::HalReadRadioReg({
require_len!(&bytes[3..], 1);
bytes[3]
}))
}
crate::vendor::opcode::GAP_SET_NONDISCOVERABLE => Ok(
VendorReturnParameters::GapSetNonDiscoverable(to_status(&bytes[3..])?),
),
Expand Down
1 change: 1 addition & 0 deletions src/vendor/opcode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ vendor_opcodes! {
pub const HAL_GET_PM_DEBUG_INFO = 0x1C;
pub const HAL_SET_PERIPHERAL_LATENCY = 0x20;
pub const HAL_READ_RSSI = 0x22;
pub const HAL_READ_RADIO_REG = 0x30;
}
Gap = 0x1;
{
Expand Down

0 comments on commit b212b01

Please sign in to comment.