OpenMacroBoard / StreamDeckSharp

A simple .NET wrapper for Stream Deck
MIT License
351 stars 47 forks source link

Get Serial Nr. of the StreamDeck #10

Closed patrick-dmxc closed 5 years ago

wischi-chr commented 5 years ago

Thanks for your input. I'm working on it. Should be done by the weekend.

wischi-chr commented 5 years ago

Just implemented that feature in 0.3.1 (https://www.nuget.org/packages/streamdecksharp/)

Quick Example:

using (var deck = StreamDeck.OpenDevice())
{
    Console.WriteLine($"FirmwareVersion : {deck.GetFirmwareVersion()}");
    Console.WriteLine($"SerialNumber    : {deck.GetSerialNumber()}");
}

Pls let me know what you think and if that works for you.

patrick-dmxc commented 5 years ago

Thank you^^

patrick-dmxc commented 5 years ago

But maybe its better, when GetFirmwareVersion and GEtSerialNumber is part of IMacroBoard

wischi-chr commented 5 years ago

I don't think that would be a good idea because not all MacroBoards have a firmware version or serial number. VirtualBoard for example isn't even real hardware and thus does not have a firmware or serial number.

patrick-dmxc commented 5 years ago

If there is no Firmeware you can return null, Because in this way i have to cast to every other IXYZWBoard to get their SerialNumber.

wischi-chr commented 5 years ago

I think that wouldn't be a good idea. If later there would be a wireless device with the method int GetBatteryCharge() every device without a battery would have to fake it or throw an exception.

Adding every feature that only one (or a few) devices support to IMacroBoard would clutter the interface with stuff that isn't supported by every device and is considered bad practice.

Besides it wouldn't help you much. At the moment you have to cast it (or even better use the new pattern matching syntax) but if I would add it to the IMacroBoard interface you would have to null-check and validate every call. It would just lead to NullReferenceExceptions and other problems (for example some devices without battery reporting -1 as battery level) down the line which would be far worse.

In the future there may be an common interface for devices with serialnumber and/or firmware (to simplify pattern matching) but I definitly won't add that to IMacroBoard.