GPS Library for Windows 10 IoT and Raspberry Pi

I am tinkering with Raspberry Pi 3 (RasPi) and Windows 10 IoT Core. I was thinking how to build an IoT device with GPS functionality in RasPi. Many IoT projects employ GPS module but they use it mostly with Arduino to build quadcopter. Some people tried it with RasPi, but they use it in Raspbian OS. No one seems tried to build directly with RPi and Windows.

So, I made my own implementation, a library to connect Windows apps with GPS device. Long story short, you can make Windows app running on RasPi which utilize GPS, and you can code it on C#.

Check the code on GitHub. The library is licensed under GNU Lesser General Public License v3. You may use it in your project while retaining the license and credit to me. 🙂

How To Use

You just simply to download the binary release, or compile it on your own. Then add reference to Heliosky.IoT.GPS.dll in your project.

To use the library, you can add usings below to simplify the class resolution.

Continue reading “GPS Library for Windows 10 IoT and Raspberry Pi”

Generics in WCF REST JSON Communication

Overview

So I got a task in designing a scalable and modular Service Oriented application using JSON and WCF. I am designing a web service using WCF. The communication between the web service and the client will be using JSON. While the server is using .NET Framework, the client is using Android Java. I aim to design the service as modular as possible. For every web service request from the client, the server will return the response in some kind of “envelope”. The “envelope” contains the execution result, whether it is success or not, the text message from web service, and the attachment which may contains object of specific type as the result of the service call.

I want to develop the modularity in my service framework, where I can make the “envelope” object as generic object that accept any kind of attachment type. And I want to deserialize the JSON response from server in my Android directly into specified “envelope” and attachment type, so that I can use it fairly easy in my code.

Prerequisite

Continue reading “Generics in WCF REST JSON Communication”

Entity Framework: Design Approach

I’ve been using Entity Framework since its introduction. Entity Framework (EF) is a powerful Object-Relational Mapping (ORM) framework for .NET Framework. I’ve been debating with my teammates whether EF is better than other ORM such as OpenAccess, which I believe is true, because EF provides the necessary feature to connect our program to the database, especially if you are using Microsoft products, SQL Server. In my thinking, why bother using custom ORM to connect to SQL Server while actually Microsoft, the creator of everything (well, not, only .NET Framework and SQL Server I’m talking about here) provided the powerful tools to support your needs. In fact, Microsoft fully support the EF and provides the latest features as their development (EF and SQL Server) (should) inline each other.

Ok, I’m not going to debate about which one is better. I am going to talk about Code First approach to build your model from scratch. This is the first time I am trying using Code First approach, while previously I always use Database First or Model First approach.

Ways to Model Your Database

Entity Framework has been evolving quite rapidly. In the newest version, I noticed they are now using DbContext class instead of the old ObjectContext. And the new generated classes (if you are generating the model from existing database), will be just Plain-Old-CLR-Objects (POCOs). In previous EF, all the model classes must be derived from EntityObject. This offers more flexibility in designing your model classes.

One other notable changes I found is that the entity framework do not require the resource file definition in the connection string anymore. This will offer more flexibility in porting your model into separate DLL library and reuse it wherever you want. I am going to explore this finding later.

So to model your database, you can use three different approach: Database first, Model first, or Code first. Below is the explanation of each one of the way
Continue reading “Entity Framework: Design Approach”

Story of Modularity: Loading XML Files

Previously I told about achieving modularity in web application and I mentioned about using XML files as a configuration script for our module. This session, I’m going to explain the easy way to load external XML file to your program. This method doesn’t only work on web application, but in any .NET application.

Where to Start?

I usually start developing custom XML structure by typing directly to my XML file. It is some kind of prototyping your XML structure. In this case, I am going to develop an XML file that contains a configuration information for my modular theming system. The XML file will describe the theme description and theme structure which is a list of ASPX pages that is inside that theme file. For each pages in theme, they should contains the type of the page, title of the page, identifier, and ASPX file name of the page.

From that requirement, I could derive my new theme file is something like this:

Continue reading “Story of Modularity: Loading XML Files”

Story of Modularity: Achieving Modularity in Web Application

In my Heliosky.Story project, I am planning to create modularity on every part of the system. To achieve modularity, my program has to be able to load module or application part dynamically. Achieving modularity in web programming is not an easy task. Basically I am amazed with WordPress style of modularity, where they provide a full set of modular API so you can easily develop your custom theme, page, or plug-in in a logical manner. As we know, WordPress is built on top of PHP, a scripting language. Every module or application part in WordPress is a PHP script.

Continue reading “Story of Modularity: Achieving Modularity in Web Application”