Skip to content

Commit

Permalink
revert file checks and firmware version
Browse files Browse the repository at this point in the history
  • Loading branch information
Zainrax committed Dec 3, 2024
1 parent 96d0774 commit 6414e12
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ use crate::recording_state::RecordingState;
const AUDIO_SHEBANG: u16 = 1;

const EXPECTED_RP2040_FIRMWARE_HASH: &str = include_str!("../_releases/tc2-firmware.sha256");
const EXPECTED_RP2040_FIRMWARE_VERSION: u32 = 14;
const EXPECTED_RP2040_FIRMWARE_VERSION: u32 = 13;
const EXPECTED_ATTINY_FIRMWARE_VERSION: u8 = 1;

const SEGMENT_LENGTH: usize = 9760;
Expand Down
11 changes: 3 additions & 8 deletions src/save_audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,22 +50,18 @@ pub fn save_audio_file_to_disk(mut audio_bytes: Vec<u8>, device_config: DeviceCo
move |_| {
// Reclaim some memory
audio_bytes.shrink_to_fit();
if audio_bytes.len() < 12 {
error!("Audio data too short: {} bytes", audio_bytes.len());
return;
}
let timestamp = LittleEndian::read_u64(&audio_bytes[2..10]);
let recording_date_time = DateTime::from_timestamp_millis(timestamp as i64 / 1000)
.unwrap_or(chrono::Local::now().with_timezone(&Utc))
.with_timezone(&chrono::Local);
info!("Saving AAC file");
if fs::metadata(&output_dir).is_err() {
if !fs::exists(&output_dir).unwrap_or(false) {
fs::create_dir_all(&output_dir)
.expect(&format!("Failed to create AAC output directory {}", output_dir));
}
let debug_dir = String::from("/home/pi/temp");
// Separate debug directory creation from raw file writing
if !fs::exists(&debug_dir).unwrap_or(false) {
if !fs::exists(&output_dir).unwrap_or(false) {
fs::create_dir(&debug_dir)
.expect(&format!("Failed to create debug output directory {}", debug_dir));
let output_path: String = format!(
Expand All @@ -76,11 +72,10 @@ pub fn save_audio_file_to_disk(mut audio_bytes: Vec<u8>, device_config: DeviceCo
fs::write(&output_path, &audio_bytes).unwrap();
}


let output_path: String =
format!("{}/{}.aac", output_dir, recording_date_time.format("%Y-%m-%d--%H-%M-%S"));
// If the file already exists, don't re-save it.
if fs::metadata(&output_path).is_err() {
if !fs::exists(&debug_dir).unwrap_or(false) {
let recording_date_time =
format!("recordingDateTime={}", recording_date_time.to_rfc3339());
let latitude = format!("latitude={}", device_config.lat_lng().0);
Expand Down

0 comments on commit 6414e12

Please sign in to comment.