-
Notifications
You must be signed in to change notification settings - Fork 0
feat: Phase 6 - Protocol Implementation & Device Logic #60
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
#51) This commit implements Phase 6 of the migration plan, adding protocol-specific communication and device logic to daqifi-core. ## New Features ### 6.1 Device Type Detection - Added DeviceType enum with Nyquist1, Nyquist2, and Nyquist3 - Implemented DeviceTypeDetector for part number-based detection - Supports both short form (Nq1, Nq2, Nq3) and full form (DQF-1000, etc.) ### 6.2 Device Capabilities - Added DeviceCapabilities class for feature detection - Detects WiFi, SD card, USB, and Ethernet support - Tracks channel counts and maximum sampling rates - Factory method to create capabilities from device type ### 6.3 Device Metadata - Implemented DeviceMetadata class for device information - Stores part number, serial number, firmware/hardware versions - Network information (IP, MAC, SSID, hostname, port) - UpdateFromProtobuf method to parse device info from protobuf messages ### 6.4 Device State Machine - Added DeviceState enum (Disconnected, Connecting, Connected, Initializing, Ready, Streaming, Error) - DaqifiDevice now tracks operational state separate from connection status ### 6.5 Protocol Handler Infrastructure - Created IProtocolHandler interface for message routing - Implemented ProtobufProtocolHandler for protobuf message processing - ProtobufMessageType enum for message classification - Message type detection (Status, Stream, SdCard, Error) ### 6.6 Device Initialization Sequence - Added InitializeAsync() method to DaqifiDevice - Standard initialization: disable echo, stop streaming, power on, set format - Query device info and populate metadata - Protocol handler integration for status/stream message routing ## Testing - Added DeviceTypeDetectorTests (15 test cases) - Added DeviceCapabilitiesTests (5 test cases) - Added DeviceMetadataTests (10 test cases) - Added ProtobufProtocolHandlerTests (8 test cases) - All 240 existing tests still passing ## Implementation Notes - Created GenericInboundMessage<T> helper class for flexible message wrapping - DaqifiDevice now uses ProtobufMessage for message event raising - Device initialization is optional but recommended workflow - Protocol handlers are extensible via IProtocolHandler interface Closes #51 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
PR Compliance Guide 🔍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 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
PR Code Suggestions ✨Latest suggestions up to 637cff3
Previous suggestionsSuggestions up to commit 637cff3
|
|||||||||||||||||||||||||||||||||
|
/improve |
|
Persistent suggestions updated to latest commit 637cff3 |
- Remove dqf-1000, dqf-2000, dqf-3000 mappings - Only support nq1, nq2, nq3 part numbers (case-insensitive) - Remove FullForm test cases - Update XML documentation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
YAGNI - Devices don't support Ethernet yet, so removing this capability to keep the API surface minimal until it's actually needed. - Remove HasEthernet property from DeviceCapabilities class - Remove HasEthernet initialization from constructor - Remove HasEthernet = false from FromDeviceType() method - Update all tests to remove HasEthernet assertions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
…sync The protected virtual *Async() wrapper methods were YAGNI - they were just synchronous Send() calls wrapped in Task.CompletedTask with no actual async work. Changes: - Remove 5 unnecessary protected virtual methods (50 lines removed): * DisableDeviceEchoAsync() * StopStreamingAsync() * TurnDeviceOnAsync() * SetProtobufMessageFormatAsync() * QueryDeviceInfoAsync() - Inline commands directly in InitializeAsync() with actual delays - Add Task.Delay() between commands (100ms each, 500ms for device info) - Now the method is genuinely async with real awaits Benefits: - Simpler code (50 fewer lines) - No false async promises - Actual async behavior with delays for device processing - Easier to understand - initialization sequence visible in one place 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
User description
Summary
Implements Phase 6 of the migration plan, adding protocol-specific communication and device logic to daqifi-core.
This PR addresses all requirements from issue #51 and provides the foundation for device initialization, protocol handling, and device metadata management.
Changes
Device Type & Capabilities
DeviceTypeenum with Nyquist1/2/3 variantsDeviceTypeDetectorfor part number-based detectionDeviceCapabilitiesclass for feature detection (WiFi, SD card, USB, channels, sampling rate)Device Metadata
DeviceMetadataclass to store device informationProtocol Handlers
IProtocolHandlerinterface for extensible message routingProtobufProtocolHandlerfor protobuf message processingDevice State Machine
DeviceStateenum (Disconnected, Connecting, Connected, Initializing, Ready, Streaming, Error)DaqifiDevice.InitializeAsync()Supporting Infrastructure
GenericInboundMessage<T>helper for flexible message wrappingDaqifiDeviceto useProtobufMessagefor eventsTesting
New Tests Added:
DeviceTypeDetectorTests- 15 test cases covering all part number formatsDeviceCapabilitiesTests- 5 test cases for capability detectionDeviceMetadataTests- 10 test cases for metadata parsingProtobufProtocolHandlerTests- 8 test cases for message routingTest Results:
Desktop Migration Impact
Once merged, desktop can:
DeviceTypeDetectorto replace desktop's implementationDeviceMetadatafor device information managementProtobufProtocolHandlerfor message routingDaqifiDevice.InitializeAsync()for device initialization sequenceDeviceCapabilitiesCloses
Closes #51
🤖 Generated with Claude Code
PR Type
Enhancement
Description
Implements Phase 6: device type detection, capabilities, and metadata management
Adds protocol handler infrastructure for extensible message routing and processing
Introduces device state machine with initialization sequence for device setup
Provides generic message wrapper and protobuf-specific message type detection
Diagram Walkthrough
File Walkthrough
10 files
Device type enumeration with Nyquist variantsPart number-based device type detection logicDevice capabilities and feature detection classDevice metadata storage and protobuf parsingDevice operational state enumerationProtocol handler interface for message routingProtobuf message type classification enumerationProtobuf message handler with type detection routingGeneric message wrapper for flexible data payloadsDevice initialization sequence and state management4 files
Unit tests for device type detection logicUnit tests for device capabilities classUnit tests for device metadata parsingUnit tests for protobuf protocol handler