Skip to content

[WIP] InfraredDevice as manual device#232

Open
J0EK3R wants to merge 10 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/InfraredDevice
Open

[WIP] InfraredDevice as manual device#232
J0EK3R wants to merge 10 commits into
vicocz:defaultfrom
J0EK3R:merge/vicocz/InfraredDevice

Conversation

@J0EK3R

@J0EK3R J0EK3R commented Jun 11, 2026

Copy link
Copy Markdown

It’s really annoying that every time you scan for devices, the four infrared devices are automatically added (if your smarphone supports ir).

I’ve moved them to the list of manual devices.

WDYT?

@vicocz

vicocz commented Jun 12, 2026

Copy link
Copy Markdown
Owner

It’s really annoying that every time you scan for devices, the four infrared devices are automatically added (if your smarphone supports ir).

I’ve moved them to the list of manual devices.

WDYT?

What if the phone / Windows does not support them? Adding something what is not supported looks weired.
How about adding some settings to disable IRDA (if it's supported) so as you can have it disabled if it annoys you?

@J0EK3R

J0EK3R commented Jun 13, 2026

Copy link
Copy Markdown
Author

Adding something what is not supported looks weired.

Yes, of course — it’s still [WIP] 😉

My suggestion would be to hide this device on the manual‑selection page whenever IRDA isn’t supported.

I mainly wanted to get your opinion on the approach and see whether you’d consider merging it before I invest more time.


Right now it’s only a LEGO IRDA implementation.
As a manually selectable device, it could later be extended with additional IRDA protocol implementations.

I.e. I have two Prio trains that are controlled via IRDA.

@J0EK3R

J0EK3R commented Jun 15, 2026

Copy link
Copy Markdown
Author

Now the IRDA devices are shown in the ManualDeviceListPage only if IInfraredService.IsInfraredSupported == true.

WDYT now? ;)

@vicocz vicocz requested a review from Copilot June 15, 2026 17:49
Comment thread BrickController2/BrickController2/DeviceManagement/DeviceManager.cs Outdated
@vicocz

vicocz commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Now the IRDA devices are shown in the ManualDeviceListPage only if IInfraredService.IsInfraredSupported == true.

WDYT now? ;)

Yeah, better, now, this is something acceptable now. Just smoke test it please, I gues have no phone capable of IRDA at the moment.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR stops Infrared (PF IR) “devices” from being auto-added during device scanning and instead exposes them as manually addable devices, while hiding them on platforms that don’t support IR.

Changes:

  • Removed IR “scan” behavior so scanning only discovers Bluetooth devices.
  • Introduced vendor/device-factory availability gating (IsAvailable) and filtered the manual-device list accordingly.
  • Added an IR vendor module that registers PF IR devices as manual device factories.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
BrickController2/BrickController2/UI/ViewModels/ManualDeviceListPageViewModel.cs Filters manual device entries to only show available device factories.
BrickController2/BrickController2/DeviceManagement/Vendors/Vendor.cs Adds a virtual IsAvailable flag to vendor modules.
BrickController2/BrickController2/DeviceManagement/InfraRedDevice/InfraRedDeviceVendor.cs New vendor module that registers PF IR manual devices and an IR device manager.
BrickController2/BrickController2/DeviceManagement/InfraRedDevice/InfraredDeviceManager.cs Moves IR manager into IR-specific namespace and removes scan-based discovery.
BrickController2/BrickController2/DeviceManagement/InfraRedDevice/InfraredDevice.cs Makes IR device conform to IDeviceType<> for vendor-based registration.
BrickController2/BrickController2/DeviceManagement/InfraRedDevice/IInfraredDeviceManager.cs Removes IDeviceScanner inheritance to reflect no scan support.
BrickController2/BrickController2/DeviceManagement/IDeviceFactoryData.cs Adds IsAvailable so UI can filter manual device factories.
BrickController2/BrickController2/DeviceManagement/DI/DeviceManagementModule.cs Removes direct IR registrations (now handled via vendor module scanning).
BrickController2/BrickController2/DeviceManagement/DeviceManager.cs Drops IR scanning from the overall scan flow.
BrickController2/BrickController2/DeviceManagement/DeviceFactoryData.cs Implements IsAvailable by delegating to the vendor.
Comments suppressed due to low confidence (1)

BrickController2/BrickController2/DeviceManagement/InfraRedDevice/InfraredDevice.cs:21

  • TypeName is used as a user-facing label in the manual device list (e.g., "VendorName - DeviceTypeName"). "InfraredDevice" is inconsistent with other TypeName values (they include spaces) and will render poorly in the UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread BrickController2/BrickController2/DeviceManagement/DI/DeviceManagementModule.cs Outdated
Comment thread BrickController2/BrickController2/DeviceManagement/DeviceManager.cs Outdated
@J0EK3R

J0EK3R commented Jun 16, 2026

Copy link
Copy Markdown
Author

The next step should be to give all type names more specific labels — something along the lines of “Lego Power Functions”.
If we introduce another device in the future that also uses IRDA, a generic name like “InfraredDevice” could lead to naming conflicts. Using more descriptive names now helps avoid such collisions later.

WDYT?

@vicocz

vicocz commented Jun 16, 2026

Copy link
Copy Markdown
Owner

The next step should be to give all type names more specific labels — something along the lines of “Lego Power Functions”. If we introduce another device in the future that also uses IRDA, a generic name like “InfraredDevice” could lead to naming conflicts. Using more descriptive names now helps avoid such collisions later.

WDYT?

I doubt any IRDA device are going to be yet used.
But you can try to rename it now.

@J0EK3R

J0EK3R commented Jun 17, 2026

Copy link
Copy Markdown
Author

Usually you go (silently) to some of your goal step by step :)

Thank you for the flowers! 😉

Do you have any vendor in your mind?

Not really - the only toys I know that work with IRDA are the BRIO trains.

But my motto is “think big” and I’m a bit of a Monk 😉 — so once I touch that part of the code, I want to do it properly.

@J0EK3R

J0EK3R commented Jun 19, 2026

Copy link
Copy Markdown
Author

In the code I noticed several places like this:

            if (Device.DeviceType != DeviceType.Infrared)
            {
                if (!await _deviceManager.IsBluetoothOnAsync())

and

            if (_devices.Any(d => d.DeviceType != DeviceType.Infrared) && !await _deviceManager.IsBluetoothOnAsync())
            {

Here the logic directly checks against DeviceType.Infrared.

My suggestion is to introduce the interfaces IBluetoothDevice and IIRDADevice to distinguish the communication technique instead of relying on explicit DeviceType comparisons.

I didn’t implement IIRDADevice because it wouldn’t be used at the moment — and I wanted to avoid your inevitable criticism. ;)

Then the code looks like this:

            if (Device is IBluetoothDevice)
            {
                if (!await _deviceManager.IsBluetoothOnAsync())

and

            if (_devices.Any(d => d is IBluetoothDevice) && !await _deviceManager.IsBluetoothOnAsync())
            {

@J0EK3R

J0EK3R commented Jun 19, 2026

Copy link
Copy Markdown
Author

Now it looks like this:

Screenshot_2026-06-19-07-18-13-166_com scn BrickController2 Screenshot_2026-06-19-07-19-53-813_com scn BrickController2 Screenshot_2026-06-19-07-21-41-288_com scn BrickController2

@J0EK3R J0EK3R marked this pull request as ready for review June 19, 2026 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants