Scott Hanselman

Exclusive Sneak Peek: The AGENT Smart Watch Emulator and managed .NET code on my wrist!

June 18, '13 Comments [30] Posted in Micro Framework | Tools
Sponsored By

The AGENT Smart Watch

I'm totally geeked out about Smart Watches. I always have been, from the original Microsoft SPOT watch (from 10 years ago!) to the Pebble, and now the AGENT Smart Watch from Secret Labs. Secret Labs are the folks that brought us the Netduino open source electronics platform that uses the .NET Micro Framework. It's pretty awesome that you can write C# and run it in 64k or in 64gigs, from the wrist to the cloud.

Upcoming Conference: If you're in or around Chicago in July 2013, consider joining Chris Walker from SecretLabs and I at the MonkeySpace conference! We'll be speaking about developing for embedded systems and the AGENT Watch with C#. What are the power considerations? How low-level is this kind of coding? Can one kind of app cause battery drain while another keeps the watch going for a week? What about notifications and bluetooth? We'll cover all this and lots more, join us.

The AGENT Smart Watch will talk to your phoneThe AGENT Smart Watch was trying to raise $100k to build a watch and as of the time of this writing they are within spitting distance of a MILLION dollars! There's just hours to go to get in on this cool Kickstarter. (Remember, Kickstarter is an investment, not a store.)

Not only is this a .NET Microframework Device, but we can start writing apps now using the AGENT Watch Emulator. From their Kickstarter site:

Traditional smartwatches run apps in an unrestricted environment.  AGENT's OS includes a managed runtime, optimized for our low-power architecture.  It is called the .NET Micro Framework and it makes watch apps trustable.

This feature-rich managed runtime also offers developers modern features they crave: event-based programming; multi-threading; garbage collection; lambda expressions; exception handling; automatic power management; and much more.

You can install VS2012 and the .NET Micro Framework 4.3 and write an app for your wrist! I alluded to this a little in my Xamarin talk "How C# Saved My Marriage." You can write .NET apps for embedded systems, a watch, tablets, desktops, web sites, large cloud systems and more.

Full disclosure: I have no financial stake or business relationship with SecretLabs, but we are friends and I'm a fan. I helped Chris with some copy writing on the Kickstarter page, its text and reviewing the video as a favor. I have received no money from SecretLabs and I backed the Kickstarter with my own money.

imageI got a preview of the AGENT Smart Watch emulator, and some code from Kickstarter backer Esben Bast who created a binary clock face. I loaded up VS2012 and the binary clock emulator. This initial code is just about 100 lines. You can see the references in Solution Explorer here. SPOT means "Smart Personal Object Technlogy."

The fact that there is an emulator is huge. No worries about breaking a watch or even having a watch! The Agent Watch SDK puts a reference to the AGENT Emulator in my registry, so it shows up directly in Visual Studio:

image

Then I can debug my watch app without a watch, just as if I were writing a Phone App or Web Site. It's a first class experience inside of VS. This makes me feel particularly empowered as a .NET developer because it means I already know how to write apps for this watch and I've never even seen it before..

The code is pretty straightforward, if appropriately low-level. This IS a small device we're talking about!

You've got total control over the screen and what can be displayed. You could create any watch face that you could imagine (that would fit on the screen) because you have a Bitmap to draw to.

The .NET Micro Framework has no fonts loaded by default, but I can include them as resources. There's some "tinyfnt" files in C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.3\Fonts or I could download or make some myself. Even better I can use the TinyFontTool from Miloush.

I can load a font from a resource like this:

font = Resources.GetFont(Resources.FontResources.small);

and then later in my UpdateTime() method, Draw the time on my binary clock screen.

_bitmap.DrawText(DateTime.Now.ToString("HH:mm:ss"), font, Color.White, 45, 15);

Run my emulator again and I have the time printed as well!

Now my AGENT Smart Watch has the time printed above the Binary Clock

