Windows 10 IoT Core / Raspbian on Raspberry Pi 2 using Windows 10’s Internet Connection Sharing (ICS)

You just got yourself a Raspberry Pi 2 (RPi 2). You could be running Raspbian or Windows 10 IoT Core. You don’t have access to a hub/switch/router to connect the RPi 2 for Internet connection. The next best solution is by connecting the RPi 2 to your PC via Ethernet and sharing your Wi-Fi’s internet connection via Internet Connection Sharing (ICS). When you go to the Wi-Fi adapter properties, you got some bad news:WiFi-ICS-disabled

What do you do? Here’s a workaround which is definitely NOT endorsed by your friendly network administrator, but it works. NOTE: This workaround is NOT permanent and it is not meant to flout your network administrator’s group policy because they are rules for good reasons; security, etc. 

  1. To enable sharing on the WiFi adapter, run the following command in a Command Prompt run as Administrator.
netsh wlan set hostednetwork mode=allow

 

  1. Run regedit. Go to Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Network Connections. Edit NC_ShowSharedAccessUI, and enter 1 in value data.
  1. Go back to Wi-Fi adapter properties, now you will see the Sharing tab. In case you don’t see the Sharing tab, this could be due to the reason that you have not connected your Ethernet adapter (for those that comes in a USB dongle). You need at least two network adapters to be present in order to do ICS. Check the box that says “Allow other network users to connect through this computer’s Internet connection”.

WiFi-ICS-avail

  1. Go to your Ethernet adapter properties. Check out the Internet Protocol Version 4 (TCP/IPv4) Properties. You will see the following preconfigured for you. Do not change these settings.

ethernet-ipv4settings

 

  1. Connect the network cable between your Raspberry Pi 2 and your Windows 10 machine via the Ethernet port.
  1. When you start up your Windows 10 IoT Core on your Raspberry Pi 2, you will see that the IP address is dynamically set to an IP address like 192.168.137.2. Voila, this means that you have Internet connection shared with your RPi 2.
RPi2-win10-dashboard

7. Follow the PowerShell documentation here to use PowerShell to connect to your running device. You can also follow the instructions here to use SSH to connect to your device.

From <http://ms-iot.github.io/content/en-US/win10/SetupRPI.htm>

  1. To make sure ICS is enabled properly, just ping any Internet site.

pinganysite

To start sending events from Windows 10 IoT Core to Azure IoT Hub:

In your Visual Studio 2015 UWP project, go to your project properties, and configure the remote machine IP.
vs2015-rpi2-props

Configure remote machine IP as 192.168.137.2, or any other IP address which you got from Step 6. Run your project.

Check Device Explorer for event has been received at the IOT Hub.deviceexplorer

Finally, a word of caution. If you don’t see ICS sharing available in your Wi-Fi adapter settings anymore, this is because the group policy has been re-applied to your machine. That’s ok, it’s meant to protect your machine after all. When you need to enable ICS for another instance, just re-do the steps above.

Using Azure WebJobs as an IoT data points ingestor

My GetFitY’all project has evolved again, obviously. Previously I intended to implement the message pump functionality as a RESTful endpoint that can be called automatically from some form of “cron job” in the cloud. But then I digress because a simpler approach could be used which is Azure WebJobs. It works well in my case because I already have a GetFitY’all Azure website which serves to provision users and to allow them to authorize GetFitY’all server-side to ingest data points from the various activity sources. My data points source have expanded to include MapMyFitness API besides Strava API and Fitbit API.

Implementing the WebJob is simple as I just pulled out the Azure WebJobs sample solution from ASP.NET CodePlex. I chose to implement a manual trigger which starts the method to ingest activity data points from my data sources. The code looks like the following:

static void Main(string[] args)
{
JobEnvInitializer();
JobHost host = new JobHost();
host.Call(typeof(Program).GetMethod("ManualTrigger"));
host.RunAndBlock();
Console.WriteLine("\nDone");
}


[NoAutomaticTrigger]
public static void ManualTrigger([Table("ActivityDatapointsProcessingLog")] CloudTable logTable)
{
GetFitYallAsync(logTable).Wait();
}

The data points ingestor cum message pump is meant to simulate a device gateway. And only if I could get my hands on the Azure Intelligent Systems Service limited beta, I could further use the ISS software agent to be embedded with my “device gateway”.  This is illustrated in the devices topologies below:

Source: https://connect.digitalwpc.com/Pages/SessionDetail.aspx?sessionId=9040ae74-c1b6-e311-8491-00155d5066d7Source: BD516 Building an Intelligent Systems Business with Microsoft Azure Services

