Tech in the 603, The Granite State Hacker

Windows 10 IoT Core, C# & Azure IoT Hub for New England Microsoft Developers 12/7/2017

Just wanted to say thanks for inviting me to reprise my Boston Code Camp 28 presentation for the group last night (12/7).   I enjoy talking about development anywhere in the Microsoft stack, and I love that Windows 10 IoT Core + Azure IoT Hub spans a good range of it.  I have a bunch of other topics I’d be happy to share, especially in the Windows 10 domain. Check through this blog, I have a post for each that shares slides, but I know the presentation’s a big part of the value of them.

These slides are really only a tweak of the BOSCC28 slides with the NEMD group title. [office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%211283616&authkey=AH0Ai1kfUL_6WKE&em=2&wdAr=1.7777777777777776″]

Tech in the 603, The Granite State Hacker

MVP IoT with Windows 10, C#, Raspberry Pi and Azure IoT Hub

Boston Code Camp 28 is in the books as one of the greatest community events of recent times in my book.  Attendance was fantastic, we had amazing sponsors, and a ton of great speakers, but the thing that really made things hop was attendance.  I’m personally convinced it was the best attended Code Camp I’ve ever participated in.
As a presenter, I don’t often get to attend as many of the amazing presentations as I’d like, but yesterday I found myself especially regretting that… there was just so much great content from so many great presenters. I did manage to get into more sessions than I usually do… how could I not?

Sure, you get a few “look at this cool stuff I can do” presentations.  These are great for folks looking for inspiration on the tough challenges.  I love the spirit of “look at this cool stuff you can do (if you apply your skills in a modestly different direction)”.
This is why I do this MVP IoT presentation.  This presentation is about taking skills you already know and love (namely C# development) and applying them to what’s classically though of as “embedded” development.  Yes, there’s overhead in this approach…  you might have to use hardware that’s slightly better equipped to handle Windows 10 IoT Core such as the Raspberry Pi 2b & 3b… but the difference is mute at small scale, and masked at large scale by not having to have a separate team with different skills. 

IoT apps on the Windows 10 IoT Core platform ARE Windows 10 apps.


The point I always try to drive home is IoT apps on the Windows 10 IoT Core platform ARE Windows 10 apps.  The very same exe you compile for your embedded device runs just as well on laptop, desktop, server, Windows 10 phone, et al.

I do regret the couple snags I had during my demos.  Still, someone approached me after the presentation with the idea that I should pre-record portions of my presentation in order to avoid these kinds of things.  I like to run live for several real reasons.  1)  I’m a coder, not a professional presenter… I don’t often have time to polish my presentations to that level.  2)  Glossing over rough edges hides what development is.  Development is tough.  You have to have backup plans and contingencies.  My Raspberry Pi didn’t want to connect to the guest WiFi, so I fell back to plan B, and moved on.  It’s a real world scenario;  you hit a snag, but keep pressing on.

IoT is already about the last mile of the Sci-fi story, bringing Internet omnipotence to the fringes of reality, enabling the “Computer” of Star Trek (or the Cortana of the modern desktop) to reach it’s potential (hopefully without becoming Skynet).

It’s the stuff of science fiction… but it’s not fiction.

Visual Studio 2017’s ability to debug into a remote embedded device and make hot changes to a running executable is beyond top notch; it’s the stuff of science fiction… but it’s not fiction.

[office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%211283217&authkey=AKQG9LbQcNcUSkk&em=2&wdAr=1.7777777777777776″]

If you look through my post history, you’ll see how this presentation has evolved over the past decade.  It’s been an interesting evolution…  starting with connecting Windows Phone 7 to SharePoint.  Then Windows Phone 8 and SharePoint online (and the story got really muddy for a bit there).  Then CSOM hit and smoothed out the SharePoint side of things.  I changed the story to Field Enablement using Xamarin for iOS, Android, and Windows Phone with SharePoint as a back end for a bit. (It’s a surprisingly compelling story, even if it’s only academic).  Eventually I started focusing on UWP for Windows 10, and my love of small form factor development drew me back to Raspberry Pi. 
Finally, I’ved bridged off of SharePoint and started talking about Azure IoT Hub, which is the modern accepted best practice in the domain of this development stack.  This change happened so relatively quickly that if you notice, the synopsis for the session didn’t mention it.  (  https://www.bostoncodecamp.com/CC28/sessions/details/16540 )

One can explore the code I developed for the demo at git hub, here:
That leads me to my final bit:  I am sorry I ran out of time in my presentation.  I was so psyched to show how to send telemetry back to Azure IoT Hub, and while I got to step through the code that sends updated reports, I did not get to explore any of what that looks like in the Azure IoT Hub portal, and didn’t get to explore the event-driven API on the embedded side that allows you to send code with Device Twin down to a the device.
Here’s the event that commits the post:

        private async void iotHubButton_Click(object sender, RoutedEventArgs e)

{

try

{

using (var client = DeviceClient.CreateFromConnectionString(

$"HostName=BOSCC-IOTHub.azure-devices.net;DeviceId=GraniteStHacker;SharedAccessKey={Credentials.LuisAccessKeyFromAzurePortal}",

TransportType.Mqtt))

{

var twinProperties = new TwinCollection();

twinProperties["MeasuredTemperature"] = manager.MeasuredTemperature;

twinProperties["HeaterPowerOn"] = manager.HeaterPowerOn;

twinProperties["ACPowerOn"] = manager.ACPowerOn;

twinProperties["Device_BOSCC"] = DateTime.Now.ToString();

await client.UpdateReportedPropertiesAsync(twinProperties);

Console.WriteLine("Done");

}

}

catch(Exception ex)

{

Console.WriteLine(ex);

}

}

}


