Skip to content

Commit

Permalink
Clean up gcoap_{get,req}_v2() related code
Browse files Browse the repository at this point in the history
  • Loading branch information
j-devel committed Jun 11, 2024
1 parent 9067859 commit e2eedeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
8 changes: 2 additions & 6 deletions examples/xbd-net/src/xbd/gcoap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,14 +182,10 @@ impl Future for ReqInner {
}
} else {
//super::Xbd::gcoap_get(&self.addr, &self.uri, cb);
//==== !!!!
// use mcu_if::c_types::c_void;
//==== !!!! WIP
self.finale.replace((_waker, heapless::Vec::new()));
super::Xbd::gcoap_get_v2(&self.addr, &self.uri,
// /* move */_waker); // !!!!
// self._waker.as_ref() as *const _); // !!!!
// self.finale.as_ref().unwrap() as *const _ as *const c_void); // !!!! `&(AtomicWaker, heapless::Vec<u8, 2>)`
self.finale.as_ref().unwrap() as *const Finale as *mut _); // !!!!
self.finale.as_ref().unwrap() as *const Finale as *mut _);
}
},
COAP_METHOD_POST => super::Xbd::gcoap_post(
Expand Down
19 changes: 5 additions & 14 deletions examples/xbd-net/src/xbd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,9 @@ impl Xbd {
}

pub fn gcoap_get<F>(addr: &str, uri: &str, cb: F) where F: FnOnce(GcoapMemoState) + 'static {
// pub fn gcoap_get(addr: &str, uri: &str, cb: fn(GcoapMemoState)) { // !!!!
Self::gcoap_req(addr, uri, COAP_METHOD_GET, None, false, None, cb);
}
// pub fn gcoap_get_v2(addr: &str, uri: &str, waker: futures_util::task::AtomicWaker) { // !!!!
// pub fn gcoap_get_v2(addr: &str, uri: &str, waker_ptr: *const futures_util::task::AtomicWaker) { // !!!!
// pub fn gcoap_get_v2(addr: &str, uri: &str, finale_ptr: *const c_void) { // !!!!

pub fn gcoap_get_v2(addr: &str, uri: &str, finale_ptr: *mut Finale) { // !!!!
Self::gcoap_req_v2(addr, uri, COAP_METHOD_GET, None, false, None, finale_ptr);
}
Expand Down Expand Up @@ -158,9 +155,6 @@ impl Xbd {
}
fn gcoap_req_v2(addr: &str, uri: &str, method: gcoap::CoapMethod,
payload: Option<&[u8]>, blockwise: bool, blockwise_state_index: Option<usize>,
// waker: futures_util::task::AtomicWaker) { // !!!!
// waker_ptr: *const futures_util::task::AtomicWaker) { // !!!!
// finale_ptr: *const c_void) { // !!!!
finale_ptr: *mut Finale) { // !!!!
let payload_ptr = payload.map_or(core::ptr::null(), |payload| payload.as_ptr());
let payload_len = payload.map_or(0, |payload| payload.len());
Expand All @@ -178,13 +172,10 @@ impl Xbd {
*const u8, usize, bool, usize, *const c_void, *const c_void);

if 1 == 1 {// ok
// use futures_util::task::AtomicWaker;

let (waker, vec) = unsafe {
&mut *(finale_ptr as *mut Finale) };
vec.push(42).unwrap();
vec.push(42+1).unwrap();
vec.push(42+2).unwrap();
let (waker, hv) = unsafe { &mut *finale_ptr };
hv.push(42).unwrap();
hv.push(42+1).unwrap();
hv.push(42+2).unwrap();
waker.wake();
}
if 0 == 1 {
Expand Down

0 comments on commit e2eedeb

Please sign in to comment.