Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/Daqifi.Core/Device/SdCard/SdCardCsvFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ private static int FindDataStartIndex(List<string> lines)
return lines.Count; // No data found
}

#pragma warning disable CS1998 // Async iterator: yield return requires async; method has no real awaits.
private static async IAsyncEnumerable<SdCardLogEntry> ParseCsvLines(
List<string> lines,
int dataStartIndex,
Expand Down Expand Up @@ -316,9 +317,8 @@ private static async IAsyncEnumerable<SdCardLogEntry> ParseCsvLines(

// Final progress report
progress?.Report(new SdCardParseProgress(bytesRead, totalBytes, linesProcessed));

await Task.CompletedTask; // keep the method async-compatible
}
#pragma warning restore CS1998

/// <summary>
/// Parses a firmware CSV data row with interleaved per-channel timestamp/value pairs.
Expand Down Expand Up @@ -472,9 +472,10 @@ private static long ComputeTickDelta(uint previous, uint current)
return (long)(uint.MaxValue - previous) + current + 1;
}

#pragma warning disable CS1998 // Async iterator: yield break requires async; no real awaits.
private static async IAsyncEnumerable<SdCardLogEntry> EmptySamples()
{
await Task.CompletedTask;
yield break;
}
#pragma warning restore CS1998
}
4 changes: 2 additions & 2 deletions src/Daqifi.Core/Device/SdCard/SdCardFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ private static async Task<List<DaqifiOutMessage>> ReadAllMessagesAsync(
return messages;
}

#pragma warning disable CS1998 // Async iterator: yield return requires async; method has no real awaits.
/// <summary>
/// Produces <see cref="SdCardLogEntry"/> samples from the parsed messages.
/// </summary>
Expand Down Expand Up @@ -327,9 +328,8 @@ private static async IAsyncEnumerable<SdCardLogEntry> ProduceSamples(

yield return new SdCardLogEntry(timestamp, analogValues, digitalData, analogTimestamps);
}

await Task.CompletedTask; // keep the method async-compatible
}
#pragma warning restore CS1998

/// <summary>
/// Scales raw ADC integer values using calibration parameters from the device config.
Expand Down
7 changes: 4 additions & 3 deletions src/Daqifi.Core/Device/SdCard/SdCardJsonFileParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public async Task<SdCardLogSession> ParseFileAsync(
return await ParseAsync(fileStream, Path.GetFileName(filePath), options, ct);
}

#pragma warning disable CS1998 // Async iterator: yield return requires async; method has no real awaits.
private static async IAsyncEnumerable<SdCardLogEntry> ParseJsonLines(
List<string> lines,
SdCardDeviceConfiguration config,
Expand Down Expand Up @@ -162,9 +163,8 @@ private static async IAsyncEnumerable<SdCardLogEntry> ParseJsonLines(

// Final progress report
progress?.Report(new SdCardParseProgress(bytesRead, totalBytes, linesProcessed));

await Task.CompletedTask; // keep the method async-compatible
}
#pragma warning restore CS1998

private static (uint timestamp, IReadOnlyList<double> analog, uint digital)? TryParseJsonLine(string line)
{
Expand Down Expand Up @@ -332,9 +332,10 @@ private static long ComputeTickDelta(uint previous, uint current)
return (long)(uint.MaxValue - previous) + current + 1;
}

#pragma warning disable CS1998 // Async iterator: yield break requires async; no real awaits.
private static async IAsyncEnumerable<SdCardLogEntry> EmptySamples()
{
await Task.CompletedTask;
yield break;
}
#pragma warning restore CS1998
}
15 changes: 14 additions & 1 deletion src/Daqifi.Core/Firmware/GitHubFirmwareDownloadService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO.Compression;
using System.Reflection;
using System.Text.Json;

namespace Daqifi.Core.Firmware;
Expand All @@ -8,9 +9,21 @@ namespace Daqifi.Core.Firmware;
/// </summary>
public sealed class GitHubFirmwareDownloadService : IFirmwareDownloadService
{
private const string DEFAULT_USER_AGENT = "DaqifiFirmwareUpdater/1.0";
private static readonly string DEFAULT_USER_AGENT = BuildDefaultUserAgent();
private const int DOWNLOAD_BUFFER_SIZE = 8192;

private static string BuildDefaultUserAgent()
{
// Prefer InformationalVersion so prerelease SemVer suffixes (e.g. "1.0.0-beta.1")
// survive into GitHub API traffic for rate-limit/abuse investigations.
// AssemblyVersion is numeric-only and would truncate them.
var assembly = typeof(GitHubFirmwareDownloadService).Assembly;
var version = assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
?? assembly.GetName().Version?.ToString()
?? "unknown";
return $"DaqifiFirmwareUpdater/{version}";
}

private readonly HttpClient _httpClient;
private readonly string _firmwareRepoApiUrl;
private readonly string _wifiRepoApiUrl;
Expand Down