Connect to a Bluetooth Serial Device with Xamarin.Android

I have been exploring the Xamarin tools recently and decided to try my hand at connecting some Bluetooth hardware to Android for a project that will be released soon. I have learned quite a bit about Bluetooth on Android and decided to write up a short description on how to connect to a Bluetooth serial device via RFCOMM/SPP.

First, grab an instance of the default BluetoothAdapter on the Android device and determine if it is enabled:

BluetoothAdapter adapter = BluetoothAdapter.DefaultAdapter;
if(adapter == null)
    throw new Exception("No Bluetooth adapter found.");

if(!adapter.IsEnabled)
    throw new Exception("Bluetooth adapter is not enabled.");

Next, get an instance of the BluetoothDevice representing the physical device you’re connecting to. You can get a list of currently paired devices using the adapter’s BondedDevices collection. I use some simple LINQ to find the device I’m looking for:

BluetoothDevice device = (from bd in adapter.BondedDevices …
Read More

Visual Studio Live! – Orlando 2013

Update: Make that 3 sessions!

imageI will be presenting 3 sessions at Visual Studio Live! in Orlando this November 18-22.  The conference is a full 5 day event and there’s still time to register and save some cash!  For this event, I’ll be presenting:

VST01 What's New in Windows 8.1 for Developers
Date:
Tuesday, November 19, 2013
Time: 9:30 am – 10:45 am
Level: Introductory

Windows 8.1 contains thousands of new APIs which can make your application even better. In this session, you will get an overview of what’s new to developers in Windows 8.1, and how to use these features to make your apps even better. From new XAML controls to PDF support to text-to-speech, you won’t want to miss this session if you’re a Windows 8 developer!

VST05 Controlling Hardware using Windows 8.1
Date:
Tuesday, November 19, 2013 
Time: 11:00 am – 12:15 pm
Level: Introductory

Windows 8.1 allows developers to communicate with a variety of devices through …

Read More

Pinball 2000 Software Update with Windows 7 x64

pb2k

Warning: This is a pretty off-topic post about pinball, but maybe it’ll help someone searching for the information.

Backstory: My dad was a coin-op operator. I’m the son of a coin-op operator. As you might imagine, I have a just a tiny bit of love for video games and pinballs. When my dad passed away in 2008, I decided to keep my favorite pins from the route: Funhouse, Addams Family, Theatre of Magic, Tales of the Arabian Nights, and Revenge from Mars.

After sitting in storage for a couple of years, the software update sitting on Revenge from Mars would no longer checksum properly. The game was running fine, but obviously something was wrong. After lots of other work on the machine, it was time to update the firmware again to version 1.5.

Finding the software and ROM images was easy. Everything is available at PlanetaryPinball.com. Anyone can just grab the Pinball 2000 Update Manager and the appropriate software update for the machine to be updated. However, …

Read More

HP TouchSmart 420t Recovery Discs + Software

imageMy mom desperately needed a new computer (she's still running XP on a very old Dell), so I decided to pick up one of HP's new TouchSmart 420t machines for her, thinking it'll also be a great machine for Windows 8 when it arrives.

HP, in their infinite wisdom, decided that, among other annoyances, one can only create a single set of recovery media from the included Recovery Media Creation application.  Once you make the set, that's it.  If you lose the media, or if you want to make a second set on USB instead of DVDs, you're out of luck, short of ordering the media from HP for a price.

If you are stuck in this situation, there is an easy fix, assuming you still have the Recovery partition available on the hard drive.

  1. Open up an Administrator command prompt window
  2. Change to the D drive (D:)
  3. Change directories to D:\HP\CDCreatorLog (cd \hp\CDCreatorLog)
  4. Delete the ResumeSnapshot.xml file (del ResumeSnapshot.xml)
  5. Restart the Recovery Media Creation application …
Read More

Kinect for Windows SDK is here!

image

Hooray!  I can finally talk about this!  As I've alluded to previously, I had a hand (one of many) in the managed portion of the SDK and what was originally shown at MIX. Since then the SDK has changed a bit but it's finally ready to go!

The Kinect for Windows SDK is now available for download on the Microsoft Research site.  We have also launched several samples over at Coding4Fun that you can begin using immediately:

Coding4Fun Kinect Toolkit

You definitely want to download this one when you get started.  This toolkit contains a variety of extension methods and controls to make using the Kinect for Windows SDK even easier to use.  Some of my code appears in this one.  Smile

Kinect Mouse Cursor

This sample is entirely mine.  Kinect Mouse Cursor is a demo application that uses the Kinect for Windows SDK and its skeletal tracking features to allow a user to use their hands to control the Windows mouse cursor.  Use your right hand to move the …

Read More

MIX11

imageIt's almost time for another MIX conference! Once again I'll be there with the Coding4Fun crew showing off some spiffy new projects for attendees to play around with, along with a few other surprises. I'll also be taking part in John Papa's Open Source Fest on Monday evening, demonstrating WiimoteLib and my MJPEG Decoder.

Anyone else heading to the conference? If you are, be sure to stop by the Coding4Fun area in the Connect Lounge and say hello, and stop by the Open Source Fest on Monday night to take a look at over 50 great open source projects and vote for your favorites. I'd say I'd trade drinks for votes, but those are free, too.

And finally, if anyone attending is working on a fun or interesting project and would like to do an interview for my Coding4Fun Show on Channel 9, please let me know.  Almost anything goes, so I'd love to see what everyone out there is working on.

Hope to see you there!

Read More

MJPEG Decoder

209653324My latest article and library is now live on the brand new Coding4Fun site, now on Channel 9, and over at CodePlex.  This project allows you to very easily decode a MJPEG (Motion JPEG) stream from a network camera (or any other source) into a consumable type for WinForms, WPF, Silverlight, XNA and Windows Phone 7 (both Silverlight and XNA).

The MJPEG Decoder library started life as a project for the t-shirt cannon built for the MIX10 keynote.  The original plan was to have an IP camera attached to the robot for a real-time video stream from the bot's perspective, but the feature wound up being cut for time, and due to some issues rendering the video on the very early Windows Phone 7 tools.  The library has been sitting around a while, has gone through several rewrites and now supports almost every platform I can think of.  With the new Coding4Fun up and running, it was time to polish it off and get it posted.

Take a look at the article, download the binaries and …

Read More

ThinkGearNET 1.1

imageI released version 1.1 of ThinkGearNET over at CodePlex last week.  ThinkGearNET is a library that allows developers to easily use the Neurosky MindSet device with .NET.  This version now matches Neurosky’s latest SDK and supports eye blink detection.  Nothing else has changed.  If anyone has used a prior version of the library, please give the new version a try and let me know if you have any problems.  Thanks!

Read More

VSLive Devapalooza and Jeopardy on Coding4Fun

imageTonight I hosted the Devapalooza event for Visual Studio Live in Redmond.  For the event, we played a Jeopardy-like game using software and hardware I created.  You can find an article on how the software was created, how to build the hardware, and full source/binary downloads over at Coding4Fun and CodePlex  This can be a fun way to host training at your office, or a way to liven up a user group.

A huge thanks to Dan Waters and Clemens Vasters from Microsoft, VSLive speakers Rocky Lhotka, Deborah Kurata, and David Platt, and our three attendees who played the game.  I think it was a great time.  Hopefully you did too if you were in attendance.

After playing the game tonight for real, I have a few ways to fix up the software and make it a bit easier to use, especially on the scoring side.  Also note that the code isn’t the best example of great coding.  With this being a side project and the deadline looming, I took a few dirty shortcuts.  But, …

Read More

WiimoteLib Future

image I’ve been working on a version 2.0 of WiimoteLib which reorganizes the library quite a bit to clean up the codebase.  It’s not quite ready for release, and I don’t have an ETA currently, but I wanted to note some of the changes and get some feedback as I finish things up.

  • I will be including a VS2010 solution for the project in addition to the original VS2008 solution
  • I’m hoping to have support for both sound and the WiiMotion Plus extension completed
  • Support for the Taiko Drum and DJ Hero turntable (testers welcome for the DJ Hero turntable)
  • Extensions have been broken out into separate classes so their code is self contained:
    • image
    • All extensions inherit from ExtensionController
    • All state objects for extensions implement the IExtensionState interface
    • Here’s an example of the new Nunchuk class.  As you can see, everything related to the Nunchuk is located in this class:
    • using System; …
Read More

ThinkGearNET Library

mindset I have written and posted a new library that allows .NET developers to easily connect to and use the Neurosky MindSet headset from any .NET application.  You can find the source code and a binary of the library at CodePlex.  Usage is very simple and may seem familiar to those that have used my .NET Wiimote LIbrary; set a reference to the library and you can connect to a headset as follows:

private ThinkGearWrapper _thinkGearWrapper = new ThinkGearWrapper();
 
private void Connect()
{
    _thinkGearWrapper = new ThinkGearWrapper();
    
    // setup the event
    _thinkGearWrapper.ThinkGearChanged += _thinkGearWrapper_ThinkGearChanged;
    
    // connect to the device on the specified COM port at 57600 baud
    _thinkGearWrapper.Connect("COM4", 57600, true);
}
 
void _thinkGearWrapper_ThinkGearChanged(object sender, ThinkGearChangedEventArgs e)
{
    // write out one of the many properties
    Debug.WriteLine("Attention: " + e.ThinkGearState.Attention;
}

The …

Read More

MindBlaster Article Posted

mindblaster My latest Coding4Fun article on the creation of my game MindBlaster is now available!  This is a game I wrote using XNA Game Studio 3.1 that combines a Nintendo Wiimote and a Neurosky MindSet headset to create a game you play entirely with your head.  If you were at PDC09 and stopped by the Coding4Fun area you may have seen it, or, if you’ll be at MIX10, please stop by the Coding4Fun area and see this and 3 or 4 more even better projects by Coding4Fun authors.

Links

Read More

PDC09, Coding4Fun, and Mind Blaster

Another PDC is over and I’m happily relaxing before work starts again on Monday.  Lots of announcements, free laptops for attendees (not me, sadly), and plenty of time spent in our Coding4Fun area with my project.  We even had the opportunity to take part in a live broadcast on Channel 9!  The recording for that show should be available shortly.

We had 5 fantastic projects in the Coding4Fun area this year:

image
Drinktendr by Clint Rutkas
image
Laser Graffiti by Jeremiah Morrill
image
Goblin XNA by Ohan Oda
image
Wi-Fi Warthogs by Tim Higgins

And what was my big project this year?  A fun little game titled Mind Blaster, a space shoot ‘em up game played entirely with your head!

Mind Blaster

How does one do that? Well…

This past July I found a brain-wave sensing headset from Neurosky called the MindSet.  They are now shipping headsets at $200 each and provide a free …

Read More

PDC 2009

Before and AfterPDC 2009, starting November 17th, is almost upon us and I’ll be heading out to the conference once again with my Coding4Fun/Channel 9 playmates.  Anyone else heading out to the big show?

We won’t be doing a Coding4Fun session like we did last year, but I will have another fun project for people to check out in the Coding4Fun area.  I can’t give out details until after the show begins, but you can probably guess there is a Wiimote in the mix somewhere.  And some spiffy new hardware.  And maybe some XNA.  Look for the details here after the show, and an article with full source code shortly thereafter.

We also have 4 or 5 other developers with their latest and greatest projects, all of which are nothing short of incredible and put mine to shame.  I will likely be doing a compendium Coding4Fun Show with all of this year’s project authors so those not in attendance can see their incredible work.

I will also be hosting a table during lunch on Monday, …

Read More

WiimoteLib 1.8 Beta 1 Posted

image I have posted a new version of WiimoteLib as a beta for people to play around with the Wii MotionPlus accessory.  Please note that this is not a stable release and should only be used if you wish to mess around with the MotionPlus.  Also note that only C# source code is included in this release as it is not a final build.  Here’s the change log:

v1.8.0.0

  • Taiko Drum Master's TaTaCon drum controller supported (Dean Herbert)
  • Bare-bones Wii MotionPlus support (wiibrew.org, testing by Tyler Tolley)
  • WiimoteTest UI changed to add MotionPlus data
    • Please note that the current version is VERY flakey and may not work at all for you.
    • Pair your Wiimote, plug in your MotionPlus, call InitializeMotionPlus()
    • Extensions plugged into the MotionPlus will give wacky results...not supported...yet!
    • Internal changes to perhaps fix some threading issues

So remember, it’s a beta, it may not work for you, and the data you’ll get back from the accessory is …

Read More

Status of Wii MotionPlus Support for WiimoteLib

Update: See this post for a beta release

wii-motionplus Ok, I get about 10 emails a day on this, so I figure a status update is in order.

The Wii MotionPlus extension for the Wiimote was released last week.  Since then, I and others have been working to figure out how the device works.  Unfortunately, it does NOT work as every other extension controller has worked up until this point, mostly due to the fact that the Wii MotionPlus accessory has an expansion port of its own so all of the other extension controllers can plug into it.

In the past few days, some progress has been made thanks to the folks over at wiibrew.org, although functionality is nowhere near complete.  For example, it’s currently impossible to have the Wiimote notify you when the Wii MotionPlus is inserted into the bottom of the Wiimote, like all of the other extension controllers do.

I have been working with the information at wiibrew.org and am trying to get things working reliably with my library so that …

Read More

WiimoteLib v1.7 Released

image I have just put up the latest version of WiimoteLib at CodePlex.  The changes for this release are:

v1.7.0.0

  • Writing registers is now properly waiting for the Wiimote to reply before continuing...this removes all of the Thread.Sleep() calls and should *greatly* improve performance when setting LEDs and rumble (Serial Nightmare & wwibrew.org)
  • Guitar Hero: World Tour Guitar and Drums now properly recognized and used (wiibrew.org, tested by Tyler Tolley and Mauro Milazzo)
  • Guitar whammy bar is now a 5-bit value instead of 4 (wiibrew.org)
  • Position of 4 IRs now properly reported in Basic reporting mode (Dan Carter)
  • Found1/2 now properly reported in MSRS (reported by akka243)
  • MSRS project updated to Microsoft Robotics Developer Studio 2008

Please give this new version a try and let me know how it works for you, especially if you have one of the newly supported controllers.  And, as always, what features/bugs would you like to see added/fixed?  Please …

Read More

Animated Musical Holiday Lights at TVUG

image I’ll be presenting a session on building your own holiday musical light show using Phidget boards and .NET at this month’s Tech Valley User Group.  I’ve previously written an article about this topic on the Coding4Fun site, and there will be a full chapter on this in our upcoming “Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More” book.  Here are the session details…

Abstract: This month, learn how to build an animated light show set to music, much like the famous holiday light show videos you may have seen on YouTube.  This session will cover how to build the hardware, how to build the software, and how to combine them to create a synchronized musical show for your home.
When: Tuesday November 18th, 2008 - 6:30-9PM
Where: VersaTrans Solutions, Latham, NY

Hope to see you at the session!

Read More

WiiEarthVR Article and Source Code Posted

I previously talked about my WiiEarthVR project shown at PDC project, and now I have posted the article for the application up at the Coding4Fun site.  Full source code is available.  You’ll need some hardware to make this go, namely a Wiimote, Nunchuk, Wii Fit Balance Board and a pair of Vuzix VR920 glasses, but the hardware can be toggled on or off depending on your own setup.  The VR920 glasses are pretty cool in that they also work with a variety of FPS games on your PC with a custom driver they include.

The article will, among other things, teach you how to use Virtual Earth 3D from a managed host (i.e. a WinForms app, not a web page), how to talk to the Wiimote, Nunchuk and Wii Fit Balance Board, how to retrieve the head tracking data from the VR920 glasses from .NET, and how to draw stereoscopic 3D images to the VR920 glasses from .NET.  Quite a bit packed in there…

Anyway, have a read and, as always, questions and comments are welcome.

Read More

WiimoteLib v1.6 Released

image A new version of my managed Wiimote library for .NET has been released.  You can find version 1.6 up at CodePlex now.  The changes are as follows:

v1.6.0.0

  • Added "center of gravity" calculation to the Wii Fit Balance Board (thanks to Steven Battersby)
  • Structs are now marked [Serializable] (suggested by Caio)
  • Battery property is now a float containing the calculated percentage of battery remaining
  • BatteryRaw is the byte value that used to be stored in the Battery property
  • WiimoteTest app now reads extensions properly when inserted at startup
  • Exposed HID device path in new HIDDevicePath property on Wiimote object
  • Changed the time delay on writes to 50ms from 100ms...this should improve responsiveness of setting LEDs and rumble

I feel like I’m running out of things to implement and bugs to fix.  I know that’s not true.  So, I want to hear from the people using my library…

What features/bugs do you want to see …

Read More

WiiEarthVR at PDC

Update 1/20/09: Here’s a vid from Channel9 showing the WiiEarthVR project:

 

Time to talk a little bit about my PDC demo…

About a year ago, I wrote an application to control Virtual Earth 3D with the Wiimote named WiiEarth and a corresponding Coding4Fun articleon how it was done.  Since that time VE3D has been updated several times and code changes have broken my application.  Since their API is undocumented and unsupported, it was bound to happen.

For PDC this year, I decided to write a new version of WiiEarth, now named WiiEarthVR, using the Wiimote and some additional hardware, namely the Wii Fit Balance Board and a pair of Vuzix VR920 glasses.  Using the Balance Board, the user can shift their center of gravity (i.e. lean) and control the VE3D environment as if they were on a hovering glider.

Wii Fit Balance Board VR920

The VR920 glasses contain sensors to allow head tracking in 3 degrees of freedom.  A very simple API provides a way to determine the yaw, pitch and …

Read More

PDC2008

pdc Anyone heading out to PDC2008 this year?  I will be in attendance with (hopefully!) a new Wiimote project and perhaps a few old ones as well.  More details on that when the project is a tiny bit further.  We will also be giving away a free chapter of our new book “Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More” to lucky PDC attendees at the O'Reilly booth.

I will also be co-presenting a lunch session at PDC:

Title: Coding4Fun: Windows Presentation Foundation Animation, YouTube, iTunes, Twitter, and Nintendo's Wiimote
Date/Time: Tuesday, October 28th, 12:45pm-1:30pm
Speakers: Dan Fernandez, Scott Hanselman, Brian Peek, Clint Rutkas
Room: 403AB
Abstract: Spend time with Coding4Fun authors as they walk through some DIY Development projects: TwitterVote, Wiimote, InnerTube, and BabySmash.

You can add this session to your agenda by visiting the PDC site and searching for “Coding4Fun”.

If anyone will be …

Read More

VSLive NY Sessions Posted

Thanks to everyone that attended my VSLive NY session.  I hope it was informative.  I have posted the slide-decks and source code for both of my sessions so you can tinker with the projects on your own.

Questions and comments welcome, as always.  Thanks!

Read More

Coding4Fun Book News

Now that we have finished writing the book, we finally have an official title and chapter listing.  Someday we may even have a cover.

The title has morphed into Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More and the final chapter listing (not necessarily in this order) is:

  • Alien Attack: Create a 2D clone of Space Invaders with XNA for the PC, Xbox 360, and Zune
  • LEGO Soldier: Create an action game using Popfly with a custom-built virtual LEGO character
  • World of Warcraft RSS Feed Reader: Use WoW's customizable interface to have feeds pop up while you're gaming
  • InnerTube: Download YouTube videos automatically and convert them to a file format for off-line viewing
  • PeerCast: Stream video files from any PC
  • TwitterVote: Create custom online polls on Twitter
  • WHSMail: Build a website with ASP.NET for Windows Home Server that lets you view the messages stored on a computer with Outlook
  • "Wiimote" …
Read More

Wiimote Smoothboard

I was contacted by Boon Jin Goh recently about his super awesome Wiimote Smoothboard application.  Boon Jin took Johnny Lee’s original Wiimote Whiteboard app and added a ton of functionality.  What was a proof of concept or tech demo is now a fully functional electronic whiteboard capable of being used in a real environment.  Here’s a video showing functionality from the 0.1 version of his app, which has had several updates since.  Definitely give it a try if you’re looking for a very capable electronic whiteboard.  Great job!

Also note that both Johnny Lee and Boon Jin have contributed to our upcoming “Coding4Fun: 10 .NET Programming Projects for Wiimote, YouTube, World of Warcraft, and More” book (yes, the name changed again) with a chapter dedicated to the Wiimote Whiteboard.  This chapter will teach you how to build Johnny’s original whiteboard with the Smoothboard’s spiffy smoothing algorithm added in.

Read More

Windows Mobile Devices and Power States

I’ve been doing some Windows Mobile development with the .NET Compact Framework recently and ran into a scenario where I needed the device to be in “full power” mode at all times with the back-light on.  The device is constantly powered, so battery life is not a concern.

The obvious choice is to go into the Brightness and Power control panels and turn off the appropriate settings, but I learned that there is a way to handle this at an application level so the behavior only occurs while the application is running.

Power State

An application can force a specific power state using the SetPowerRequirement method, and release that state using the ReleasePowerRequirement method.  Using P/Invoke, these methods look like the following:

   1: public enum CEDevicePowerState
<pre style="padding-right: 0px; padding-left: 0px; font-size: 8pt; padding-bottom: 0px; margin: 0em; overflow: visible; width: 100%; color: black; border-top-style: none; line-height: 12pt; …
Read More

VSLive! New York

I have been selected to present two sessions at VSLive! New York this September.  Here are the abstracts:

Title: Creating a Simple 2D Game Using XNA Game Studio to Run on a PC, Xbox 360 or Microsoft Zune

Date/Time: Wednesday, September 10th at 3:15pm

Description: This session will demonstrate how to build a very simple 2D game engine and game using the latest version of XNA Game Studio. Attendees will learn how to effectively use the content pipeline, import 2D sprites into XNA, manage input from the keyboard, mouse, Xbox 360 controller and Zune, manage game state, and debug the resulting game. The sample code will be built on a PC and run on the PC, Xbox 360, and Zune platforms when complete.

Title: Interfacing External Hardware Using Managed Code

Date/Time: Wednesday, September 10th at 4:45pm

Description: While developers write code to build software every day, not often are they exposed to code that drives and interfaces hardware. This session will attempt to …

Read More