-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Phase 4: Device Discovery Framework
This issue tracks Phase 4 from the migration plan: moving device discovery logic from daqifi-desktop to daqifi-core.
Success Criteria
4.1 Device Discovery Interfaces
- Create
IDeviceFinderinterface for device discovery - Create
IDeviceInfointerface/class for discovered device metadata - Support for multiple discovery mechanisms (WiFi, Serial, USB HID)
- Async discovery with cancellation token support
- Event-based discovery notifications (device found, discovery complete)
4.2 WiFi Device Discovery
- Implement
WiFiDeviceFinderusing UDP broadcast - UDP broadcast on port 30303 with "DAQiFi?\r\n" query
- Parse protobuf responses containing device info (IP, MAC, port, hostname, serial, firmware version)
- Support for custom broadcast messages
- Network interface enumeration and selection
- Timeout and retry configuration
4.3 Serial Device Discovery
- Implement
SerialDeviceFinderfor USB/Serial enumeration - Serial port scanning with device info queries
-
TryGetDeviceInfo()pattern with quick connection attempts - Configurable baud rates and DTR control
- Device identification from serial responses
4.4 USB HID Device Discovery (for firmware updates)
- Implement
HidDeviceFinderfor bootloader mode devices - HID device enumeration (VendorId: 0x4D8, ProductId: 0x03C)
- Device mode detection (normal vs bootloader)
4.5 Device Info Extraction
- Parse device metadata from protobuf messages
- Extract IP address, MAC address, TCP port
- Device hostname, serial number, firmware version
- Device type detection from part numbers
- Power status information
Implementation Guidance
Discovery Interface Example
public interface IDeviceFinder
{
event EventHandler<DeviceDiscoveredEventArgs>? DeviceDiscovered;
event EventHandler? DiscoveryCompleted;
Task<IEnumerable<IDeviceInfo>> DiscoverAsync(CancellationToken cancellationToken = default);
Task<IEnumerable<IDeviceInfo>> DiscoverAsync(TimeSpan timeout);
}
public interface IDeviceInfo
{
string Name { get; }
string SerialNumber { get; }
string FirmwareVersion { get; }
IPAddress? IPAddress { get; }
string? MacAddress { get; }
int? Port { get; }
DeviceType Type { get; }
}WiFi Discovery Example
// Core should support WiFi discovery
var finder = new WiFiDeviceFinder();
finder.DeviceDiscovered += (s, e) => Console.WriteLine($"Found: {e.DeviceInfo.Name}");
var devices = await finder.DiscoverAsync(TimeSpan.FromSeconds(5));
foreach (var device in devices)
{
Console.WriteLine($"{device.Name} at {device.IPAddress}:{device.Port}");
}Serial Discovery Example
// Core should support serial enumeration
var finder = new SerialDeviceFinder();
finder.BaudRate = 115200;
finder.EnableDtr = true;
var devices = await finder.DiscoverAsync();
foreach (var device in devices)
{
Console.WriteLine($"{device.Name} on {device.PortName}");
}Desktop Migration Impact
Once complete, desktop can migrate:
DaqifiDeviceFinder→ useWiFiDeviceFinderfrom coreSerialDeviceFinder→ use core implementationHidDeviceFinder→ use core implementation- Device enumeration logic → removed from desktop
Testing Requirements
- Unit tests for each finder type
- Mock network/serial responses for testing
- Discovery timeout tests
- Multiple device discovery tests
- Cancellation token tests
- Platform-specific discovery tests
- Integration tests with real devices (manual/optional)
Target Version
Core 0.6.0
Dependencies
- Depends on: Phase 3 (Connection Management - UDP transport needed)
- Blocks: Phase 5 (Channel Management)
Related Documentation
Desktop implementation references:
/Device/WiFiDevice/DaqifiDeviceFinder.cs- UDP discovery on port 30303/Device/SerialDevice/SerialDeviceFinder.cs- Serial port scanning/Device/HidDevice/HidDeviceFinder.cs- HID enumeration
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request