mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-09-28 12:50:53 +00:00
Some minor esp-ieee802154 updates (#2114)
* Use default CCA threshold value (per esp-idf) * apply different consts for h2 versus c6 in tx power convert func * Fix compile error when building with binary-logs feature * Fix possible integer underflow error
This commit is contained in:
parent
ddf4ff7e9d
commit
e1c27f1b22
@ -9,10 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
### Added
|
||||
|
||||
- Added board-specific consts for c6 and h2 when caluclating transmit power conversion
|
||||
|
||||
### Changed
|
||||
|
||||
- Modified CCA threshold value to default of -60
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed possible integer underflow in array access
|
||||
- Fixed compile error when building binary-logs feature
|
||||
|
||||
### Removed
|
||||
|
||||
## 0.2.0 - 2024-08-29
|
||||
|
@ -25,6 +25,8 @@ heapless = "0.8.0"
|
||||
ieee802154 = "0.6.1"
|
||||
log = "0.4.22"
|
||||
vcell = "0.1.3"
|
||||
cfg-if = "1.0.0"
|
||||
|
||||
|
||||
[features]
|
||||
esp32c6 = ["esp-hal/esp32c6", "esp-wifi-sys/esp32c6"]
|
||||
|
@ -23,7 +23,7 @@ mod binary_logs {
|
||||
syslog(_format, _args);
|
||||
}
|
||||
|
||||
pub unsafe extern "C" fn syslog(format: *const u8, args: VaListImpl) {
|
||||
pub unsafe extern "C" fn syslog(format: *const u8, args: core::ffi::VaListImpl) {
|
||||
let mut buf = [0u8; 512];
|
||||
vsnprintf(&mut buf as *mut u8, 511, format, args);
|
||||
let res_str = core::ffi::CStr::from_ptr(core::ptr::addr_of!(buf).cast())
|
||||
|
@ -169,7 +169,7 @@ impl<'a> Ieee802154<'a> {
|
||||
let result = match maybe_decoded {
|
||||
Ok((decoded, _)) => {
|
||||
// crc is not written to rx buffer
|
||||
let rssi = if raw.data[0] as usize > raw.data.len() {
|
||||
let rssi = if (raw.data[0] as usize > raw.data.len()) || (raw.data[0] == 0) {
|
||||
raw.data[raw.data.len() - 1] as i8
|
||||
} else {
|
||||
raw.data[raw.data[0] as usize - 1] as i8
|
||||
|
@ -19,7 +19,7 @@ use crate::hal::{
|
||||
set_tx_enhance_ack,
|
||||
};
|
||||
|
||||
pub(crate) const CONFIG_IEEE802154_CCA_THRESHOLD: i8 = 1;
|
||||
pub(crate) const CONFIG_IEEE802154_CCA_THRESHOLD: i8 = -60;
|
||||
pub(crate) const IEEE802154_FRAME_EXT_ADDR_SIZE: usize = 8;
|
||||
|
||||
const IEEE802154_MULTIPAN_0: u8 = 0;
|
||||
@ -227,15 +227,26 @@ fn ieee802154_set_multipan_hal(pib: &Pib) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://github.com/espressif/esp-idf/blob/release/v5.3/components/ieee802154/driver/esp_ieee802154_pib.c#L48
|
||||
fn ieee802154_txpower_convert(txpower: i8) -> u8 {
|
||||
const IEEE802154_TXPOWER_VALUE_MAX: i8 = 13;
|
||||
const IEEE802154_TXPOWER_VALUE_MIN: i8 = -32;
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature="esp32h2")] {
|
||||
// https://github.com/espressif/esp-idf/blob/release/v5.3/components/hal/esp32h2/include/hal/ieee802154_ll.h
|
||||
const IEEE802154_TXPOWER_VALUE_MAX: i8 = 20;
|
||||
const IEEE802154_TXPOWER_VALUE_MIN: i8 = -24;
|
||||
const IEEE802154_TXPOWER_INDEX_MIN: i8 = 0;
|
||||
} else if #[cfg(feature="esp32c6")]{
|
||||
// https://github.com/espressif/esp-idf/blob/release/v5.3/components/hal/esp32c6/include/hal/ieee802154_ll.h
|
||||
const IEEE802154_TXPOWER_VALUE_MAX: i8 = 20;
|
||||
const IEEE802154_TXPOWER_VALUE_MIN: i8 = -15;
|
||||
const IEEE802154_TXPOWER_INDEX_MIN: i8 = 3;
|
||||
}
|
||||
}
|
||||
if txpower > IEEE802154_TXPOWER_VALUE_MAX {
|
||||
15
|
||||
} else if txpower < IEEE802154_TXPOWER_VALUE_MIN {
|
||||
0
|
||||
} else if txpower <= IEEE802154_TXPOWER_VALUE_MIN {
|
||||
IEEE802154_TXPOWER_INDEX_MIN as u8
|
||||
} else {
|
||||
((txpower - IEEE802154_TXPOWER_VALUE_MIN) / 3) as u8
|
||||
(((txpower - IEEE802154_TXPOWER_VALUE_MIN) / 3) + IEEE802154_TXPOWER_INDEX_MIN) as u8
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user