Skip to content

feat: Add network configuration support - #83

Merged
tylerkron merged 2 commits into
mainfrom
feature/network-configuration-support
Jan 19, 2026
Merged

tylerkron merged 2 commits into
mainfrom
feature/network-configuration-support

Conversation

@tylerkron

@tylerkron tylerkron commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor

User description

Summary

  • Add programmatic network configuration capabilities to the Core library
  • Enable third-party developers to manage device WiFi and LAN settings
  • Implement SD card/LAN interface switching (shared SPI bus constraint)

Changes

New Data Models (Daqifi.Core.Device.Network/)

  • WifiMode enum with ExistingNetwork (1) and SelfHosted (4) values
  • WifiSecurityType enum with None (0) and WpaPskPhrase (3) values
  • NetworkConfiguration class with Mode, SecurityType, SSID, Password properties
  • INetworkConfigurable interface defining the network configuration contract

DaqifiStreamingDevice Extensions

  • NetworkConfiguration property exposing current network settings
  • UpdateNetworkConfigurationAsync() method that:
    • Stops active streaming before configuration
    • Sends WiFi mode, SSID, security type, and password commands
    • Applies configuration and waits for WiFi module restart
    • Re-enables LAN interface and saves configuration
  • PrepareSdInterface() - Disables LAN, enables SD card
  • PrepareLanInterface() - Disables SD card, enables LAN

Tests

  • 31 new tests covering data models, enums, and device network configuration methods
  • All 359 tests pass

Test plan

  • Build succeeds with no errors
  • All existing tests continue to pass
  • New network configuration unit tests pass
  • Code follows existing patterns and conventions

Closes #82

🤖 Generated with Claude Code


PR Type

Enhancement, Tests


Description

  • Add network configuration support to DaqifiStreamingDevice

  • Implement WiFi mode, security type, and credential management

  • Support SD card/LAN interface switching for shared SPI bus

  • Add 31 comprehensive unit tests for network functionality


Diagram Walkthrough

flowchart LR
  A["DaqifiStreamingDevice"] -->|implements| B["INetworkConfigurable"]
  B -->|manages| C["NetworkConfiguration"]
  C -->|contains| D["WifiMode"]
  C -->|contains| E["WifiSecurityType"]
  A -->|switches| F["SD Card Interface"]
  A -->|switches| G["LAN Interface"]
  H["UpdateNetworkConfigurationAsync"] -->|configures| A
  I["PrepareSdInterface"] -->|disables LAN| A
  J["PrepareLanInterface"] -->|disables SD| A
Loading

File Walkthrough

Relevant files
Enhancement
WifiMode.cs
WiFi operating mode enumeration                                                   

src/Daqifi.Core/Device/Network/WifiMode.cs

  • New enum defining WiFi operating modes
  • ExistingNetwork (value 1) for client mode
  • SelfHosted (value 4) for access point mode
+18/-0   
WifiSecurityType.cs
WiFi security type enumeration                                                     

src/Daqifi.Core/Device/Network/WifiSecurityType.cs

  • New enum defining WiFi security types
  • None (value 0) for open networks
  • WpaPskPhrase (value 3) for WPA/WPA2 security
+18/-0   
NetworkConfiguration.cs
Network configuration data model                                                 

src/Daqifi.Core/Device/Network/NetworkConfiguration.cs

  • New class representing network configuration settings
  • Properties for Mode, SecurityType, SSID, and Password
  • Default constructor and parameterized constructor
  • Clone() method for creating independent copies
+65/-0   
INetworkConfigurable.cs
Network configurable interface contract                                   

src/Daqifi.Core/Device/Network/INetworkConfigurable.cs

  • New interface defining network configuration contract
  • NetworkConfiguration property for current settings
  • UpdateNetworkConfigurationAsync() for WiFi configuration workflow
  • PrepareSdInterface() and PrepareLanInterface() for SPI bus switching
  • Comprehensive documentation of configuration steps and hardware
    constraints
+62/-0   
DaqifiStreamingDevice.cs
Network configuration implementation in streaming device 

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs

  • Implement INetworkConfigurable interface
  • Add NetworkConfiguration property initialized with defaults
  • Implement UpdateNetworkConfigurationAsync() with complete WiFi
    configuration workflow
  • Add PrepareSdInterface() to disable LAN and enable SD card
  • Add PrepareLanInterface() to disable SD card and enable LAN
  • Include 2-second delay for WiFi module restart
  • Stop active streaming before configuration changes
