IoT For Humans (and Developers) - Getting Started with my Microsoft Band

Making the “Internet of Things” make sense to observers outside the industry is going to take a lot of work. While we might grow frustrated with the overuse and below-required understanding of the term, I would argue that in the industry we have a long way to go to fully understand the implications of security, health, privacy, etiquette, social dynamics, productivity and individualism.

But while the term may seem obscure, especially hiding being other abstractions like “connected devices” and mixed in with other buzzwords like “big data”, the reality is that…it’s here.

The auto industry embraced the “of Things” part really well quite some time ago, well before mainstream internet in fact, and has been increasingly good and getting the “Internet” part as well.

As a consumer, it would appear that my van sends me an email when it needs an oil change; in reality there is a query or a push occurring at some set interval or cued off of some trigger when I’ve reached a certain amount of mileage. That push or pull stores a flag in a database, which is later picked up by some service, likely processed through some kind of templating engine and mixed with my past service records and ultimately delivered to my inbox. But, dang, my van sends me emails, Mom!

Bringing IoT Home For .NET Developers

Even to me as a developer, while I’ve sensed these “Things” emerging around me it’s still been hard to find a way to explore them. You can’t get application development guidance or a NuGet package for your Chevy Uplander.

In many ways our phones have really become these interconnected devices as well, becoming more and more sensor-laden in a world where LTE and Wi-Fi signals have broader reach. Android watches and even the Pebble watch spaces have SDKs if you’re familiar with those development ecosystems or cross-plat tools to target specific devices.

But last week, my Microsoft Band showed up. And there is both an SDK and guidance freely available. As a developer on the .NET stack and solid knowledge of Azure, I can’t help but feel that my playground just got a lot bigger.

What I Get as a Tinkerer

So, for about $200, and leveraging my Azure benefits, I am like a kid in a candy shop. Here’s what I have:

  • A crazy amount of sensors (GPS, UV, heartrate, accelerometer, gyrometer, ambient light, microphone)
  • “Free” pairing with any major phone platform via the SDK
  • More sensors available via the phone
  • A myriad of connectivity options (Wi-Fi, Bluetooth, NFC)
  • Local and cloud-based storage
  • User accounts, identity services
  • Haptic and audio feedback mechanisms
  • Multiple interaction surfaces
  • Other cloud services (SMS, email, batch processing)
  • A human attached to all of the above
  • The ability to create applications on my laptop/PC/tablet that ties these things together

You can sign up for Azure for a free trial here, or look into your benefits through the MSDN program, as you may already have monthly credits to burn up.

I haven’t quite figured out what I want to build yet, but there seems to be a lot of interesting paths.:

  • A “Safe and Alive” monitoring application for high-risk occupations (I’m already exploring this)
  • A immersive game with haptic, visual, audio, SMS and touch interactions
  • A reminder app to keep active, with an accountability partner using similar kit
  • An application that leverages the Band for build server (or other service) failures
    Remember that some of these become quite interesting when you consider the fact that you don’t have to have your phone out or even in your pocket for these to work, just as long as the Band can maintain it’s Bluetooth connection. You can leave your phone when it gets the best signal (in the vehicle, at the entrance to a storage facility) and still have your app running, collecting, pushing, pulling and processing data.

So What Now?

These are exciting times, and I’m having fun exploring practical and completely impractical uses and applications. My kids, 13, 11 and 5, are infinite sources of hilarity in discussing what we can do with it. My wife, too, and I’ve found all of a sudden that without talking about “consumer applications”, “big data” and “interconnected devices” I have completely engaged the entire family in the “Internet of Things”. Oh, and I had to order my wife a Band as well. Smile

I’m going to start sharing my experiences while developing an application in the weeks ahead, delving into the use of the sensors on the Band, exploring interactions and trying to test it in real-world scenarios. Stay tuned to follow my path. My next post will be a “Hello World” app that introduces you to the tooling and SDK.

Have you got a Band? What applications are you thinking about developing? Do you have any successes or failures to share in regards to the “Internet of Things”?

Working from Home and Walking to Work: Surviving Remote Work

There’s a commercial that I’ve seen in the last few months on TV where the announcer is singing the praises of a lady who rides her bike to work, “…which is impressive, because she works from home.” While it’s true that it seems a little nuts to leave your house to go to your house, there’s actually some incredible wisdom in this simple practice. Working from home is a privilege and an expression of trust from our employers, even if we’re self-employed, and you need to be equipped to find a good cadence to your day.

Awake, Alert and Ready to Go

The first month that I started working from home I thought I had it made. I was sliding out of bed pretty much straight into my chair and starting my work day with the sludge still on my teeth, sipping on coffee and trying to make sense of the emails I was catching up on through my half-closed eyes. I’d usually wait until lunch to shower and I rarely did my hair.

Now, this was all kinds of bad for many reasons, especially because I wasn’t able to get any of my schtuff done, but it also meant that days were always a real slow build up. Rather than hitting the keyboard running with trumpets and sirens and “Hells, ya!”, it was more like a pitiful crawl being cheered on by a fourth-grader playing a sad kazoo.

So, I started walking to work. And I love it. I say goodbye to my kids and give my wife a smootch. I leave via the front or side door, head North and do a loop through my neighbourhood. I will usually read a few emails, catch up some news and listen to music as I walk, but often I stop to talk to folks who live in my community too. As I finish my walk, I enter the house through the back door, and I’m officially at work.

I am engaged, trumpets blaring, as I start hacking.

When I finish my work day, I leave through the back door, and head South, doing another loop, but usually on a different route. If it’s a busy evening, it can be as short as a block or two. I come in through the front or side door that I exited through in the AM and I’m back home.

Separation of Work Space and Home Space

This practice really helps me to keep the work stuff at work and the home stuff at home. There are a few other physical boundaries that I keep in place, but really, the walk at the start of the day and the end of the day are just a great way to get energized, tune in my focus on the way to my office and leave work behind when I’ve signed out for the evening.

Those other physical boundaries? I work in my office, I have a space set aside in my home where work stays. It is a very rare occasion when I bring my laptop out of my office to work elsewhere in my home.  I don’t keep a house phone in my office, and I don’t take my VOIP gear out into my home.  My wife and I don’t talk much through the day, if at all, except occasionally via Skype chat. In my new office (we’re in the process of renovating right now) I’m installing extra sound-proofing so that the noises of the home enter my work space even less than they do today.

Of course, there are some exceptions. At lunchtime, I just walk upstairs to have lunch with my bride, I don’t do the walk from-and-to work again. And if she is otherwise predisposed throughout the day, I’ll take the home phone with me as I head down to the office (our son has Type 1 Diabetes, and our house phone is the emergency contact number). And with kids missing school busses and meetings starting promptly in the AM or running late at the end of the day, I don’t always get my walk in. But I covet the days I do.

Find Your Own Survival Technique

The walking works for me, but it may not for you and I understand it’s not for everybody.  It really doesn’t have to be a walk, but as a remote worker I have found success in having a way to start my work cleanly and to be able to literally walk away from my job at the end of the day.

This is really a matter of figuring out how to not only survive the opportunity you have to work from home, but to find success in it. So figure it out! What is it for you that helps you train in on your work day? What is it that helps you disconnect as the evening begins?

Wake Up and Get S#!t Done – A Practice of Awesome

People, we need to get more stuff done. Insert whatever word is appropriate for you. We’re a culture consumed by consumption and I think it’s going to suck a lot of life out of our kids. Seriously, it’s going to suck.

As we seek to fill our time with things that are pre-fabricated, manufactured and less original, we lose out on the participation in creation, which is how we got to be awesome as a species in the first place. So, let’s be all commit to being more awesome.

  • Learn every day; just…be more learned.
  • Wake up early and give yourself an hour for your future self.
  • Teach someone, especially kids.

Sleep is awesome. I’m speaking from personal experience as I’ve done it a few times, in fact I’m quickly approaching 13,800 attempts at a night’s rest, many of them successful. I even take a nap most days. But we’re suckers for using sleep on the wrong end of our night. Staying up late is just way more appealing.

Bust Out of Your Funk

But what do we do in those last hours, when we’re the least rested and least focused? We watch House of Cards. Play games. Do the Facebook. Drown in Twitter or Instagram. Lame.

As far as New Years resolutions go, I’m not much of a fan. And since I try to do this every day already, it’s not really much of a commitment for me to make, but I think it’s a great life hack. So, here’s one thing that you can do to make your life better:

Wake up early.

That’s it. No secret sauce, no programs or diets or fads. Just get your arse out of bed.

I’ve been doing this, fairly faithfully for the last couple of years, and it’s something that I’ve started sharing with folks because it works. I can’t possibly make money off of you getting up earlier, so there’s nothing but a good honest recommendation in this.

Why do it? Because you can start to take control of your life, that’s why. You get up early, and things happen. There’s likely less distraction in your house and you’re going to be able to tune in to the task at hand. There are a ton of things you can do in just 45min-1hr:

  • Read something you’re interested in
  • Gain at least some awareness of world events
  • Learn, learn, learn
  • Go for a run/walk/bike, take out the trash, do some Yoga, shovel some snow (I do advise against snow blowers and lawn mowers in the wee hours, for the sake of the neighbours. Especially if I’m your neighbour)
  • Write, even if you aren’t sharing it
  • Solve a problem outside of your normal domain

I’m a software developer (in case you couldn’t tell from my blog) so for me, my goal is to stay caught up on the changes in the industry (cloud, patterns, vNext type stuff), things that influence my industry (electronics, politics, economic trends, job markets) and things that are disruptive to my career (wearables, IoT, startup culture, young kids with big ideas). I write code almost every morning. I try to work out 4 times a week.

If you don’t think that an hour of effort can make a difference, here’s what I did yesterday AM in 64 minutes:

  • Created a new Azure Web Site
  • Setup DNS for the site
  • Created a certificate request for the site
  • Applied for SSL with GoDaddy
  • Completed the certificate request
  • Exported the cert (with cert chain) and uploaded to azure
  • Added the site to a GitHub private repo
  • Published the site to Azure
  • Added two settings to turn “test” and “paypal sandbox” mode to my web.config
  • Added those app settings to the Azure website
  • Enabled SSL bindings and redirects

TL;DR: I got schtuff done. And yes, I track my time and keep a log. When I look back on my week, I can honestly reflect and say, “Good week, Chambers” or “Pick up the slack, home slice”. It’s not a tool to condemn myself, it’s a way to score wins and keep motivated. Last year I put over 150 hours into “my career” and this year my career is better than last year.

Ch-Ch-Ch-Ch-Ch-Changes

If you’re not a morning person, so what? All you’re saying is that you’re not great at waking up. So wake up earlier, and get over your “not a morning person” time, then get to work.

If you get up early and start doing something meaningful, there’s going to be a few things that happen:

  • You’ll start slipping away to bed earlier, because you’ll be tired earlier in the evening. Embrace it.
  • You’ll start to lose interest in gossippy, trendy fads.
  • Things you have wanted to learn will start to get learned.
  • Projects you have wanted to work on will get some attention.
  • It will be easier to walk away from your work during the day/evening and spend time with your family because you’re constantly achieving.
  • You will see less value in lower forms of entertainment (reality shows) and greater value in the investment in yourself and time with your loved ones.
  • You will be happier because you will feel like you’re accomplishing something nearly every single day.
  • You will appreciate your rest much more

Oh, yes, rest is important. And I don’t just mean sleep. No athlete worth her salt trains every day of the week, nor should you. Take a day off every week (I try to practice a digital Sabbath) and let yourself recharge. And balance your efforts (I take a walk before and after work). I will write on this soon, as it’s especially important for me as I am a remote worker.

“Can’t I just do this before I go to bed?” Sure, if that’s what you prefer. But why wait until your last hours of the day – as your concentration and willpower fade – to invest in yourself?

My morning ritual is easy: I get up, put the coffee on, do a quick workout (sometimes as short as 10 minutes), shower, grab my cup of joe and get to work. This takes less than 20 minutes, so I get up about an hour before the rest of the household. Want to know something crazy? I don’t even set an alarm. But, more on that in a future post.

legocreative