The only real "microframework-ism" in the code is that the watch face doesn't want to use a lot of power, so you should "go to sleep." It's the same as if you were writing a console app. If your main() function ends, then your app will end! But, since this is a watch face, we want it to run all the time, so, we start a 1 second timer, then sleep the main() forever. Everything interesting happens as an event on a background thread. (The watch can control the lifetime and tombstone or kill the watch face if you're doing other things.)

public static void Main()
{
_bitmap = new Bitmap(Bitmap.MaxWidth, Bitmap.MaxHeight);
_font = Resources.GetFont(Resources.FontResources.small);

// display the time immediately
UpdateTime(null);

// set up timer to refresh time every minute
DateTime currentTime = DateTime.Now;
TimeSpan dueTime = new TimeSpan(0); // beginning of next minute
TimeSpan period = new TimeSpan(0, 0, 0, 1, 0); // update time every minute
_updateClockTimer = new Timer(UpdateTime, null, dueTime, period); // start our minute timer

_button = new InterruptPort(HardwareProvider.HwProvider.GetButtonPins(Button.VK_SELECT),
false,
Port.ResistorMode.PullDown,
Port.InterruptMode.InterruptEdgeBoth);
_button.OnInterrupt += _button_OnInterrupt;
// go to sleep; time updates will happen automatically every minute
Thread.Sleep(Timeout.Infinite);
}

That last part is interesting. You've got two event handlers here, the one to UpdateTime every second and then one to watch for the Button getting pressed. You want the watch app to be event-driven...it needs to do as little as possible NOTHING until it's time to do something. This InterruptPort is watching for the the middle button (the VK_SELECT button). ResisterMode.PullDown means the button will show "1" or true when it's pressed. InterruptEdgeBoth means I get events when the button is pressed AND when it goes up.

Go make Watch Apps!

Here's another cool watch face from Dylan Mazurek next to the Big Digits example:

PixelFace example Watch for AGENT Smart Watch BigDigits example Watch for AGENT Smart Watch

And finally, here's an animated concept for a World Time face that Steve Bulgin made for Pete Brown as well as another Steve concept below:

The next step will be more than watch faces, it will be watch utilities and apps. Maybe an app for my FitBit, or an app to manage Blood Sugar? Perhaps a Nest app to control my thermostat?

The AGENT Watch Emulator emulator will be available to download this Thursday at www.agentwatches.com. You can get ready by installing the .NET Micro Framework today.

Steve Bulgin watch face for the AGENT smart watchWatch apps can be written in C# using Microsoft Visual Studio 2012 (including the free Express edition). Deploy your apps over Bluetooth and debug them interactively.

Download Visual Studio Express 2012
Download .NET Micro Framework SDK v4.3

Developers can also use AGENT as a secondary display, interacting with it remotely via Bluetooth from their Objective-C, C#, or Java smartphone app.

Even though the watch ships in December, I'm going to start writing apps now so I'm ready for the Watch App Store (coming soon)!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. I am a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by ORCS Web
Tuesday, June 18, 2013 5:59:16 PM UTC
Really excited! Can't wait to see what people do with this!
Richard Simpson
Tuesday, June 18, 2013 6:15:43 PM UTC
I wanted to get the Pebble, but as a WP8 user myself, it was sadly not the watch for me. But this one, running .NET? This is quite honestly the smart watch I've been wanting my entire life.

December can't come soon enough.
Preston Moore
Tuesday, June 18, 2013 6:26:53 PM UTC
Thanks for this wonderful article showing the "hello world" app for this smart watch. You certainly have me intrigued. Does the API provide access to the smart phone too?
Stephen Hardie
Tuesday, June 18, 2013 6:38:22 PM UTC
Was the "Sneak Peak" in the title intentional? :) ... you getting on a smart-watch "high" with "Secret" Labs.
Shankar
Tuesday, June 18, 2013 7:22:44 PM UTC
Awesome!

It triggered the geek bug on me!

I spread it to my friends, although not even a handful will be able to read the binary format (which I loved by the way).

I will do an experience with my kid when she will learn the decimal code: give her a watch like this and see if she gets the binary way smoothly ;)

Jokes a side: those are the kind of things that really teach people how to code or appreciate the others effort on creating tools/frameworks.

Like in the old 70's song: "Oh baby it a lego-world".

Live longer and prosper!
Rogerio Prudente
Tuesday, June 18, 2013 7:26:57 PM UTC
I can't wait for mine and I'm downloading the SDK as we speak.
Tuesday, June 18, 2013 7:37:17 PM UTC
Did the Timex Datalink watch not count?
Phil
Tuesday, June 18, 2013 8:06:45 PM UTC
Scott,

you truly are the king of all .NET geeks :)
Tuesday, June 18, 2013 8:23:49 PM UTC
Hey Scott, how does the emulator work with Bluetooth? Does it just use the PC's Bluetooth? Or is it even possible?

I'm envisioning some cool Windows Phone 8 apps paired with apps for the AGENT.
Cam Soper
Tuesday, June 18, 2013 9:54:06 PM UTC
Been waiting years for a decent smartwatch and now they are finally arriving. Being a more traditional watch wearer though I am waiting for them to get a bit better looking.
Pete
Tuesday, June 18, 2013 10:25:55 PM UTC
Is dueTime being set properly ?
Aaron
Wednesday, June 19, 2013 12:33:50 AM UTC
@Cam Soper -- This was asked in the Kickstarter comments - it seems it'll use Bluetooth SPP (Serial Port Profile) to communicate with the watch wirelessly for programming, step-through debugging, etc. As long as your PC has Bluetooth capable of SPP (either built-in or using a USB dongle) you should be covered.
Wednesday, June 19, 2013 3:32:35 AM UTC
This seems promising. I am giving it a try.
Wednesday, June 19, 2013 3:36:28 AM UTC
@Cam Soper -- as Erik said, yes you can communicate between WP8 apps and AGENT apps, even in the emulator. :)

