Skip to content

Commit

Permalink
Detect blockwise complete in stream iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
j-devel committed Feb 14, 2024
1 parent 2d57879 commit cfa6aba
Showing 1 changed file with 4 additions and 16 deletions.
20 changes: 4 additions & 16 deletions examples/xbd-net/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,31 +143,19 @@ async fn xbd_main() {

println!("!! sending ... [blockwise-1]");
let mut bs = Xbd::async_gcoap_get_blockwise(addr_self, "/const/song.txt");
let mut _debug = 0;
while let Some(req) = bs.next().await {
while let Some(Some(req)) = bs.next().await {
println!("req: {:?}", req);

println!("!!!! before `let out = req.await`");
let out = req.unwrap().await; // !!!!
let out = req.await;
println!("@@ out: {:?}", out);

//break; // !!!! TODO check whether end block
//====
_debug += 1;
// if _debug > 1 { break; } // return on 2nd packet
//====
// if let xbd::GcoapMemoState::Resp(Some(payload)) = out {
// if payload.len() == 23 { break; } // !!!
// }
//====
}
panic!("ok"); // !!!!

println!("!! sending ... [blockwise-2]");
// WIP multiple-static blockwise streams !!
let mut bs = Xbd::async_gcoap_get_blockwise(addr_self, "/const/song.txt");
while let Some(req) = bs.next().await {
let out = req.unwrap().await; // !!!!
while let Some(Some(req)) = bs.next().await {
let out = req.await;
println!("@@ out: {:?}", out);
panic!("!!");
}
Expand Down

0 comments on commit cfa6aba

Please sign in to comment.