+118/-2 
Tests
NetworkConfigurationTests.cs
Network configuration model unit tests                                     

src/Daqifi.Core.Tests/Device/Network/NetworkConfigurationTests.cs

  • Test NetworkConfiguration default constructor initialization
  • Test parameterized constructor with all properties
  • Test Clone() method creates independent copies
  • Test property modification
  • Test WifiMode enum values (ExistingNetwork=1, SelfHosted=4)
  • Test WifiSecurityType enum values (None=0, WpaPskPhrase=3)
+114/-0 
NetworkConfigurableTests.cs
Network configurable device functionality tests                   

src/Daqifi.Core.Tests/Device/Network/NetworkConfigurableTests.cs

  • Test NetworkConfiguration initialization on device construction
  • Test UpdateNetworkConfigurationAsync() throws when disconnected
  • Test UpdateNetworkConfigurationAsync() throws on null configuration
  • Test correct SCPI commands sent for ExistingNetwork mode
  • Test correct SCPI commands sent for SelfHosted mode
  • Test streaming stops before configuration update
  • Test local configuration updated after async operation
  • Test LAN interface preparation during configuration
  • Test PrepareSdInterface() and PrepareLanInterface() command sequences
  • Test interface methods throw when disconnected
  • Include TestableDaqifiStreamingDevice for message capture
+256/-0 

Add programmatic network configuration capabilities to the Core library,
enabling third-party developers to manage device WiFi and LAN settings.

New data models:
- WifiMode enum (ExistingNetwork, SelfHosted)
- WifiSecurityType enum (None, WpaPskPhrase)
- NetworkConfiguration class with Mode, SecurityType, SSID, Password

INetworkConfigurable interface with:
- NetworkConfiguration property
- UpdateNetworkConfigurationAsync() method
- PrepareSdInterface() and PrepareLanInterface() for SPI bus switching

DaqifiStreamingDevice now implements INetworkConfigurable with full
support for WiFi configuration workflow including streaming halt,
command sequencing, WiFi module restart delay, and interface switching.

Closes #82

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tylerkron
tylerkron requested a review from a team as a code owner January 19, 2026 05:39
@qodo-code-review

qodo-code-review Bot commented Jan 19, 2026 •

Copy link
Copy Markdown

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
⚪
Sensitive data exposure

Description: UpdateNetworkConfigurationAsync transmits WiFi credentials (SSID/password) via SCPI
messages (e.g., SetNetworkWifiPassword(configuration.Password)), which could be exposed if
outbound messages are logged, traced, or persisted elsewhere in the communication stack,
requiring verification of logging/redaction behavior. DaqifiStreamingDevice.cs [91-154]

