Skip to content

Phase 7: Advanced Features (Network Config, SD Card, Firmware) #52

@tylerkron

Description

@tylerkron

Phase 7: Advanced Features

This issue tracks Phase 7 from the migration plan: migrating advanced device features from daqifi-desktop to daqifi-core.

Success Criteria

7.1 Network Configuration

  • WiFi SSID and password configuration
  • WiFi security mode selection (Open, WEP, WPA, WPA2)
  • LAN settings (IP address, subnet, gateway)
  • Network configuration persistence on device
  • Network status queries
  • Apply configuration and reboot sequence

7.2 SD Card Operations

  • Enable/disable SD card logging mode
  • File listing (text-based response handling)
  • File retrieval from device
  • SD card format commands
  • Storage capacity queries
  • File management (delete, rename)
  • Text message consumer for SD card responses (non-protobuf)

7.3 Device Configuration Persistence

  • Device settings save/load
  • Configuration validation
  • Default configuration restoration
  • Configuration versioning
  • Cross-device configuration compatibility

7.4 Firmware Update Support

  • Firmware version comparison and validation
  • Bootloader mode detection and entry
  • Firmware upload protocol (HID-based)
  • Upload progress tracking
  • Firmware verification
  • Device reboot after update
  • Rollback on failure

7.5 Logging and Diagnostics

  • Device-level logging interface
  • Diagnostic message capture
  • Performance metrics (connection time, message latency)
  • Error tracking and reporting
  • Debug mode with verbose logging

Implementation Guidance

Network Configuration Example

public class NetworkConfiguration
{
    public string? WifiSsid { get; set; }
    public string? WifiPassword { get; set; }
    public WifiSecurityMode SecurityMode { get; set; }
    public IPAddress? StaticIP { get; set; }
    public IPAddress? SubnetMask { get; set; }
    public IPAddress? Gateway { get; set; }
}

public interface INetworkConfigurable
{
    Task<NetworkConfiguration> GetNetworkConfigAsync();
    Task SetNetworkConfigAsync(NetworkConfiguration config);
    Task ApplyNetworkConfigAsync(); // Saves and reboots device
}

SD Card Operations Example

public interface ISdCardSupport
{
    bool SdCardLoggingEnabled { get; set; }
    
    Task<IEnumerable<SdCardFileInfo>> ListFilesAsync();
    Task<byte[]> RetrieveFileAsync(string filename);
    Task DeleteFileAsync(string filename);
    Task FormatSdCardAsync();
    Task<SdCardStatus> GetSdCardStatusAsync();
}

// Usage
var files = await device.ListFilesAsync();
foreach (var file in files)
{
    Console.WriteLine($"{file.Name} - {file.Size} bytes - {file.Timestamp}");
}

var data = await device.RetrieveFileAsync("log_2024_10_16.csv");

Firmware Update Example

public interface IFirmwareUpdateSupport
{
    string CurrentFirmwareVersion { get; }
    
    Task<bool> EnterBootloaderModeAsync();
    Task<FirmwareUpdateResult> UpdateFirmwareAsync(
        byte[] firmwareData, 
        IProgress<int>? progress = null);
    Task<bool> VerifyFirmwareAsync();
}

// Usage
var progress = new Progress<int>(p => Console.WriteLine($"Upload progress: {p}%"));
var result = await device.UpdateFirmwareAsync(firmwareBytes, progress);

if (result.Success)
{
    Console.WriteLine($"Firmware updated to {result.NewVersion}");
}

Desktop Migration Impact

Once complete, desktop can migrate:

  • Network configuration UI → use core's INetworkConfigurable
  • SD card operations → use core's ISdCardSupport
  • Firmware update logic → use core's IFirmwareUpdateSupport
  • Device logging → use core's diagnostic interfaces
  • Configuration management → use core's persistence

Testing Requirements

  • Unit tests for network configuration commands
  • SD card operation tests (with mock responses)
  • Text message consumer tests (SD card file listings)
  • Firmware version comparison tests
  • Configuration validation tests
  • Mock bootloader communication tests
  • Integration tests for complete workflows
  • Error handling and rollback tests

Target Version

Core 0.9.0

Dependencies

  • Depends on: Phase 6 (Protocol Implementation)
  • Blocks: Phase 8 (Desktop Integration & Adapters)

Related Documentation

Desktop implementation references:

  • /Device/AbstractStreamingDevice.cs - Network config, SD card operations
  • /Bootloader/ - Firmware update implementation
  • /IO/Messages/Consumers/TextMessageConsumer.cs - SD card text responses
  • HID library usage for bootloader communication

Notes

  • SD card operations use text-based responses (not protobuf), requiring TextMessageConsumer
  • Firmware updates require HID library for bootloader communication
  • Network configuration requires device reboot to apply changes
  • Some operations may be device-type specific (not all DAQiFi devices support all features)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions