Skip to content

Commit

Permalink
Mark None on blockwise COMPLETE, pass tests for "[blockwise-{1,2}]"
Browse files Browse the repository at this point in the history
  • Loading branch information
j-devel committed Mar 25, 2024
1 parent d5009ce commit 0239996
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
23 changes: 18 additions & 5 deletions examples/xbd-net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,20 +170,33 @@ async fn xbd_main() {
println!("@@ out_1: {:?}", out);
debug_count += 1;

if debug_count == 3 { // !!!!
if debug_count == 3 {
//if debug_count == 9 { // right after [blockwise-1] done
println!("!! debug NEW [blockwise-2]");
let mut bs = Xbd::async_gcoap_get_blockwise(addr_self, "/const/song.txt").unwrap();
while let Some(Some(req)) = bs.next().await {
let out = req.await;
println!("@@ out_2: {:?}", out);
}
blockwise_states_print(); // !!!!
assert_eq!(blockwise_states_debug()[0], false, "debug"); // !!!!

blockwise_states_print();
assert_eq!(blockwise_states_debug()[1], false, "debug");
}
}
assert_eq!(blockwise_states_debug()[1], false, "debug"); // !!!!

panic!("ok"); // !!!!
blockwise_states_print();
assert_eq!(blockwise_states_debug()[0], false, "debug");

/* WIP - message: "XbdStream::new should only be called once: AlreadyInit"
println!("!! debug NEW [blockwise-3]");
let mut bs = Xbd::async_gcoap_get_blockwise(addr_self, "/const/song.txt").unwrap();
while let Some(Some(req)) = bs.next().await {
let out = req.await;
println!("@@ out_3: {:?}", out);
}
*/

panic!("debug ok"); // !!!!
}
}

Expand Down
7 changes: 5 additions & 2 deletions examples/xbd-net/src/xbd/blockwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ pub extern fn xbd_blockwise_async_gcoap_req(
#[no_mangle]
pub extern fn xbd_blockwise_async_gcoap_complete(idx: usize) {
BlockwiseData::clear_state(idx);
crate::println!("!!!! debug - complete, after clear state[{}]", idx);

BlockwiseData::send_blockwise_req(Some(idx), None);
}
Expand Down Expand Up @@ -89,7 +90,7 @@ static mut BLOCKWISE_STATES: &'static mut [Option<BlockwiseState>] = &mut [ARRAY
//

pub fn blockwise_states_print() {
crate::println!("blockwise_states_print(): states: {:?}", BlockwiseData::states());
crate::println!("[debug] blockwise_states_print(): states: {:?}", BlockwiseData::states());
}

pub fn blockwise_states_debug() -> heapless::Vec<bool, BLOCKWISE_STATES_MAX> {
Expand Down Expand Up @@ -161,7 +162,9 @@ impl BlockwiseData {
} else { // <blockwise COMPLETE>
stat.add_to_stream(None);
BlockwiseData::set_state_last(None);
crate::println!("!!!! debug - set None to {}", idx);

crate::println!("!!!! debug - complete, set None to state[{}]", idx);
*(&mut Self::states()[idx]) = None;
}

return None;
Expand Down

0 comments on commit 0239996

Please sign in to comment.