Leveraging ISS agent on the gateway is good because all the IoT workflow would be managed by ISS including the sending of the data points as queue message. Currently  I have implemented some of the workflow on my own as some form of message pump (see below). Ideally I just want to focus on the simple device gateway logic of ingesting data points from multiple device APIs, and of course the fun parts of doing self-analysis of my IoT data points.

The “devices gateway” acts as a message pump to send each data point as a message via AMQP to the Azure Event Hub. This is meant to decouple the processing of these messages from the message pump. The Azure Event Hub is a highly scalable publish-subscribe ingestor that can intake millions of events per second and can handle huge throughput.

That piece of code looks like this:

// use RedDog.ServiceBus helper class to generate SAS
var sas = EventHubSharedAccessSignature.CreateForSender(senderKeyName, senderKey, serviceNamespace, hubName, deviceName, new TimeSpan(0, 120, 0));
var factory = MessagingFactory.Create(ServiceBusEnvironment.CreateServiceUri("sb", serviceNamespace, ""), new MessagingFactorySettings
{
TokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider(sas),
TransportType = Microsoft.ServiceBus.Messaging.TransportType.Amqp
});
var client = factory.CreateEventHubClient(String.Format("{0}/publishers/{1}", hubName, deviceName));
// iterate through the 4 Lists and compose an ActivityDataPoint object and fire off the message using Event Hub
int cnt = intraDaySteps.DataSet.Count;
var procTasks = new List();
for (int i = 0; i < cnt; i++)
{
FitbitDataPoint adt = new FitbitDataPoint();
adt.Time = intraDaySteps.DataSet[i].Time;
adt.Steps = intraDaySteps.DataSet[i].Value;
adt.StepsLevel = intraDaySteps.DataSet[i].Level;
adt.CaloriesOut = intraDayCaloriesOut.DataSet[i].Value;
adt.CaloriesOutLevel = intraDayCaloriesOut.DataSet[i].Level;
var data = new EventData(System.Text.Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(adt)));
data.PartitionKey = userName;
data.Properties.Add("Type", "Fitbit");
procTasks.Add(client.SendAsync(data));
}
await Task.WhenAll(procTasks);
procResult.Success = true;

A FitbitDataPoint object is constructed for each data point retrieved from the Fitbit API. This is then serialized into JSON and added as EventData. The partition and a simple property to identify this message as a Fitbit data point is set to the EventData object. Finally a simple SendAsync() sends this to the Event Hub using  Microsoft.ServiceBus.Messaging.TransportType.Amqp. I am using RedDog.ServiceBus which is a really nifty library which you can install using NuGet. Full credit goes to Sandrino Di Mattia, I learned a lot from his blog post about IoT with Azure Service Bus Event Hubs.

Similar code goes for Strava and MapMyFitness data points. When I’m done,  I just have to publish this WebJob to Azure. This can be performed in Visual Studio itself but please make sure that you have installed Visual Studio 2013 Update 3. This is because the WebJobs deployment features are included in Update 3. I won’t describe the steps here because there is already a great article about How to Deploy Azure WebJobs to Azure Websites. Also check out Get Started with the Azure WebJobs SDK

publishwebjob

 

All is fine and dandy, I could execute my WebJob and the message pump works like a charm in firing off the AMQP messages to my Event Hub. But there’s a problem which I haven’t been able to troubleshoot, my web jobs always abort.

webjobs-aborted

 

Maybe it is due to what is described by Amit Apple that WebJobs only run continuously in an “Always on” Azure website and this is not available in the free and shared websites. But then my webjob is not meant to run continuously, it just runs and finishes upon firing the message pump. The WebJobs dashboard should display a successful run. *scratch head*

As a final confirmation that there’s indeed some “action” on the part of my Event Hub, here’s my GetFitYall Azure Event Hub dashboard.

eventhubdashboard

Moving up the Internet of Things Value Chain

Fragmentation == Opportunities

I reckon that I don’t need to make an introduction about the Internet of Things because there are enough resources out there to explain what it is and also the opportunities around it. Thus far the market seems highly fragmented as there are a number of players operating within the IoT space without directly competing. This condition typically appears for new business or market during its nascent stage. Competition usually heats up as the market develops and matures. However the key differentiator for a successful company is to identify the market opportunities early on by being “customer-obsessed” to the point that solutions would encompass many stages within the IoT ecosystem. Such are the opportunities that lie within the IoT value chain.