My 11 year old son loves Lego and Dr. Who. He wakes up a couple of times a week and spends 10-15 minutes or so looking at online projects that other Lego-Whovians have built, and then tries to re-create them, or just builds his own, even recently getting into painting his own characters. He gets it: if he wants to learn how to do something, he’s got to put some time into it. He’s got school during the day, homework and music lessons during the evenings, and his parents make him get a reasonable sleep in each night. When else can he do this?

So, wake up early, close down your unnecessary browser tabs (Twitter, Facebook, email) and get some real s#@t done. Spend your early mornings on yourself, your daytime on your job, your evenings with the people you care about most and get a good night’s sleep. It will change your life for the better, guaranteed, or I’ll double your money back.

And happy coding. Smile

Fatal: unable to access 'Repository': Failed connect to bitbucket.org:443; No error

I was getting this error when trying to push a new branch up to bitbucket today:

fatal: unable to access ‘https://{account}@bitbucket.org/{project}/{repo-name}.git/‘: Failed connect to bitbucket.org:443; No error

I was able to get the correct IP for bitbucket.org via nslookup, and I was able to access both HTTP and HTTPS in a browser. Going verbose didn’t reveal much new information either:

$ GIT_CURL_VERBOSE=1 git push –set-upstream origin feature/select-account-dialog:feature/select-account-dialog

  • Couldn’t find host bitbucket.org in the _netrc file; using defaults
  • Adding handle: conn: 0x36b570
  • Adding handle: send: 0
  • Adding handle: recv: 0
  • Curl_addHandleToPipeline: length: 1
    • Conn 0 (0x36b570) send_pipe: 1, recv_pipe: 0
  • About to connect() to bitbucket.org port 443 (#0)
  • Trying 131.103.20.168…
  • Timed out
  • Trying 131.103.20.167…
  • Timed out
  • Failed connect to bitbucket.org:443; No error
  • Closing connection 0
    fatal: unable to access ‘https://{account}@bitbucket.org/{project}/{repo-name}.git/‘: Failed connect to bitbucket.org:443; No error

Then I noticed the Cisco VPN client icon in the taskbar…I was connected to a VPN. Disconnected, and the push was successful. Hope this helps someone else out there.

Haping coding. Smile

Team Foundation Error – BasicAuthCredential is not marked as serializable

I was working on a project hosted in a git repo in Team Foundation and wanted to update the build process. Scroll down for two different fixes if you’ve got the error, or read on to see if it’s applicable to your situation.

When I navigated to the step to configure the process template parameters, I ran into the following error:

image

The text was:

Team Foundation Error – Type ‘Microsoft.TeamFoundation.Client.BasicAuthCredential’ in assembly ‘Microsoft.TeamFoundation.Client, Version=12.0.0.0, Culture=neutral, PublicKeyToken=’[token] is not marked as serializable.

I’m not aware of any recent changes or updates to my machine, my dev environment or the TFS server in question. I tried restarting Visual Studio, but the error persisted.

I then remembered that about three months ago I ran into a similar problem (though I can’t quite recall if it was the same error) when I started using a VM that had a co-worker’s credentials pre-baked into VS. To fix this problem I removed the credentials in Windows, and it resolved the issue, prompting me to sign in as myself when I next launched VS.

Solution 1 – Reset Your Credentials

Rather than removing the account, I wanted to first try to just poke it by re-entering my password or  To reset your credentials, try this:

  1. Close all instances of Visual Studio.
  2. Tap your Windows key, then type “Credentials”. The Credential Manager app link should show up in your list.
  3. Check out your “Windows Credentials”. Under Generic Credentials, you should see your TFS account.
  4. Click on the twirldown next to the entry and select “Edit”.5. Retype your password.

Solution 2 – Delete the Credentials from Windows

imageIf the reset doesn’t work, you can try this instead.

  1. Close all instances of Visual Studio.
  2. Tap your Windows key, then type “Credentials”. The Credential Manager app link should show up in your list.
  3. Check out your “Windows Credentials”. Under Generic Credentials, you should see your TFS account.
  4. Click on the twirldown next to the entry and select “Delete”.5. You may need to do this for more than one account, especially if you have a git:http:// account saved as well.
  5. Confirm the delete operation.

Whichever solution you have to go with, this should fix things up. Note that in solution 2, you’ll be prompted for your credentials when you open up Visual Studio and try to navigate to a team project.

Cheers, and happy coding! Smile

Day 2 – Adding Entities to a Storage Account Table

In this series we are looking at the basic mechanics of interacting with cloud-based Table Storage from an MVC 5 Application, using the Visual Studio 2013 IDE and Microsoft Azure infrastructure.

We’ve got some basics in place, namely loading up all resources from a table, but it turns out that users want to be able to add records, too. Who knew?  To allow this to happen, we’re going to need to update our view a little and add an appropriate method on our controller.  Let’s make that happen, then we’re going to take a look at why our approach is breaking down.  Don’t worry, we’ll start fixing things up in Day 3!

If you want to follow along, please pop into Azure and make sure you’ve got an account ready to go. The trial is free, so get at it!

Updating Our View

We’re going to keep working off of the view we created in Day 1, just simply by adding a form below the existing UI. 

<h2>Like Kittehs? Add a Kitteh!</h2>
@using (Html.BeginForm(“Index”, “Home”, FormMethod.Post))
{
<div class=“form-group”>
<label for=“ImageUrl”>What kind of Kitteh is it?</label>
<select class=“form-control” name=“PartitionKey”>
<option value=“FunnyKittehs”>Funny Kitteh</option>
<option value=“CuteKittehs”>Cute Kitteh</option>
</select>
</div>
<div class=“form-group”>
<label for=“RowKey”>Kitteh Name</label>
<input type=“text” class=“form-control” id=“RowKey” name=“RowKey” placeholder=“SeriousKitteh”>
</div>
<div class=“form-group”>
<label for=“ImageUrl”>Image URL</label>
<input type=“url” class=“form-control” id=“ImageUrl” name=“ImageUrl” placeholder=http://awesomekittehs.org/pic1.jpg">
</div>
<button type=“submit” class=“btn btn-default”>Submit</button>
}

If you’re new to Bootstrap, it may seem like there’s a lot going on there, but you get used to it pretty quickly. Our form has three “groups” in it.  This is a construct in Bootstrap that allows us to associate controls and labels and get the CSS styling we expect.   Each form group has a label and a control, in our case, and we’re simply putting in the properties we need in order to create a new row in our Azure Table.

The form is configured to POST to the Index action on the Home controller, so let’s set up someone to answer when the calls start coming.

Updating Our Controller

The next piece is just as easy. We want to accept the form information (our controller will leverage MVC’s model binding) and then create a new entity in the Table.

[HttpPost]
public ActionResult Index(KittehEntity entity)
{
var storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting(“StorageConnectionString”));

var client = storageAccount.CreateCloudTableClient();
var kittehTable = client.GetTableReference(<span class="str">"PicturesOfKittehs"</span>);

var insert = TableOperation.Insert(entity);
kittehTable.Execute(insert);

var kittehQuery = <span class="kwrd">new</span> TableQuery&lt;KittehEntity&gt;()
    .Where(TableQuery.GenerateFilterCondition(<span class="str">"PartitionKey"</span>, QueryComparisons.Equal, <span class="str">"FunnyKittehs"</span>));

var kittehs = kittehTable.ExecuteQuery(kittehQuery).ToList();

<span class="kwrd">return</span> View(kittehs);

}

The insert is a type of TableOperation that we get by calling the static method aptly named “Insert” and passing in our entity. Our kittehTable object here is created in the context of a table reference that we load from our storage account by name.

At the tail end of the insert operation, we reload the list of kittehs (everyone is here to see the kittehs, after all) and return the view to render the list.

It’s Falling Apart!

Good grief, Charlie Brown, you’ve repeated all your code!  Our controllers should handle the mapping of requests and related payload to service endpoints, and direct users to the correct views.

Putting application logic into our methods is a dangerous slope, and anytime our actions start doing more than one thing we start making it hard to test and maintain our software.  This is ungood.

Next Steps

A lot of times tutorials and blog posts fall short in the area of best practices, and I don’t want to go there for this one. In tomorrow’s exercise we’re going to break our problem down into better pieces that more accurately represent what you’d be doing in a real-world application.