Click the image below to see the device I was using for the demo in Azure IoT Hub’s Device Twin view.

Here’s the resulting Device Twin JSON:
{
  “deviceId”: “GraniteStHacker”,
  “etag”: “AAAAAAAAAAE=”,
  “version”: 8,
  “status”: “enabled”,
  “statusUpdateTime”: “0001-01-01T00:00:00”,
  “connectionState”: “Disconnected”,
  “lastActivityTime”: “0001-01-01T00:00:00”,
  “cloudToDeviceMessageCount”: 0,
  “authenticationType”: “sas”,
  “x509Thumbprint”: {
    “primaryThumbprint”: null,
    “secondaryThumbprint”: null
  },
  “properties”: {
    “desired”: {
      “$metadata”: {
        “$lastUpdated”: “2017-11-14T01:48:45.8322179Z”
      },
      “$version”: 1
    },
    “reported”: {
      “MeasuredTemperature”: 74,
      “HeaterPowerOn”: true,
      “ACPowerOn”: false,
      “Device_BOSCC”: “11/18/2017 8:34:08 AM”,
      “$metadata”: {
        “$lastUpdated”: “2017-11-18T16:34:20.1258514Z”,
        “MeasuredTemperature”: {
          “$lastUpdated”: “2017-11-18T16:34:20.1258514Z”
        },
        “HeaterPowerOn”: {
          “$lastUpdated”: “2017-11-18T16:34:20.1258514Z”
        },
        “ACPowerOn”: {
          “$lastUpdated”: “2017-11-18T16:34:20.1258514Z”
        },
        “Device_BOSCC”: {
          “$lastUpdated”: “2017-11-18T16:34:20.1258514Z”
        }
      },
      “$version”: 7
    }
  }
}

Tech in the 603, The Granite State Hacker

Intro to IoT with C#, Windows 10 on Raspberry PI 3a, a la #BOSCC26

Despite the time crunch, I had expected to be able to dig in on more of the example code I’d prepared (heck, wouldn’t have spent so much time pulling that together if I’d thought I wasn’t going to get to it.)

I’ll also admit, my slides were more of a discussion guide than details, but there are a few good url’s in there to get you going with a PI or other IoT starter kit.

[office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%211258505&authkey=AH4O2F_Cu16yiaE&em=2″ width=”402″ height=”327″]

GIT repository for the demo code
https://github.com/GraniteStateHacker/BOSCC-GPIO

Feel free to reach out to me with questions, I’m happy to help!

Tech in the 603, The Granite State Hacker

Intro to Windows 10 Universal Devices and Raspberry Pi