A quick screenshot:
https://www.facebook.com/photo.php?fbid=277448055733627

I tested that app on both an AGENT prototype watch and the emulator. No code changes required, other than swapping the name of the target Bluetooth device on the phone.

Chris
Wednesday, June 19, 2013 6:05:21 AM UTC
I think I see another BABYSMASH port coming soon!
Bryan
Wednesday, June 19, 2013 9:02:51 AM UTC
The Agent watch has the potential to be brilliant, but blooming heck it's 1980's Casio UGLY. I'll stick with my Pebble until a better-looking model comes along!
Graham Watts
Wednesday, June 19, 2013 9:04:06 AM UTC
Obviously, beauty is in the eye of the beholder and all that :)
Graham Watts
Wednesday, June 19, 2013 10:00:21 AM UTC
Realy amazing!

Very good news. Thanks.
Amir
Wednesday, June 19, 2013 11:28:16 AM UTC
Any information when the AGENT SDK will be able to use? Did you have a download link?
Wednesday, June 19, 2013 1:31:04 PM UTC
I'd sure like to give up my Dexcom receiver and have the mg/dl, trend indicator and alarm here.

Then again, the FDA will probably always stand in the way of that.
Phil
Wednesday, June 19, 2013 2:25:49 PM UTC
Wonderful ! Give it a small microphone, a low bit-rate a-to-d converter, and a stream-by-BlueTooth-to smart-phone record function, and it will be the audio equivalent of Google Glass :)

thanks, Scott
BillWoo
Wednesday, June 19, 2013 3:34:00 PM UTC
I'm curious about your statement that, "Kickstarter is an investment, not a store." This seems inconsistent with the fact that although you've "backed" this product you don't have any financial stake in the company. Isn't it more accurate to describe Kickstarter as a store that resembles an investment in that it may not pay off?
Paul
Wednesday, June 19, 2013 4:15:20 PM UTC
@Paul -- Kickstarter backers rally together to support a project and get it off the ground. They don't receive any financial stake in the company itself in exchange for their pledge. They can however select to receive a reward (such as the production watch itself). This is similar to how PBS telethons work for instance.

@Tom -- an early SDK and emulator will be available for download tomorrow evening. :) We're pretty excited to see what you build!

Chris
Secret Labs
Thursday, June 20, 2013 7:59:30 AM UTC
@Chris - Can't wait for the SDK download link, please let us know soonest :-)
Thursday, June 20, 2013 10:50:23 AM UTC
hmm hmm, so we have a non-realtime watch here.
hypekilla
Friday, June 21, 2013 4:22:24 AM UTC
You know what I like best about this type of programming? Our children will love it! If I say to my son, "let's make a web app," he can get bent around the axle with the ceremony and cruft of HTML, JS, etc. But with this, he can have a physical device that he can remotely push to (via bluetooth) and debug. He will be able to code all weekend and have something to show his friends come Monday morning; no app store process, no executable file and hosting, just write, build, push to phone, and rock on.

This is so accessible!
Friday, June 21, 2013 5:38:52 AM UTC
Our early-access preview SDK and emulator for AGENT are now live :)

http://www.agentwatches.com/#tools

If you're adventurous--you can even create a Windows Phone app and use its Proximity and Networking features to connect to the AGENT Emulator via Bluetooth Serial Port Profile :)

BTW, Rob Chartier posted a blog post about installing the tools here:
http://weblogs.asp.net/rchartier/archive/2013/06/20/getting-started-with-developing-for-the-agent-smartwatch.aspx

We'll be updating the SDK with new features, creating tutorials, etc. over the next few months as we move towards autumn production.

Chris
Secret Labs
Monday, June 24, 2013 10:07:50 AM UTC
I want to see .NET spreading everywhere, so finding about about The Agent really made my day. Only problem is that I can't see how we can earn money making apps for this smartwatch (as we should). Unless maybe we could earn money off of the mobile phone app that uses The Agent.
Elliot
Tuesday, June 25, 2013 12:27:25 PM UTC
Currently downloading the tools :)
Can't wait to get my hands on it and the actual hardware in December.

Awesome that they support Windows Phone. That's what ruled out the Pebble for me.
Wednesday, June 26, 2013 8:39:45 AM UTC
I Love You scott.
Iman (ایمان)
Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.