-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Upgrade to Daqifi.Core v0.7.0 with ProtobufProtocolHandler integration #297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s (issue #293) This commit upgrades daqifi-desktop to use Daqifi.Core v0.7.0 and leverages the Phase 6 features for improved device initialization and metadata handling. ## Changes ### Package Updates - Updated Daqifi.Core from v0.6.0 to v0.7.0 ### Device Type Detection - Removed desktop's DeviceTypeDetector.cs (28 lines removed) - Now using Core's DeviceTypeDetector which includes Nyquist2 support - Removed desktop's DeviceType enum (replaced with Core's version) ### Metadata Handling - Added DeviceMetadata property to AbstractStreamingDevice - Added DeviceCapabilities property (exposes Metadata.Capabilities) - Added DeviceState observable property for formal state tracking - Updated HydrateDeviceMetadata() to use Core's Metadata.UpdateFromProtobuf() - **Fixes WiFi security mode bug** - can now transition to mode 0 (open network) ### Async Device Initialization - Added InitializeDeviceAsync() method with proper delays between commands - Updated SerialStreamingDevice.Connect() to use InitializeDeviceAsync() - Updated SerialStreamingDevice.TryGetDeviceInfo() to use InitializeDeviceAsync() - Updated DaqifiStreamingDevice.Connect() to use InitializeDeviceAsync() ## Benefits - **Bug Fix**: WiFi security mode 0 (open network) now works correctly - **Better device support**: Nyquist2 device type now recognized - **Reduced LOC**: ~40 lines removed by leveraging Core library - **Improved initialization**: Proper delays between device commands - **Single source of truth**: Core maintains device initialization logic ## Related - Implements: daqifi-desktop#293 - Uses: daqifi-core v0.7.0 (PR #60) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Added `using Daqifi.Core.Device;` to AbstractStreamingDeviceTests.cs to resolve CS0103 errors where DeviceType and DeviceTypeDetector were not found in the current context. This was needed because the desktop's DeviceType enum was removed and replaced with Core's version, but the test file was missing the import. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…uting This commit refactors the desktop application to leverage Core's ProtobufProtocolHandler for automatic message routing, eliminating ~50 lines of manual message handler switching logic. ## Changes ### AbstractStreamingDevice.cs - Removed manual `SetMessageHandler()` and `MessageHandlerType` enum - Added `InitializeProtocolHandler()` to create ProtobufProtocolHandler - Added `OnInboundMessageReceived()` to route messages through protocol handler - Updated `OnStatusMessageReceived()` to accept DaqifiOutMessage directly - Updated `OnStreamMessageReceived()` to accept DaqifiOutMessage directly - Updated `StartStreamingMessageConsumer()` to wire up protocol handler - Updated `StopMessageConsumer()` to unsubscribe from message events - Updated `InitializeDeviceState()` to initialize protocol handler - Kept `OnSdCardMessageReceived()` for text-based SD card messages ### SerialStreamingDevice.cs - Updated device info detection to use ProtobufProtocolHandler.DetectMessageType() - Replaced manual `IsValidStatusMessage()` with Core's message type detection ## Benefits - **Code reduction**: Removed ~50 lines of manual message routing logic - **Single source of truth**: Core library handles message type detection - **Automatic routing**: Protocol handler routes status/streaming messages automatically - **Better maintainability**: Changes to message detection logic only needed in Core - **Consistency**: Desktop and other Core consumers use same message routing logic ## Technical Details The ProtobufProtocolHandler automatically detects message types based on: - Status messages: Have channel configuration (DigitalPortNum, AnalogInPortNum, etc.) - Streaming messages: Have timestamp and data (MsgTimeStamp, AnalogInData, etc.) The handler routes each message type to the appropriate callback, eliminating the need for manual handler switching via SetMessageHandler(). SD card messages remain text-based and are handled separately via the TextMessageConsumer and OnSdCardMessageReceived() handler. ## Related - Addresses missed opportunity from daqifi-desktop#293 review - Uses daqifi-core v0.7.0 ProtobufProtocolHandler (PR #60) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
PR Compliance Guide 🔍(Compliance updated until commit bca609f)Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label Previous compliance checksCompliance check up to commit d85d26b
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||||||||||
Core's DeviceType enum now includes Nyquist2 (value=2) between Nyquist1 and Nyquist3, so the test expectations needed to be updated: - Unknown = 0 - Nyquist1 = 1 - Nyquist2 = 2 (new) - Nyquist3 = 3 (was 2) This fixes the failing test: DeviceType_Enum_ShouldHaveCorrectValues 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
Replace null sdCardMessageHandler with empty lambda to prevent potential NullReferenceException if a protobuf SD card message is ever received. This addresses Qodo's defensive coding suggestion - SD card messages are normally text-based and handled separately, but providing an empty handler is safer than null. Addresses: Qodo PR #297 code suggestion Impact: Low (defensive coding improvement) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
📊 Code Coverage ReportSummarySummary
CoverageDAQiFi - 10.3%
Daqifi.Desktop.Bootloader - 20.6%
Daqifi.Desktop.Common - 45.9%
Daqifi.Desktop.DataModel - 100%
Daqifi.Desktop.IO - 23.9%
Coverage report generated by ReportGenerator • View full report in build artifacts |
User description
Summary
This PR upgrades daqifi-desktop to use Daqifi.Core v0.7.0 and fully leverages Phase 6 features including device type detection, metadata management, async initialization, and automatic message routing via
ProtobufProtocolHandler.Changes
Package Updates
Daqifi.Corefrom v0.6.0 to v0.7.0Device Type Detection (Commit 1)
DeviceTypeDetector.cs(27 lines)DeviceTypeDetectorwith Nyquist2 supportDeviceTypeenum (replaced with Core's version)Metadata & State Management (Commit 1)
DeviceMetadataproperty toAbstractStreamingDeviceDeviceCapabilitiesproperty (exposesMetadata.Capabilities)DeviceStateobservable property for formal state trackingHydrateDeviceMetadata()to use Core'sMetadata.UpdateFromProtobuf()Async Device Initialization (Commit 1)
InitializeDeviceAsync()method with proper delays between commandsSerialStreamingDevice.Connect()to useInitializeDeviceAsync()SerialStreamingDevice.TryGetDeviceInfo()to useInitializeDeviceAsync()DaqifiStreamingDevice.Connect()to useInitializeDeviceAsync()Automatic Message Routing (Commit 3)
ProtobufProtocolHandlerfor automatic message routingSetMessageHandler()andMessageHandlerTypeenum (~50 lines)InitializeProtocolHandler()to create protocol handlerDaqifiOutMessagedirectlyBug Fixes
Benefits
Code Quality
Functionality
DeviceStateproperty for monitoring device statusMaintainability
Testing
Related Issues
Migration Notes
This PR maintains backward compatibility - all existing Desktop functionality works as before, but now leverages Core's implementations for:
DeviceTypeDetector)DeviceMetadata.UpdateFromProtobuf())InitializeDeviceAsync())ProtobufProtocolHandler)🤖 Generated with Claude Code
Co-Authored-By: Claude [email protected]
PR Type
Enhancement, Bug fix
Description
Upgrade Daqifi.Core from v0.6.0 to v0.7.0 with Phase 6 features
Integrate ProtobufProtocolHandler for automatic message routing
Leverage Core's device type detection and metadata management
Implement async device initialization with proper command delays
Diagram Walkthrough
File Walkthrough
AbstractStreamingDeviceTests.cs
Add missing Core Device namespace importDaqifi.Desktop.Test/Device/AbstractStreamingDeviceTests.cs
using Daqifi.Core.Device;statementreferences
AbstractStreamingDevice.cs
Integrate Core v0.7.0 with protocol handler and metadataDaqifi.Desktop/Device/AbstractStreamingDevice.cs
Core)
ProtobufProtocolHandler
(OnStatusMessageReceived, OnStreamMessageReceived,
OnSdCardMessageReceived)
Metadata.UpdateFromProtobuf()
commands
DeviceTypeDetector.cs
Remove duplicate DeviceTypeDetector implementationDaqifi.Desktop/Device/DeviceTypeDetector.cs
SerialStreamingDevice.cs
Use async initialization and protocol handler detectionDaqifi.Desktop/Device/SerialDevice/SerialStreamingDevice.cs
ProtobufProtocolHandler.DetectMessageType()
DaqifiOutMessage
DaqifiStreamingDevice.cs
Use async initialization in WiFi deviceDaqifi.Desktop/Device/WiFiDevice/DaqifiStreamingDevice.cs
Daqifi.Desktop.csproj
Upgrade Daqifi.Core NuGet package versionDaqifi.Desktop/Daqifi.Desktop.csproj