The goal of project 0 is to introduce you to some of the tools you might find useful for projects in home network and give you the flavor of the kinds of things you might want to do. You can think of this as a hello world program for the home.
The goal is to write a HomeOS program that finds a camera and periodically displays an image from it on the screen. Once you get HomeOS up and working this will consist of the following tasks:
- Displaying a window in which to show the image
- Looking for existing cameras (actually their ports) and looking for new cameras as they become available (see the documentation about GetAllPortsFromPlatform and PortRegistered in the programming guide)
- Choosing one camera, likely the first one you find
- Entering a loop to alternate between sleeping for a second and getting an image from the camera by invoking the GetImage operation on its port, then rendering the image in the window (it might be useful to look at the UpdateImage function in CameraWindow.xaml.cs in the AppCamera project)
The best course of action is to start by following the setup instructions below until you have HomeOS and the provided apps and drivers building.
From there it's probably best to pick up from "Running for the first time" in the HomeOS Programming Guide. It should walk you through writing a skeleton of your own HomeOS app. The most relevant parts for this are:
- Page 2 which discusses getting HomeOS to run in Visual Studio 2010 so you can debug it
- The "Creating a new HomeOS Module in Visual Studio 2010" section (pages 9-16) which goes through the nitty, gritty details of making your own app.
- The "Programming Abstractions" section (pages 4-9) and in particular "Example Application Bits" on page 6 which talks about what you'll need to do to query a camera driver for an image.
You may find the that the function UpdateImage in CameraWindow.xaml.cs in the AppCamera project has some useful code for manipulating the image bytes that come back from the camera driver and rendering them in a .NET window.
- .NET Framework 4 on MSDN
- All the documentation about writing code for .NET 4 including C# which is what most of HomeOS is implemented in. Google searches about relevant terms like ".net bitmapimage" also usually produces helpful links.
- What's Included with HomeOS (pdf, docx)
- This describes what is in the HomeOS distribution as well as how to get some of the drivers to work including how to turn a windows 7 PC in to a media server and programmable media player as well as how to set up a Z-wave USB stick and basic webcam.
- Programming in HomeOS (pdf, docx)
- This is a much more detailed primer on how to get started with HomeOS and should walk you through everything in some detail. There's some overlap between this, the "What's Included" guide and the instructions below.
Development Setup Instructions
- Download and install Windows Phone 7 Developer Tools
- Download and install all 3 things in order: Windows Phone Developer Tools, January 2011 Update, and Fix
- Some of the installers seemed finicky when I've installed them in the past and can take a really long time to run and/or just stall in the middle of things. Let things run for 10 minutes or so before freaking out and if things seem to hang up for a really long time, try rebooting.
- Download and install Silverlight 4 Tools for Visual Studio 2010
- The same rules about waiting for things to finish and helpful reboot apply.
- Install Silverlight for Windows Phone Toolkit (Feb 2011)
- Download the HomeOS code
- Just extract the contents of the zip file. This should result in a folder called "homeos". Move that somewhere convenient and then look inside to find homeos.sln.
- Open homeos.sln in Visual Studio 2010
- Ignore the warnings about not being connected to Source Control. If when you go to save a file it asks if you want to overwrite or save as, go ahead and overwrite it. These are both issues resulting from the solution file being attached to a source control system it can't reach and we're working to resolve them.
- If you're running on a 64-bit version of Windows, you may need to fix the Reference to Microsoft.Phone.Controls.Toolkit in the AppCameraWp7 and AppSwitchMultiLevel projects:
- Remove the dangling Reference: expand the References under the project, right-click on the Toolkit reference, and remove.
- Add the reference to the dll C:\Program Files (x86)\Microsoft SDKs\Windows Phone\v7.0\Toolkit\Feb11\Bin\Microsoft.Phone.Controls.Toolkit.dll: right-click on References under the project, Add Reference, Browse, navigate to the dll.
- At this point you should be able to build everything by either pressing F6 or right-clicking on the Solution and going to "Rebuild solution". Make sure that this builds without errors.
- Try running now
- Start a command prompt as an Administrator and go to directory homeos/output in the command prompt.
- Enter command "Platform.exe -c DistConfig"
- You should see a bunch of messages fly by (ignore warnings about no usable adapters found), two windows pop-up, and then messages about echo messages should scrool by periodically