The Internet of Things (IoT) solutions are very fragmented, they are either custom and unrepeatable or incompatible with existing infrastructure, with incomplete and unprotected data access and insights. Fragmentation is both a challenge as well as an opportunity. This blog post describes how a typical IoT vendor be it a device manufacturer, solution provider or system integrator can move up the IoT value chain by taking advantage of these fragmentation opportunities and offer a proposed solution in the form of an IoT Services Platform to its customers and partners.

Opportunities

The goal is to ensure that your company becomes the device manufacturer or SI of choice among customers and every player within the IoT value chain. More players are anticipated along every stage in the IoT value chain. IoT players would have a healthy relationship of collaboration, competition and dependence on each other along the value chain. Customers are highly dependent on data, information and insights. The success criteria is fast time to market, repeatable IoT vertical solution that meets customers’ business objectives.

Tremendous value could be realized from the following simple chevron process:

iotchevron

In the following examples, I am painting the picture of how an IoT device or module manufacturer can provide value in each of the process above.

  • Be the de facto module/device manufacturer by helping new entrants achieve faster time to market, be it a managed services company, a cloud platform IoT provider or a CRM/Big Data analytics company. This promotes dependence on your modules and devices. Successful partners would influence the sales of the modules and devices.
  • Provide a modular approach to helping these new entrants build their customised IoT vertical solutions using your IoT Services Platform. Basically avoid reinventing the wheel and allowing more time on product and solution innovation. Overall this is all part and parcel of building a healthy IoT ecosystem.
  • Upsell consulting and premium support services to System Integration partners who require help, guidance and support to integrate with the IoT Services Platform.
  • Architect the IoT Services Platform as a gateway of telemetry collection being able to process large-scale telemetry data streams generated by the devices and hardware developed by yourself, but beyond that manage other devices and services too.
  • Data is not the only raw material being unlocked by the IoT it is also the ability to perform command and control of devices.

As a result of taking advantage of these opportunities

  • Recurring revenue through a subscription model.

o   E.g., a vertical IoT software platform partner can subscribe to the IoT Services Platform to enable the ingestion of IoT device telemetry streams. This especially makes sense because of the large-scale telemetry data streams and equally high-volume of instructions that needs to be communicated to the devices in the field.

  • Win-win Partnership models – solution partners pay as their business grows
  • A vibrant partnership ecosystem whereby more IoT vertical solutions are launched into the market with reliance on your modules/devices or the IoT Services Platform.
  • Be what’s next in “Product Relationship Management”, it’s beyond buzz words such as CRM, Big Data or BI.

 

What an IoT Services Platform may look like?

IoTServicesPlatform

 

An IoT Services Platform offers a services & software platform to help customers and partners gain new insights, optimize business processes, make more informed decisions and identify new revenue opportunities. The platform performs the heavy-lifting and plumbing services such as IoT device management, telemetry collection, interactivity, notifications, servicing, etc. This would remove the barrier to entry for many IoT players, allowing them to just focus on IoT vertical solutions.

More importantly, having this platform allows an IoT provider to actively pursue IoT verticals such as smart metering, eHealth, Building Automation, Digital Display, Light Industrial scenarios. It allows it to customise solutions to meet individual customer requirement. It also promotes the best of breed partnerships as it continues to partner with large, established IoT players to deliver solutions in various verticals such as utilities, transportation, healthcare, government and consumer.

 

Business Model

The business model of this platform is one that relies on the success of IoT market which is huge. Monetization is based on the following business models:

Consumption model

  • Pay-as-you-go allows broader, wider adoption among smaller players in the IoT ecosystem

Subscription model

  • Allows medium and bigger players to leverage the economies of scale of this platform by committing to subscription contracts.
  • Provides good recurring revenue.

Premium Consulting and Support Services

  • Pay per support incidents
  • Support contracts with enterprises and medium to big business partners

 

Summary

Many existing IoT providers have the first mover advantage in the IoT ecosystem. It can continue to extend such an advantage by taking its lead in moving up the value chain. Such a move does not necessarily compete with its partners because it addresses the opportunities which could be leveraged by any player within the IoT market. By providing an IoT Services Platform whereby products, solutions and innovation from any player could thrive within the IoT market, the ecosystem becomes larger and healthier. One company getting a bigger slice of the proverbial pie is one thing. However a bigger pie is everything.

An IoT Services Platform serves as a great framework and also infrastructure for either custom or repeatable IoT vertical solutions could be engineered. This brings a two-fold benefit because it promotes dependence and loyalty on its solutions or hardware modules and devices. This bolsters its existing hardware business. The next opportunity is to take advantage of new business models described in this white paper to leverage new revenue streams which are recurring in nature.

This is all part and parcel of moving up the IoT value chain.