getsenic / nuimo-windows

Library for Windows 10 platforms to connect and communicate with Nuimo controllers made by Senic
MIT License
23 stars 8 forks source link

Converted to Portable library #8

Closed Inrego closed 8 years ago

Inrego commented 8 years ago

I've converted the project to a portable library, in order to be able to target both UWP 10 and .NET 4.5

I've tested that the compiled .dll can be referenced in both a .NET 4.5 project and a UWP 10 project. I have also tested that the resulting .dll works in .NET 4.5 by successfully writing a LED Matrix to the Nuimo device. I have not yet tested the .dll in any UWP projects, but as Portable libraries are exactly for this kind of stuff, I can't imagine why it shouldn't work. Still think it should be tested before going live with the change, though.

larsblumberg commented 8 years ago

Awesome – thanks! We'll have a look into it

Inrego commented 8 years ago

For those not familiar with Portable Libraries (since they are a rather new concept), I'll give a brief explanation:

You are able to select which frameworks you want to target.

Change Targets

The available api's are then the intersection of the selected frameworks. As you can see in above screenshot, it automatically changes the targets by adding targets that support the same set of api's as the ones I currently selected.

In fact, I had to make a minor change to NuimoBluetoothController.cs since Encoding.ASCII was not available in all the targeted frameworks. Also, the only overload of GetString that was available across all the selected targets, was the one where you provide index and length of the bytes you want to read.

That means the class library now actually supports the following targets:

Available Targets

I do have my doubts about the bluetooth api's on Xamarin, it will probably just act as if there is no bluetooth controller. But .NET Framework 4.5 does work and that's what was important to me. Actually, it's possible to target .NET Framework 4.0 by removing ASP.NET Core 1.0, but I'll leave it up to you guys to do the nitpicking about which frameworks to target :smiley:

I learned about this from a free course on Xamarin University. While we are not working with Xamarin/Android/iOS in this case, the same methodology for targeting multiple platforms are the same. I can recommend the course. It can be found here: Introduction to Cross-Platform Mobile Development (XAM110) (you probably need to register and sign in before you can use that link)

hansmbakker commented 8 years ago

@Inrego on Xamarin (Android / iOS, but UWP not yet) you can maybe use https://github.com/xabre/xamarin-bluetooth-le/

Inrego commented 8 years ago

It's not that I wanted to develop for Xamarin. I was just providing examples :)

larsblumberg commented 8 years ago

Dear @Inrego – thanks for clarifying my questions. After you found time to rebase the branch and modify the file reference from being relative to absolute using MS placeholders (I guess), we're ready to merge your PR. Thanks again!

Inrego commented 8 years ago

Sorry for the long delay. I have rebased and made the changes you asked about in your comments.

Inrego commented 8 years ago

Note if you get an error while compiling that says something about not referencing portable .NET it's because you still have project.lock.json in your project folder. Delete that and then it should compile fine.

larsblumberg commented 8 years ago

Hi @Inrego,

thanks for continuing your work on this PR. I'd like to merge but it seems you didn't properly rebase your branch on top of the master branch as your PR shows changes it shouldn't show (e.g. changes to NuimoBluetoothController.cs).

To properly rebase ("sync") your branch please follow these steps: https://help.github.com/articles/syncing-a-fork/, it only takes a few steps. Please don't forget to push your changes at the end.

Inrego commented 8 years ago

I guess I've made too much of a mess in this branch/pull request. I will make a new PR.