Referred Code
public async Task UpdateNetworkConfigurationAsync(NetworkConfiguration configuration, CancellationToken cancellationToken = default)
{
    if (configuration == null)
    {
        throw new ArgumentNullException(nameof(configuration));
    }

    if (!IsConnected)
    {
        throw new InvalidOperationException("Device is not connected.");
    }

    // Stop streaming if active
    if (IsStreaming)
    {
        StopStreaming();
    }

    // Set WiFi mode
    switch (configuration.Mode)
    {


 ... (clipped 43 lines)
Ticket Compliance
🟢
🎫 #82
🟢 Add WifiMode enum with ExistingNetwork = 1 and SelfHosted = 4 in
Daqifi.Core.Device.Network.
Add WifiSecurityType enum with None = 0 and WpaPskPhrase = 3 in
Daqifi.Core.Device.Network.
Add NetworkConfiguration model in Daqifi.Core.Device.Network with Mode, SecurityType,
Ssid, and Password.
Add a device-level API for configuration via interface extension (e.g.,
INetworkConfigurableDevice/INetworkConfigurable) exposing NetworkConfiguration and
UpdateNetworkConfigurationAsync(...).
Implement UpdateNetworkConfigurationAsync(...) orchestration to stop streaming, set WiFi
mode, set SSID, set security type, set password, apply settings, wait ~2 seconds,
re-enable LAN, and save settings.
Handle SD card / LAN interface switching due to shared SPI bus via PrepareLanInterface()
and PrepareSdInterface().
Add unit tests for the network configuration logic.
Add XML documentation on public API.
Codebase Duplication Compliance
⚪
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
🟢
Generic: Meaningful Naming and Self-Documenting Code

Objective: Ensure all identifiers clearly express their purpose and intent, making code
self-documenting

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Error Handling

Objective: To prevent the leakage of sensitive system information through error messages while
providing sufficient detail for internal debugging.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Secure Logging Practices

Objective: To ensure logs are useful for debugging and auditing without exposing sensitive
information like PII, PHI, or cardholder data.

Status: Passed

Learn more about managing compliance generic rules or creating your own custom rules

🔴
Generic: Comprehensive Audit Trails

Objective: To create a detailed and reliable record of critical system actions for security analysis
and compliance.

Status:
No audit logging: The new network configuration workflow performs sensitive state changes (WiFi
mode/SSID/security/password) without any audit log entries capturing
who/when/what/outcome.

Referred Code
public async Task UpdateNetworkConfigurationAsync(NetworkConfiguration configuration, CancellationToken cancellationToken = default)
{
    if (configuration == null)
    {
        throw new ArgumentNullException(nameof(configuration));
    }

    if (!IsConnected)
    {
        throw new InvalidOperationException("Device is not connected.");
    }

    // Stop streaming if active
    if (IsStreaming)
    {
        StopStreaming();
    }

    // Set WiFi mode
    switch (configuration.Mode)
    {


 ... (clipped 43 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Robust Error Handling and Edge Case Management

Objective: Ensure comprehensive error handling that provides meaningful context and graceful
degradation

Status:
Missing input validation: UpdateNetworkConfigurationAsync does not validate
configuration.Ssid/configuration.Password for null/empty/invalid values or handle
unexpected enum values (no default case), which can lead to sending malformed commands or
silently skipping configuration steps.

Referred Code
// Set WiFi mode
switch (configuration.Mode)
{
    case WifiMode.ExistingNetwork:
        Send(ScpiMessageProducer.SetNetworkWifiModeExisting);
        break;
    case WifiMode.SelfHosted:
        Send(ScpiMessageProducer.SetNetworkWifiModeSelfHosted);
        break;
}

// Set SSID
Send(ScpiMessageProducer.SetNetworkWifiSsid(configuration.Ssid));

// Set security type
switch (configuration.SecurityType)
{
    case WifiSecurityType.None:
        Send(ScpiMessageProducer.SetNetworkWifiSecurityOpen);
        break;
    case WifiSecurityType.WpaPskPhrase:


 ... (clipped 7 lines)

Learn more about managing compliance generic rules or creating your own custom rules

Generic: Security-First Input Validation and Data Handling

Objective: Ensure all data inputs are validated, sanitized, and handled securely to prevent
vulnerabilities

Status:
Unsanitized command inputs: External input fields (configuration.Ssid and configuration.Password) are forwarded
directly into SCPI message producers without visible sanitization/escaping or constraints,
which risks command injection or protocol-breaking payloads.

Referred Code
// Set SSID
Send(ScpiMessageProducer.SetNetworkWifiSsid(configuration.Ssid));

// Set security type
switch (configuration.SecurityType)
{
    case WifiSecurityType.None:
        Send(ScpiMessageProducer.SetNetworkWifiSecurityOpen);
        break;
    case WifiSecurityType.WpaPskPhrase:
        Send(ScpiMessageProducer.SetNetworkWifiSecurityWpa);
        break;
}

// Set password
Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));

Learn more about managing compliance generic rules or creating your own custom rules

  • Update
Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-code-review

qodo-code-review Bot commented Jan 19, 2026 •

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
High-level
Verify network configuration after update

Instead of optimistically updating the local network configuration state after
sending commands, the method should query the device to get the actual, applied
configuration. This ensures the library's state accurately reflects the
hardware's state.

Examples:

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [149-153]
            // Update local configuration
            NetworkConfiguration.Mode = configuration.Mode;
            NetworkConfiguration.SecurityType = configuration.SecurityType;
            NetworkConfiguration.Ssid = configuration.Ssid;
            NetworkConfiguration.Password = configuration.Password;

Solution Walkthrough:

Before:

async function UpdateNetworkConfigurationAsync(new_config):
    // ... send commands to device ...
    Send(SetNetworkWifiSsid(new_config.Ssid))
    Send(SetNetworkWifiPassword(new_config.Password))
    // ...

    Send(ApplyNetworkLan)
    await Task.Delay(RESTART_DELAY)
    Send(SaveNetworkLan)

    // Optimistically update local state without verification
    this.NetworkConfiguration.Mode = new_config.Mode
    this.NetworkConfiguration.Ssid = new_config.Ssid
    this.NetworkConfiguration.Password = new_config.Password

After:

async function UpdateNetworkConfigurationAsync(new_config):
    // ... send commands to device ...
    Send(SetNetworkWifiSsid(new_config.Ssid))
    Send(SetNetworkWifiPassword(new_config.Password))
    // ...

    Send(ApplyNetworkLan)
    await Task.Delay(RESTART_DELAY)
    Send(SaveNetworkLan)

    // Read back the actual configuration from the device
    // (Assumes query commands exist or can be added)
    actual_config = await QueryDeviceNetworkConfiguration()

    // Update local state with verified values
    this.NetworkConfiguration.Mode = actual_config.Mode
    this.NetworkConfiguration.Ssid = actual_config.Ssid
    this.NetworkConfiguration.Password = actual_config.Password
Suggestion importance[1-10]: 7

__

Why: This is a valid and important suggestion that improves the robustness of the new feature by preventing potential state mismatches between the client and the device.

Medium
Possible issue
✅ Return a clone to prevent state mismatch
Suggestion Impact:The commit replaced the public auto-property with a private readonly _networkConfiguration field and changed the NetworkConfiguration getter to return _networkConfiguration.Clone(), preventing external state modification. It also updated UpdateNetworkConfigurationAsync to write into _networkConfiguration instead of the public property.

code diff:

+        private readonly NetworkConfiguration _networkConfiguration = new NetworkConfiguration();
+
         /// <summary>
-        /// Gets the current network configuration.
+        /// Gets a copy of the current network configuration.
         /// </summary>
-        public NetworkConfiguration NetworkConfiguration { get; } = new NetworkConfiguration();
+        /// <remarks>
+        /// Returns a clone to prevent external modification. Use <see cref="UpdateNetworkConfigurationAsync"/>
+        /// to change the device's network configuration.
+        /// </remarks>
+        public NetworkConfiguration NetworkConfiguration => _networkConfiguration.Clone();
 
         /// <summary>
         /// Initializes a new instance of the <see cref="DaqifiStreamingDevice"/> class.
@@ -88,12 +94,16 @@
         /// <returns>A task that represents the asynchronous operation.</returns>
         /// <exception cref="InvalidOperationException">Thrown when the device is not connected.</exception>
         /// <exception cref="ArgumentNullException">Thrown when <paramref name="configuration"/> is null.</exception>
+        /// <exception cref="ArgumentOutOfRangeException">Thrown when an unsupported WiFi mode or security type is specified.</exception>
+        /// <exception cref="OperationCanceledException">Thrown when the operation is canceled.</exception>
         public async Task UpdateNetworkConfigurationAsync(NetworkConfiguration configuration, CancellationToken cancellationToken = default)
         {
             if (configuration == null)
             {
                 throw new ArgumentNullException(nameof(configuration));
             }
+
+            cancellationToken.ThrowIfCancellationRequested();
 
             if (!IsConnected)
             {
@@ -115,12 +125,14 @@
                 case WifiMode.SelfHosted:
                     Send(ScpiMessageProducer.SetNetworkWifiModeSelfHosted);
                     break;
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(configuration), configuration.Mode, "Unsupported WiFi mode.");
             }
 
             // Set SSID
             Send(ScpiMessageProducer.SetNetworkWifiSsid(configuration.Ssid));
 
-            // Set security type
+            // Set security type and password
             switch (configuration.SecurityType)
             {
                 case WifiSecurityType.None:
@@ -128,11 +140,11 @@
                     break;
                 case WifiSecurityType.WpaPskPhrase:
                     Send(ScpiMessageProducer.SetNetworkWifiSecurityWpa);
+                    Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
                     break;
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(configuration), configuration.SecurityType, "Unsupported WiFi security type.");
             }
-
-            // Set password
-            Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
 
             // Apply configuration
             Send(ScpiMessageProducer.ApplyNetworkLan);
@@ -147,10 +159,10 @@
             Send(ScpiMessageProducer.SaveNetworkLan);
 
             // Update local configuration
-            NetworkConfiguration.Mode = configuration.Mode;
-            NetworkConfiguration.SecurityType = configuration.SecurityType;
-            NetworkConfiguration.Ssid = configuration.Ssid;
-            NetworkConfiguration.Password = configuration.Password;
+            _networkConfiguration.Mode = configuration.Mode;
+            _networkConfiguration.SecurityType = configuration.SecurityType;
+            _networkConfiguration.Ssid = configuration.Ssid;
+            _networkConfiguration.Password = configuration.Password;
         }

To prevent state mismatches, modify the NetworkConfiguration property to return
a clone of the internal configuration object, enforcing the use of
UpdateNetworkConfigurationAsync for all changes.

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [37]

-public NetworkConfiguration NetworkConfiguration { get; } = new NetworkConfiguration();
+private readonly NetworkConfiguration _networkConfiguration = new NetworkConfiguration();
 
+/// <summary>
+/// Gets the current network configuration.
+/// </summary>
+public NetworkConfiguration NetworkConfiguration => _networkConfiguration.Clone();
+

[Suggestion processed]

Suggestion importance[1-10]: 7

__

Why: This is a valuable design improvement that enhances encapsulation by preventing direct modification of the internal state, which could lead to inconsistencies between the object's state and the hardware's actual configuration.

Medium
✅ Throw on unsupported WifiMode
Suggestion Impact:The commit added a `default` branch to the `WifiMode` switch that throws an `ArgumentOutOfRangeException` when an unsupported WiFi mode is provided, implementing the defensive handling suggested (though with slightly different exception arguments/message).

code diff:

@@ -115,12 +125,14 @@
                 case WifiMode.SelfHosted:
                     Send(ScpiMessageProducer.SetNetworkWifiModeSelfHosted);
                     break;
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(configuration), configuration.Mode, "Unsupported WiFi mode.");
             }

