Windows 10 IOT Remote Display Experience

With Microsoft Build 2016 complete, there are so many things to be looking at and trying out.   One of the more useful features for me right now is the new remoting functionality in Windows 10 IoT Insider Preview 10.0.14295.   I have this running on a Raspberry Pi 3 and I am busy with some work using an array of sensor telemetry.  Being able to see what is happening remotely make life far easier when building Universal Apps.

To configure this is very simple.    There is a new menu option added to the administration console called “Remote”.  This is accessible via the URL:  http://[ipaddress of pi]:8080.   If you haven’t changed the password the login should be:  “Administrator” and “p@ssw0rd”

IoT Remoting

Enable the Windows IoT Remote Server by ticking the box presented.

 

To access the Raspberry Pi remotely you need a client.   This is available in the Windows Store either by following the provided link, or just by searching for “Windows IoT” in the store.  https://www.microsoft.com/store/apps/9nblggh5mnxz

 

remote client

 

This will run on any Windows 10 device.   Just something to note: on a Windows 10 Mobile device (Lumia 950 XL in my case) you may have to set the device color scheme to light for the application text to be legible.  I’m sure this will be corrected in later builds.

iot client

Fill in the IP address of the Raspberry PI in the “Enter an IP address” text box and click / tap “Connect”.  You should now be seeing what the Raspberry Pi is displaying.

WP_20160403_16_42_25_Pro_LI
Remoting to a Windows 10 PC / Tablet
WIN_20160403_17_10_17_Pro
Remoting to a Lumia 950 XL

 

Running ASP .NET vNext on a pcDuino

Microsoft is doing a lot of great things at the moment.  One of these is the ability to run ASP .NET vNext away from a Windows Server, and away from IIS.    Being a ASP .NET Mvc developer for a few years now, the idea to run on any environment is quite liberating.

 

A pcDuino is a device with tons of potential.   It’s a powerful device and it really is a full “mini PC” with enough processing power to do interesting things like image processing.    But is small enough to be used in situations where you would uses an Arduino, Netduino, RFduino etc in the IoT or maker space.   The pcDuino also has an Ethernet port and on-board WiFi, so it is a rather compelling internet connected device.

Having deployed Mono on my board already, it was also a no brainer to extend that and to explore the potential of an internet connected device but leveraging ASP .NET vNext to do that.

 

asp net web server

ASP .NET Web Server (with Arduino Uno and Xamarin Monkey used for scale)

 

 

To get started read these two blog posts:

 

Now that we have both Ubuntu and Mono installed, we can now begin getting ASP .NET vNext up and running.

To figure out how to do this, I referred to the ASP .NET github repository, “Getting Started” page.  This page can be found here:  https://github.com/aspnet/Home

 

Lets start by installing the necessary certificates.

$ CERTMGR=/usr/local/bin/certmgr
$ sudo $CERTMGR -ssl -m https://go.microsoft.com
$ sudo $CERTMGR -ssl -m https://nugetgallery.blob.core.windows.net
$ sudo $CERTMGR -ssl -m https://nuget.org
$ sudo $CERTMGR -ssl -m https://www.myget.org/F/aspnetvnext/
$ mozroots --import --sync

 

We need curl, so install that next

$ sudo apt-get install curl

 

Download and execute the KVM installer on the ASP .NET site.   As of writing this,  the master branch has the 1.0.0-beta1, so we will use that.

$ curl https://raw.githubusercontent.com/aspnet/Home/master/kvminstall.sh | sh && source ~/.kre/kvm/kvm.sh
$ kvm upgrade

 

Check to see if the installation is correct, you should see the version number reflected with the list command.

$ kvm list

 

If git is not already installed, install git next.

$ sudo apt-get-install git

 

The web server ASP .NET vNext uses (Kestrel), is based on Libuv, so we need to install that next.

$ git clone https://github.com/libuv/libuv.git
$ cd libuv
$ sh autogen.sh
$ ./configure
$ make
$ make check
$ sudo make install

 

Now we need something to run.  Lets use one of the samples from the ASP .NET github repository.for simplicity.  Clone the aspnet repository.

$ git clone https://github.com/aspnet/Home

 

Focusing on the Mvc example, change to the directory “HelloMvc”.    To resolve and download the necessary dependencies for the project, execute a restore command on the package manager “KPM”.

$ cd Home/samples/HelloMvc
$ kpm restore

 

We need to set up a symbolic link for libuv to avoid any “Object Reference not set to an instance of an object” errors.    This is not the most helpful or informative of error messages, but we get what it means.

 $ ln /usr/local/lib/libuv.so -sf ~/.kpm/packages/Microsoft.AspNet.Server.Kestrel/1.0.0-beta1/native/darwin/universal/libuv.dylib

 

Run the Kestrel server

$ LD_LIBRARY_PATH=/usr/local/lib k kestrel

 

If all goes well you should see “Started” appear on the command line.

$ Started

 

The default port for kestrel is 5004.   As a test navigate to “http://localhost:5004” using the internal pcDuino Chromium browser.     The sample ASP .NET Mvc application should appear as below.

 asp .net vnextAsp .NET Mvc site up and running on Mono 3.12.0

 

Find the ip address of the pcDuino using the ifconfig command.

$ ifconfig

 

Use this ip address from a remote device (or pc’s) browser.   The great feature of the pcDuino that it is equipped with both an Ethernet port and WiFi so connectivity is very easy and convenient.

 

Congratulations you now have a Mono / NET powered IOT device running ASP .Net vNext!   A mobile wireless web server / web connected device has endless potential.   In future blog posts I hope to explore some of those.

 

I hope this was helpful!

Mono Compilation on a pcDuino

Being a C# .NET developer and a Xamarin developer, it was just a matter of time before I had to have Mono on my pcDuino.    A default package installation of Mono on any ARM (ARMhf) device (like the pcDuino with it’s A20 processor) at this moment is unfortunately not possible as it’s not available yet.  However luckily Mono can be compiled directly on the pcDuino.   I’ll share my exploration of building Mono 3.12.0 here.

Attempting to install the current Mono packages on a system with an ARMhf processor will currently yield the following unfriendly error messages:

sudo apt-get install mono-devel
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
mono-devel : Depends: mono-runtime (>= 2.10.1) but it is not going to be installed
Depends: libmono-cecil-private-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono-cecil-private-cil (< 3.12.1) but it is not going to be installed
Depends: libmono-codecontracts4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-compilerservices-symbolwriter4.0-cil (>= 3.6.0) but it is not going to be installed
Depends: libmono-corlib2.0-cil (>= 3.2.8) but it is not going to be installed
Depends: libmono-corlib4.5-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono-peapi2.0a-cil (>= 3.2.8) but it is not going to be installed
Depends: libmono-peapi4.0a-cil (>= 3.2.8) but it is not going to be installed
Depends: libmono-relaxng4.0-cil (>= 2.10.1) but it is not going to be installed
Depends: libmono-security2.0-cil (>= 3.0.6) but it is not going to be installed
Depends: libmono-security4.0-cil (>= 3.0.6) but it is not going to be installed
Depends: libmono-system-componentmodel-composition4.0-cil (>= 3.0.6) but it is not going to be installed
Depends: libmono-system-componentmodel-dataannotations4.0-cil (>= 3.2.3) but it is not going to be installed
Depends: libmono-system-configuration-install4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-configuration4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-core4.0-cil (>= 3.2.8) but it is not going to be installed
Depends: libmono-system-data-linq4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-data2.0-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono-system-data4.0-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono-system-numerics4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-runtime-serialization4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-runtime4.0-cil (>= 2.10.1) but it is not going to be installed
Depends: libmono-system-security4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-servicemodel4.0a-cil (>= 3.2.3) but it is not going to be installed
Depends: libmono-system-web-services4.0-cil (>= 1.0) but it is not going to be installed
Depends: libmono-system-web2.0-cil (>= 2.10.3) but it is not going to be installed
Depends: libmono-system-xml-linq4.0-cil (>= 3.0.6) but it is not going to be installed
Depends: libmono-system-xml4.0-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono-system2.0-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono-system4.0-cil (>= 3.12.0) but it is not going to be installed
Depends: libmono2.0-cil (>= 3.6.0) but it is not going to be installed
Depends: mono-mcs (= 3.12.0-0xamarin3) but it is not going to be installed
Depends: mono-gac (= 3.12.0-0xamarin3) but it is not going to be installed
Depends: mono-xbuild (= 3.12.0-0xamarin3) but it is not going to be installed
Depends: libmono-cil-dev (= 3.12.0-0xamarin3) but it is not going to be installed
Depends: libmono-2.0-dev (>= 3.12.0-0xamarin3) but 3.2.8+dfsg-4ubuntu1 is to be installed
Recommends: mono-csharp-shell but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

 

To solve this problem we will make our own ARMhf targeted build. Let’s start by finding a USB memory stick or a SD card with sufficient space.   The Mono source repository is quite large and it occupies about two gigabytes of storage. I would suggest a size of four gigabytes or more (I used an eight gigabyte module myself).  Make sure it’s formatted to the Ext file system.  FAT32 will not work for compilation.  I wasted a good couple of hours with error messages caused simply by the chaos caused using the wrong file system.

 

To figure out what to do, I referred to the official Mono documentation for the installation steps I list below.   These compilation instructions can also be found here on the Mono site:  http://www.mono-project.com/docs/compiling-mono/linux/

 

Let’s first make sure we have the tools available to build Mono.

 

$ apt-get install git autoconf libtool automake build-essential gettext

 

Clone the Mono source code from the git repository.

 

$ cd /media/[path to your external media]
$ git clone git://github.com/mono/mono.git

 

The cloning of the Git repository can take a while depending on the internet connection.   The size of the repository is just under two gigabytes so try to be patient.

 

The entire process of compilation will take about five hours on the pcDuino, so best to do this overnight..

$ cd mono
$ git checkout mono-3.12.0-branch
$ git submodule init
$ git submodule update --recursive
$ git submodule

$ ./autogen.sh --prefix=/usr/local --with-sgen=yes --with-large-heap=yes --with-xen_opt=no --enable-parallel-mark --with-libgdiplus=/usr/local/lib
$ make get-monolite-latest
$ make EXTERNAL_MCS="${PWD}/mcs/class/lib/monolite/gmcs.exe"
$ make

Build in progress!

 

monocompiling

 

Compiling is complete!  So to conclude we will install the build locally.

$ sudo make install

 

Once installed check the Mono version.

$ mono --version

 

If you are seeing the message below, congratulations you have successfully built Mono 3.12 on your device!

Mono JIT compiler version 3.12.0 (mono-3.12.0-branch/501f5a9 Mon Feb 2 12:41:29 UTC 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: normal
Notifications: epoll
Architecture: armel,vfp+hard
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

 

For the non-adventurous or if you are just needing to save time, you can download my Mono-3.12.0 package here:  http://1drv.ms/1zvLtgN

 

Now that we have mono installed we can explore some pcDuino .net (c#) related topics in future posts.

Rolling your own Android Emulator

In certain situations the emulators provided just don’t cut it.      It is actually relatively simply to create your own by just using an x86 image of Android.   It is also possible to add additional features to the emulator for testing by virtue of daemons installed.

 

Download Android X86 iso image of choice from http://www.androidx86.org/download

 

Boot ISO in Hyper Visor of choice. (Android will work in VMWare, VirtualBox and Hyper-V) 

 

Install any GPS, Accelerometer, orientation etc spoof daemons of choice

 

Android Debugger Bridge  (ADB)

 

Once Android is booted (first time), run terminal (on Android) and issue commands below

o setprop service.adb.tcp.port 5555

o stop adbd

o start adbd

o or adb tcpip 5555 

 

From the development PC (issue commands via CMD – adb can be found in platform-tools folder in you Android SDK folder):

o adb connect [Android emulator ip address]

 

If the ip not known from Android terminal command: (busybox ifconfig)  Connect as normal from Visual Studio.   Should appear as Hyper Visor name, ie VMWare etc

 

 

Creating an OSX Virtual Machine

For creating a test OSX environment, it is possible to run it within a virtual machine.

 

On physical mac
 Download OS Mavericks from the App Store
 Insert a USB Drive of atleast 8GB

Use Disk Utility
 Choose USB Drive
 Choose Partition. (Partition Layout: 1 partition)
 Under options choose master Boot Record
 Choose Format (Mac OS Extended (Journaled)
 Click Apply
Use UniBeast
 Download UniBeast: http://www.tonymacx86.com/downloads.php?do=file&id=202
 Run Unibeast
 Choose USB Drive
 Select Mavericks 10.9
 Continue
 This takes a while (Not less than a minute :))
On Windows Host:
To Temporarily disable HyperV as your primary Hyper Visor:
Open Command Prompt:
 bcdedit /copy {current} /d “Disable Hyper-V”
 bcdedit /set {GUID Provided from previous command} hypervisorlaunchtype off
For Windows 8
 Win Key – C
 Settings
 Power
 Hold Shift and Restart
 Wait for Boot Screen
 Choose Other Operating System
 Disable Hyper-V (Remember to do this every time you want to use Virtual Box or
VMWare instead of HyperV)
Install Virtual Box or VM Ware
For VMWare:
 Install VMWare Workstation 10 (the free VMWare Player will work aswell to
playback VMs)
 Install Hackintosh Template for
OSX: http://www.insanelymac.com/forum/files/file/20-vmware-unlocker-for-os-x/
 Create a Virtual Machine with Workstation 10 Compatibility hardware
 Install Operation System Later
 Choose OSX 10.9
 Add desired Hardware with at least 40 gig disk space allocated to the Virtual Hard
Disk.
 Run NAT preferably
 Insert USB Boot Drive Created on Mac into PC
 Boot Virtual Machine
 Under VM\Removable Disks Connect the USB Drive (this will remove it from
visibility to Windows Host)
 Reset the VM
 OSX should install
On New OSX VM:
 Install Xcode from App Store
 Install Xamarin Business Edition (iOS)
 Follow Xamarin iOS instructions for Build Agent
Setup: http://docs.xamarin.com/guides/ios/getting_started/introduction_to_xama
rin_ios_for_visual_studio/

 

Content from the CTXUG Talk: The Second Screen

It was a good evening as always at CTXUG.    I hope everybody will be inspired to create a ChromeCast, Android TV or SmartTV app.  🙂

 

 

I’ve shared the presentation:

https://github.com/apead/CTXUG/tree/2faa7c3b62e61da1552c8993c1f53cdfe36247c9/21082014/presentation

 

The source code for the ChromeCast sample receiver can be found here:

https://github.com/apead/CTXUG/tree/2faa7c3b62e61da1552c8993c1f53cdfe36247c9/21082014/source/receiver

 

The source code for the ChromeCast enabled Xamarin app:

https://github.com/apead/CTXUG/tree/2faa7c3b62e61da1552c8993c1f53cdfe36247c9/21082014/source/xamarin

 

Happy Xamarin Coding!