Skip to content

Commit 2ea2dd1

Browse files
committed
mctp-estack: Add clear_eid()
A counterpart of set_eid(). set_eid() doesn't allow setting a NULL EID. Signed-off-by: Matt Johnston <[email protected]>
1 parent f3865a5 commit 2ea2dd1

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

mctp-estack/src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub use heapless::Vec;
4949

5050
use heapless::{Entry, FnvIndexMap};
5151

52-
use mctp::{Eid, Error, MsgIC, MsgType, Result, Tag, TagValue};
52+
use mctp::{Eid, Error, MsgIC, MsgType, Result, Tag, TagValue, MCTP_ADDR_NULL};
5353

5454
#[cfg(not(any(feature = "log", feature = "defmt")))]
5555
compile_error!("Either log or defmt feature must be enabled");
@@ -490,6 +490,11 @@ impl Stack {
490490
Ok(())
491491
}
492492

493+
/// Clears the local Endpoint ID.
494+
pub fn clear_eid(&mut self) {
495+
self.own_eid = MCTP_ADDR_NULL;
496+
}
497+
493498
/// Retrieves the local Endpoint ID.
494499
pub fn eid(&self) -> Eid {
495500
self.own_eid

mctp-estack/src/router.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,12 @@ impl<'r> Router<'r> {
812812
let mut inner = self.inner.lock().await;
813813
inner.stack.set_eid(eid.0)
814814
}
815+
816+
/// Clears the EID assigned to the local stack
817+
pub async fn clear_eid(&self) {
818+
let mut inner = self.inner.lock().await;
819+
inner.stack.clear_eid();
820+
}
815821
}
816822

817823
impl core::fmt::Debug for Router<'_> {

0 commit comments

Comments
 (0)