Add a default case to the WifiMode switch statement that throws an
ArgumentOutOfRangeException to handle unsupported enum values.

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [110-118]

 switch (configuration.Mode)
 {
     case WifiMode.ExistingNetwork:
         Send(ScpiMessageProducer.SetNetworkWifiModeExisting);
         break;
     case WifiMode.SelfHosted:
         Send(ScpiMessageProducer.SetNetworkWifiModeSelfHosted);
         break;
+    default:
+        throw new ArgumentOutOfRangeException(nameof(configuration.Mode), configuration.Mode, "Unsupported WifiMode");
 }

[Suggestion processed]

Suggestion importance[1-10]: 5

__

Why: This is a good defensive programming practice that makes the code more robust against future changes to the WifiMode enum by explicitly handling unexpected values.

Low
✅ Throw on unsupported security type
Suggestion Impact:The commit added a `default` branch to the `configuration.SecurityType` switch that throws an `ArgumentOutOfRangeException` when an unsupported WiFi security type is provided (and also added a similar default for WiFi mode). The thrown exception differs slightly from the suggestion (uses `nameof(configuration)` and different message text), but implements the same defensive behavior.

code diff:

-            // Set security type
+            // Set security type and password
             switch (configuration.SecurityType)
             {
                 case WifiSecurityType.None:
@@ -128,11 +140,11 @@
                     break;
                 case WifiSecurityType.WpaPskPhrase:
                     Send(ScpiMessageProducer.SetNetworkWifiSecurityWpa);
+                    Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
                     break;
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(configuration), configuration.SecurityType, "Unsupported WiFi security type.");
             }

