Skip to content

Commit

Permalink
Fix log feature
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Nov 2, 2023
1 parent c40b48c commit 0ec09ae
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/board/ota/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ where
residue: 0,
};

debug!("Activating {}", self.update_slot);
debug!("Activating {:?}", self.update_slot);

self.ota_data.erase(self.update_slot).await?;

Expand Down
4 changes: 2 additions & 2 deletions src/human_readable.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use defmt::Format;
use embassy_time::Duration;
use ufmt::{uDebug, uDisplay, uwrite};

Expand Down Expand Up @@ -55,7 +54,8 @@ impl uDisplay for Throughput {
}
}

impl Format for Throughput {
#[cfg(feature = "defmt")]
impl defmt::Format for Throughput {
fn format(&self, fmt: defmt::Formatter) {
let bytes_per_sec = self.bytes_per_sec();
if let Some((int, frac, suffix)) = find_suffix(bytes_per_sec) {
Expand Down
16 changes: 8 additions & 8 deletions src/states/firmware_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async fn do_update(context: &mut Context) -> UpdateResult {
{
Some(Ok(request)) => request,
Some(Err(e)) => {
warn!("HTTP connect error: {}", e);
warn!("HTTP connect error: {:?}", e);
return UpdateResult::Failed(UpdateError::HttpConnectionFailed);
}
None => return UpdateResult::Failed(UpdateError::HttpConnectionTimeout),
Expand All @@ -130,12 +130,12 @@ async fn do_update(context: &mut Context) -> UpdateResult {
Status::Ok => response,
Status::NotModified => return UpdateResult::AlreadyUpToDate,
_ => {
warn!("HTTP response error: {}", response.status);
warn!("HTTP response error: {:?}", response.status);
return UpdateResult::Failed(UpdateError::HttpRequestFailed);
}
},
Err(e) => {
warn!("HTTP response error: {}", e);
warn!("HTTP response error: {:?}", e);
return UpdateResult::Failed(UpdateError::HttpRequestFailed);
}
};
Expand All @@ -144,7 +144,7 @@ async fn do_update(context: &mut Context) -> UpdateResult {
{
Ok(ota) => ota,
Err(e) => {
warn!("Failed to initialize OTA: {}", e);
warn!("Failed to initialize OTA: {:?}", e);
return UpdateResult::Failed(UpdateError::InternalError);
}
};
Expand All @@ -153,7 +153,7 @@ async fn do_update(context: &mut Context) -> UpdateResult {
print_progress(context, 0, size, None).await;

if let Err(e) = ota.erase().await {
warn!("Failed to erase OTA: {}", e);
warn!("Failed to erase OTA: {:?}", e);
return UpdateResult::Failed(UpdateError::EraseFailed);
};

Expand All @@ -170,15 +170,15 @@ async fn do_update(context: &mut Context) -> UpdateResult {
Ok(&[]) => break None,
Ok(read) => read,
Err(e) => {
warn!("HTTP read error: {}", e);
warn!("HTTP read error: {:?}", e);
break Some(UpdateError::DownloadFailed);
}
},
_ => break Some(UpdateError::DownloadTimeout),
};

if let Err(e) = ota.write(received_buffer).await {
warn!("Failed to write OTA: {}", e);
warn!("Failed to write OTA: {:?}", e);
break Some(UpdateError::WriteError);
}

Expand All @@ -205,7 +205,7 @@ async fn do_update(context: &mut Context) -> UpdateResult {
Either::First(Some(error)) => UpdateResult::Failed(error),
Either::First(None) => {
if let Err(e) = ota.activate().await {
warn!("Failed to activate OTA: {}", e);
warn!("Failed to activate OTA: {:?}", e);
UpdateResult::Failed(UpdateError::ActivateFailed)
} else {
UpdateResult::Success
Expand Down
8 changes: 4 additions & 4 deletions src/states/throughput.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ async fn run_test(context: &mut Context) -> TestResult {
let mut request = match connect.await {
Some(Ok(request)) => request,
Some(Err(e)) => {
warn!("HTTP connect error: {}", e);
warn!("HTTP connect error: {:?}", e);
return TestResult::Failed(TestError::HttpConnectionFailed);
}
_ => return TestResult::Failed(TestError::HttpConnectionTimeout),
Expand All @@ -131,12 +131,12 @@ async fn run_test(context: &mut Context) -> TestResult {
Ok(response) => match response.status {
Status::Ok => response,
_ => {
warn!("HTTP response error: {}", response.status);
warn!("HTTP response error: {:?}", response.status);
return TestResult::Failed(TestError::HttpRequestFailed);
}
},
Err(e) => {
warn!("HTTP response error: {}", e);
warn!("HTTP response error: {:?}", e);
return TestResult::Failed(TestError::HttpRequestFailed);
}
};
Expand Down Expand Up @@ -170,7 +170,7 @@ async fn run_test(context: &mut Context) -> TestResult {
reader.consume(read_len);
}
Err(e) => {
warn!("HTTP read error: {}", e);
warn!("HTTP read error: {:?}", e);
break Some(TestError::DownloadFailed);
}
},
Expand Down
8 changes: 4 additions & 4 deletions src/states/upload_or_store_measurement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ async fn upload_stored(context: &mut Context) {

info!("Uploaded {}", name);
if let Err(e) = file.delete(storage).await {
warn!("Failed to delete file: {}", e);
warn!("Failed to delete file: {:?}", e);
}
}
Ok(_) | Err(StorageError::InsufficientBuffer) => {
Expand Down Expand Up @@ -439,7 +439,7 @@ where
match Timeout::with(CONNECT_TIMEOUT, client.request(Method::POST, &upload_url)).await {
Some(Ok(request)) => request.headers(&headers).body(samples),
Some(Err(e)) => {
warn!("HTTP connect error: {}", e);
warn!("HTTP connect error: {:?}", e);
return Err(());
}
_ => {
Expand All @@ -455,7 +455,7 @@ where
return Ok(());
}

warn!("HTTP upload failed: {}", response.status);
warn!("HTTP upload failed: {:?}", response.status);
for header in response.headers() {
if !header.0.is_empty() {
debug!(
Expand All @@ -466,7 +466,7 @@ where
}
}
}
Some(Err(e)) => warn!("HTTP upload error: {}", e),
Some(Err(e)) => warn!("HTTP upload error: {:?}", e),
_ => warn!("Timeout"),
}
Err(())
Expand Down

0 comments on commit 0ec09ae

Please sign in to comment.