Skip to content

Commit

Permalink
Merge pull request #106 from jloxfo2/block_xfer_msg_id
Browse files Browse the repository at this point in the history
client: Generate message ID for all block transfer
  • Loading branch information
Covertness authored Nov 9, 2024
2 parents ebfbe8e + 8b4c6a4 commit 673651d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,9 @@ impl<T: ClientTransport + 'static> CoAPClient<T> {
async fn send_request(&self, request: &mut CoapRequest<SocketAddr>) -> IoResult<CoapResponse> {
let request_length = request.message.payload.len();
if request_length <= self.block1_size {
if 0 == request.message.header.message_id {
request.message.header.message_id = self.gen_message_id();
}
return self.send_single_request(request).await;
}
let payload = std::mem::take(&mut request.message.payload);
Expand Down Expand Up @@ -869,6 +872,7 @@ impl<T: ClientTransport + 'static> CoAPClient<T> {
loop {
match Self::intercept_response(request, &mut block2_state) {
Ok(true) => {
request.message.header.message_id = self.gen_message_id();
let resp = self.send_single_request(request).await?;
request.response = Some(resp);
}
Expand Down

0 comments on commit 673651d

Please sign in to comment.