Add a default case to the WifiSecurityType switch statement that throws an
ArgumentOutOfRangeException to handle unsupported enum values.

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [124-132]

 switch (configuration.SecurityType)
 {
     case WifiSecurityType.None:
         Send(ScpiMessageProducer.SetNetworkWifiSecurityOpen);
         break;
     case WifiSecurityType.WpaPskPhrase:
         Send(ScpiMessageProducer.SetNetworkWifiSecurityWpa);
         break;
+    default:
+        throw new ArgumentOutOfRangeException(nameof(configuration.SecurityType), configuration.SecurityType, "Unsupported WifiSecurityType");
 }

[Suggestion processed]

Suggestion importance[1-10]: 5

__

Why: This is a good defensive programming practice that makes the code more robust against future changes to the WifiSecurityType enum by explicitly handling unexpected values.

Low
General
Replace fixed delay with robust polling

Replace the fixed Task.Delay for the WiFi module restart with a more robust
polling mechanism to check for device readiness, improving the reliability of
the configuration process.

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [140-141]

+// A more robust implementation would poll the device to check if it's back online
+// instead of a fixed delay. For example:
+// await PollForDeviceReady(cancellationToken);
+
 // Wait for WiFi module to restart
 await Task.Delay(WIFI_MODULE_RESTART_DELAY_MS, cancellationToken);
  • Apply / Chat