I really enjoyed presenting “Intro to Windows 10 Universal with Raspberry Pi” to the Granite State Windows Platform App Devs (#WPDevNH) this past week. 

Here’s the slides which have a few decent links in them to get you started.

[office src=”https://onedrive.live.com/embed?cid=90A564D76FC99F8F&resid=90A564D76FC99F8F%21470743&authkey=AFGBvV7-jEFyGVA&em=2″ width=”402″ height=”327″]

I will try to get a presentation on the next part of this sometime over the next couple months, with a dive in on the GPIO libraries.

Check out the group’s Meetup site for stuff going on going forward.

http://www.meetup.com/Granite-State-NH-WPDev/

Tech in the 603, The Granite State Hacker

Google’s Challenge, by the Numbers

Google may have inadvertently worked itself into some awkward dependencies that could be troublesome for it in the next few years.

It’s hard to imagine Web 2.0, now a decade gone by, as the peak of the web, but I think the numbers speak volumes about it.  Below, I’ve grabbed some stats from Wikipedia, as of today (4/26/2015) ( http://en.wikipedia.org/wiki/Usage_share_of_operating_systems ), that puts together some puzzle pieces together in my head, but introduces a few new ones. 

Originally, I was thinking about Windows market share this past weekend, and how absurd it is that folks think of Windows 8/8.1 a “failure”… (It came up at the Global Azure Cloud Camp Jim O’Neil hosted at BlueMetal’s office in Watertown this past Saturday.)  There’s more Windows 8+ machine (alone) than all versions of Mac OS X combined…  Microsoft’s “failure” is only a failure when compared to Windows XP and Windows 7.

Desktop operating system browsing statistics
Windows 7
  
58.04%
Windows XP
  
16.94%
Windows 8.1
  
10.55%
Mac OS X 10.10
  
3.96%
Windows 8
  
3.52%
Windows Vista
  
1.97%
Mac OS X (other)
  
1.71%
Mac OS X 10.9
  
1.61%
Linux
  
1.5%
Windows (other)
  
0.2%

Windows 8 / 8.1 comes sums at roughly 13%, while OS X (all versions) is (estimating generously) 8%.  So 13% may be a failure compared to Windows 7’s 58%….  but no one thinks of OS X’s 8% market share as anything less than a smash hit.  

I get that the terms of failure for 8.x come from it’s largest customer, the enterprise market, which has largely ignored it. It’s why Windows 10 is a significant comeuppance for Microsoft.

All told, though, among desktop OS’s, Windows is king.  No surprise there, really.  That’s only the beginning of the story. 

Some of the other stats started to catch my attention with respect to all devices, and what folks are using them for.

From the same Wikipedia page:

According to Gartner, the following is the worldwide device shipments (referring to wholesale) by operating system, which includes smartphones, tablets, laptops and PCs together.

Worldwide Device Shipments by Operating System
Source Year Android iOS/OS X Windows Others
Gartner[1] 2014 48.61% 11.04% 14.0% 26.34%
Gartner[2] 2013 38.51% 10.12% 13.98% 37.41%
Gartner[3] 2012 22.8% 9.6% 15.62% 51.98%

The above table establishes that “device” shipments of Windows devices is relatively small compared to Android devices, with Apple devices coming in 3rd overall.  If we set form factor aside and look at all consumer “computing devices”, Android is undeniably tops, and has been for a few years already.

Now look at this…  (a breakdown of what OS folks are using web browsers on.)

Web clients’ OS family statistics
Windows
  
55.74%
Linux based
  
22.02%
iOS, OS X
  
17.17%
Symbian, S40
  
2.02%
Other
  
3.05%
Linux based is actually composed of both desktop and Android based devices… digging a bit, the stat that shows Android usage specifically shows it at less than half of “Linux” based stats.

See the rub?

The web is unequivocally consumed by desktops, which are owned by Windows.

Android… the most popular consumer “device” (by an allegedly monopolistic margin in some markets), represents less than half the web traffic.

Either the margin of error is so far off these stats, rendering them all useless, or there’s an interesting story there.

This means the good old browser is being left behind by mobile devices.   This has been observed before, but it’s interesting to note that Google’s hanging on it.  I mean, what’s your home page?  If you’re like a lot of folks, it may well be www.google.com.

Here’s a question.  Is the browser propping up Windows, or is Windows propping up the WWW?

Here’s an answer…  Microsoft’s go-forward strategy is Mobile First / Cloud First.  Windows 10 is a mobile OS that supports desktops, not a desktop OS that supports mobile.  Clearly, Microsoft is taking risks, but their goal is to push Windows into the mobile app world, taking only the parts of the world wide web that are important to mobile and cloud.

One might argue that Windows 10 includes both IE 12 and the Spartan browser.  Further, Microsoft is just releasing a new ASP.NET and MVC web development tools.

No matter what, the web app is not going to vanish overnight.  Still, Microsoft adding yet another browser and more tools is 1) further fragmenting the already terribly fragmented web app platform, 2) a bone thrown to the many enterprises who have built their infrastructure on web technology and can’t afford to fully shift their enterprise app platform (and developer skill set) to mobile apps in the next few years, and 3) continued support for the still critical http protocol that is a core network transport for everything in the Internet of Things.

One might argue Office 365.  The backfire there:  pretty much everyone who has Office 365 also has desktop and even mobile apps.  This leaves Office 365 to be primarily a services back end for those apps, with a web-based UI as a fallback if you for some reason can’t run the native apps.

Apple’s iOS success and Google’s Chromebook failure led Google to cannibalize itself into the (unexpectedly?) wildly successful Android.

Android’s success, in turn, is eating away at Google’s classic model…  Google will likely always be a media platform first, but more and more, that media platform is being confined to (and defined by) Android.  (Like a genie enslaved to its bottle…  “Phenomenal cosmic power, itty-bitty living space.)

All in all, I’ll go out on a limb and say that Microsoft is about done propping up the consumer web as an application platform.

Still, forgetting what Microsoft is doing, Google is SaaS heavy, and has no PaaS or IaaS offering to fall back on.  They have no desktop OS to elevate them.  All the cards in their foreseeable future appear to rest on Android (and therefore Samsung).

With the anti-trust suits already starting against Google because of Android, it’s hard to really see Google’s future over the next decade.

Being at the top, it’s pretty easy to say Android is peaking.   The question is where does that leave Google.  YouTube?  Self-driving cars?

I find myself thinking it makes a bit more sense that Apple and Yahoo have aligned their search with Bing.

What am I missing?