Skip to content

Commit acec2a2

Browse files
lexfreiclaude
andcommitted
fix(bindings): correct otRadioCaps type to u16 for riscv32imac
The riscv32imac bindings incorrectly defined otRadioCaps as u8, but OT_RADIO_CAPS_RX_ON_WHEN_IDLE = 256 which doesn't fit in u8. This caused the capability to be silently truncated to 0, preventing OpenThread from calling otPlatRadioSetRxOnWhenIdle callback. Changes: - Change otRadioCaps from u8 to u16 in riscv32imac bindings - Add missing OT_RADIO_CAPS_RX_ON_WHEN_IDLE constant (256) - Use proper import in lib.rs instead of local const - Fix otPlatRadioGetCaps return type to use otRadioCaps Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: Aleksei Sviridkin <f@lex.la>
1 parent 8e42bae commit acec2a2

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

openthread-sys/src/include/riscv32imac-unknown-none-elf.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2830,7 +2830,7 @@ pub type _bindgen_ty_4 = ::core::ffi::c_uint;
28302830
/// Represents radio capabilities.
28312831
///
28322832
/// The value is a bit-field indicating the capabilities supported by the radio. See `OT_RADIO_CAPS_*` definitions.
2833-
pub type otRadioCaps = u8;
2833+
pub type otRadioCaps = u16;
28342834
///< Radio supports no capability.
28352835
pub const OT_RADIO_CAPS_NONE: _bindgen_ty_5 = 0;
28362836
///< Radio supports AckTime event.
@@ -2849,6 +2849,8 @@ pub const OT_RADIO_CAPS_TRANSMIT_SEC: _bindgen_ty_5 = 32;
28492849
pub const OT_RADIO_CAPS_TRANSMIT_TIMING: _bindgen_ty_5 = 64;
28502850
///< Radio supports rx at specific time.
28512851
pub const OT_RADIO_CAPS_RECEIVE_TIMING: _bindgen_ty_5 = 128;
2852+
///< Radio supports RxOnWhenIdle setting.
2853+
pub const OT_RADIO_CAPS_RX_ON_WHEN_IDLE: _bindgen_ty_5 = 256;
28522854
/// Defines constants that are used to indicate different radio capabilities. See `otRadioCaps`.
28532855
pub type _bindgen_ty_5 = ::core::ffi::c_uint;
28542856
/// Represents the IEEE 802.15.4 PAN ID.

openthread/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ use sys::{
7878
otPlatRadioTxDone, otPlatRadioTxStarted, otRadioCaps, otRadioFrame, otSetStateChangedCallback,
7979
otTaskletsProcess, otThreadGetDeviceRole, otThreadGetExtendedPanId, otThreadSetEnabled,
8080
otThreadSetLinkMode, OT_RADIO_CAPS_ACK_TIMEOUT, OT_RADIO_CAPS_CSMA_BACKOFF,
81-
OT_RADIO_FRAME_MAX_SIZE,
81+
OT_RADIO_CAPS_RX_ON_WHEN_IDLE, OT_RADIO_FRAME_MAX_SIZE,
8282
};
8383

8484
/// A newtype wrapper over the native OpenThread error type (`otError`).
@@ -1427,8 +1427,6 @@ impl<'a> OtContext<'a> {
14271427
}
14281428

14291429
fn plat_radio_caps(&mut self) -> otRadioCaps {
1430-
// OT_RADIO_CAPS_RX_ON_WHEN_IDLE = 256, not in all bindgen targets
1431-
const OT_RADIO_CAPS_RX_ON_WHEN_IDLE: u32 = 256;
14321430
let caps =
14331431
(OT_RADIO_CAPS_ACK_TIMEOUT | OT_RADIO_CAPS_CSMA_BACKOFF | OT_RADIO_CAPS_RX_ON_WHEN_IDLE)
14341432
as _;

openthread/src/platform.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use portable_atomic::AtomicUsize;
77

88
use openthread_sys::otError_OT_ERROR_NONE;
99

10-
use crate::sys::{otError, otInstance, otLogLevel, otLogRegion, otRadioFrame};
10+
use crate::sys::{otError, otInstance, otLogLevel, otLogRegion, otRadioCaps, otRadioFrame};
1111
use crate::{IntoOtCode, OtActiveState, OtContext};
1212

1313
/// A hack so that we can store a mutable reference to the active state in a global static variable
@@ -70,7 +70,7 @@ extern "C" fn otPlatRadioGetIeeeEui64(instance: *const otInstance, mac: *mut u8)
7070
}
7171

7272
#[no_mangle]
73-
extern "C" fn otPlatRadioGetCaps(instance: *const otInstance) -> u8 {
73+
extern "C" fn otPlatRadioGetCaps(instance: *const otInstance) -> otRadioCaps {
7474
OtContext::callback(instance).plat_radio_caps()
7575
}
7676

0 commit comments

Comments
 (0)