Suggestion importance[1-10]: 6

__

Why: The suggestion correctly points out that a fixed delay is not robust and proposes a better polling-based approach, which would improve reliability, though it's a non-trivial change.

Low
✅ Check cancellation early
Suggestion Impact:The commit added cancellationToken.ThrowIfCancellationRequested() near the beginning of UpdateNetworkConfigurationAsync, ensuring the operation can be cancelled before performing connection checks and sending SCPI commands.

code diff:

+        /// <exception cref="ArgumentOutOfRangeException">Thrown when an unsupported WiFi mode or security type is specified.</exception>
+        /// <exception cref="OperationCanceledException">Thrown when the operation is canceled.</exception>
         public async Task UpdateNetworkConfigurationAsync(NetworkConfiguration configuration, CancellationToken cancellationToken = default)
         {
             if (configuration == null)
             {
                 throw new ArgumentNullException(nameof(configuration));
             }
+
+            cancellationToken.ThrowIfCancellationRequested();
 
             if (!IsConnected)

Add a cancellationToken.ThrowIfCancellationRequested() call at the beginning of
the method to ensure cancellation is handled before any operations begin.

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [103-107]

 // Stop streaming if active
+cancellationToken.ThrowIfCancellationRequested();
 if (IsStreaming)
 {
     StopStreaming();
 }

[Suggestion processed]

Suggestion importance[1-10]: 6

__

Why: This is a good practice for responsive and correct asynchronous code, ensuring that cancellation requests are honored promptly before performing state-changing operations.

Low
✅ Skip password for open networks
Suggestion Impact:The commit moved the SetNetworkWifiPassword(...) call into the WifiSecurityType.WpaPskPhrase branch, so no password command is sent when SecurityType is None. This achieves the suggested optimization, though implemented via the switch instead of an explicit if.

code diff:

-            // Set security type
+            // Set security type and password
             switch (configuration.SecurityType)
             {
                 case WifiSecurityType.None:
@@ -128,11 +140,11 @@
                     break;
                 case WifiSecurityType.WpaPskPhrase:
                     Send(ScpiMessageProducer.SetNetworkWifiSecurityWpa);
+                    Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
                     break;
+                default:
+                    throw new ArgumentOutOfRangeException(nameof(configuration), configuration.SecurityType, "Unsupported WiFi security type.");
             }
-
-            // Set password
-            Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
 

Conditionally send the password command only if the SecurityType is not None to
avoid sending an unnecessary command for open networks.

src/Daqifi.Core/Device/DaqifiStreamingDevice.cs [135]

-Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
+if (configuration.SecurityType != WifiSecurityType.None)
+{
+    Send(ScpiMessageProducer.SetNetworkWifiPassword(configuration.Password));
+}

[Suggestion processed]

Suggestion importance[1-10]: 4

__

Why: This is a minor optimization that avoids sending a redundant command for open networks, making the communication slightly more efficient and clean.

Low
  • Update

- Return clone from NetworkConfiguration property to prevent external
  state modification and enforce use of UpdateNetworkConfigurationAsync
- Add early cancellation check with ThrowIfCancellationRequested
- Add default cases to switch statements that throw
  ArgumentOutOfRangeException for unsupported enum values
- Skip password command for open networks (WifiSecurityType.None)
- Add tests for clone behavior, cancellation, and invalid enum handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@tylerkron
tylerkron merged commit 8c09909 into main Jan 19, 2026
1 check passed
@tylerkron
tylerkron deleted the feature/network-configuration-support branch January 19, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Add network configuration support

1 participant