0

I'm trying to communicate with some LIFX bulbs over the LAN.

They use their own protocol and instead of re-inventing the wheel, I decided to take advantage of LIFX.Lib. It seems like the most complete option.

The problem is, it's a PCL library and I'm having issues referencing the appropriate types to invoke methods.

The examples rely on a DatagramSocket which seems to be part of the Windows.Networking.Sockets namespace. As far as I can tell, it's a "Universal App"-only part of the framework. I can't find any way to reference it from my console application. The few documents I've found online just claim that it doesn't need a specific reference and is part of the core framework.

I tried starting a universal class library instead, but then was unable to load the nuget package (no supported targets)

I was under the impression that PCLs could only include references to libraries available on all supported platforms, so I'm a little confused as to why this isn't working.

Have I misunderstood how PCLs work, or is there an obvious way around this that I'm missing? Failing that, is anyone aware of another library that has similar capabilities?

Edit: Apologies, I should probably mention:

.Net 4.6.1 / C# / VS2015 Update 3 / Win 10

Basic
  • 26,321
  • 24
  • 115
  • 201
  • It uses a profile that is specific to Xamarin Studio version 4.1. What could go wrong? GitHub is turning into the next Codeproject.com, requires the Only Works on My Machine label. – Hans Passant Dec 07 '16 at 00:09
  • @HansPassant You'll get no disagreement from me. I assume you're unaware of any way to reference the DatagramSocket type from a console app? I don't mind re-packaging the code in a "standard" DLL, but I'm facing the same issue with not being able to find/add the appropriate reference – Basic Dec 07 '16 at 18:51
  • The example in the README page is UWP specific, that's right, but the library itself should be applicable to your .NET Framework application. Just use the `Socket` class or corresponding instead of `DatagramSocket` in your own application. And, the repository comes with a console application which should be .NET Framework specific. Take a closer look at this application instead of the README example. – Anders Gustafsson Dec 08 '16 at 07:37
  • @AndersGustafsson Thanks for the help, I was using the nuget package so didn't see the source. Also, small world... I was in Enkoping last week. In any case, if you'd care to post as an answer, I'll accept. – Basic Dec 09 '16 at 11:30
  • Small world, indeed :-) I'll post an answer soon enough. Thanks! – Anders Gustafsson Dec 09 '16 at 12:50

1 Answers1

1

The example in the README page is UWP specific, but the library itself should be applicable to your .NET Framework application.

The PCL profile is 151, which means the library can target .NET Framework 4.5.1 and higher, Windows Phone (non-Silverlight) 8.1, Windows 8.1, UWP and Xamarin applications.

If you are developing for .NET Framework, you should be able to use the Socket class or corresponding together with LIFX.Lib. Also note that the repository includes a console application which should be .NET Framework specific. This sample should give you further details on how to use LIFX.Lib in .NET Framework.

Anders Gustafsson
  • 15,837
  • 8
  • 56
  • 114