Unnamed Project – A Programming Library for IoT



Unnamed Project – A Programming Library for IoT

0 0


konscio-presentation


On Github pedalpete / konscio-presentation

Unnamed Project

A Programming Library for IoT

This Guy?

Hi, I'm Pete, I'm a software developer, and recently I've been working on a library or framework for making it easier to code for the internet of things.

This Talk

A little bit technical

A little bit rock & roll

How many programmers do we have here? So, this talk isn't going to be very technical, I won't be going through reams of code, so hopefully you won't have to be a programmer to understand the first half of the talk. I'll be introducing some basic concepts, so hopefully even if you're not a programmer, you may just want to become one after. Then we'll talk about what the library can help devices to do, and hopefully get into a little discussion about practical applications.

In the beginning

So, let's start at the beginning, I'm one of those guys that always has lots of ideas. It's what made me become a developer, so I could actually make some of my ideas come to life. And I asked myself one day, why do I not have a micro-quadcopter that can make my bed? I mean, we're teaching these things to play tennis and all sorts of other crazy tricks, making my bed seems like a rather obvious one.

Weird Ideas

but, one thing at a time...

It's true, I also want shark's with frickin' laser beams attached to their heads, but that will have to wait until after I have a quad-copter making my bed. So years ago I had some idea, and I got an arduino and started learning to program it, and I really didn't like it, so when I got this quad-copter idea, I started looking at RaspberryPi, and other platforms and how to write code for those, and I saw stuff like this.

First Lines of Code

  • gpio mode 0 out
  • gpio write 0 1
  • gpio write 0 0

I threw up in my mouth a little bit when I saw this code.

To me, that is horrible code. Who here knows what this code does? Possible discussion... Right, you can't tell what it does, because you don't know what is on pin '0'. This is like a recipe saying 'move left hand up, then down' when it is trying to get you to slice a tomato.

Programming the Obvious

Code should be...

  • descriptive
  • portable
  • separation of concerns
When we write code, it should be descriptive of what the code is trying to accomplish. That's why we give variables and methods names which describe what they are and what they do. You should be able to read a program and get some idea of what it does. That last bit of code with the GPIO stuff doesn't tell you what it does really, it tells you the actions it should take, not the effect it is going to have. It also isn't portable. We can't take that code and run it on multiple devices because we can't be guaranteed that both devices would have the same thing plugged into port 0, or that anything would be on port 0. Separations of concerns, not sure if I used the right term there, but basically, your software developer shouldn't be so closely tied to a hardware platform that the intricacies of the hard dictates the software, I think their should be a middle layer that abstracts as much of that out as possible.

Let's try this...

  • $$('led').on();
  • $$('led').off();
  • $$('temperature').get();
  • $$('temperature').live(3000);
So, what about programming like this, it's pretty clear what it's doing. For those who don't know how to code, you can just read the words, ignore the symbols, and you could probably guess what each of these lines of code does. This is also shorter than the previous example, but more important, this can run on different devices without having to change the code. The devices can have completely different I/O's and pin numbers, we never define GPIO or I2C 1-Wire, or any other protocols, the developer is developing software to run on a more diverse range of devices.

What makes this possible

{"name":"descriptive_name", "abilities":[ {"type":"led","pin":16, "interface":"gpio","color":"red"}, {"type":"led","pin":15,"interface":"gpio","color":"green"}, {"type":"led","pin":18,"interface":"gpio","color":"blue"}, {"type":"temperature","pin":"28-000004acb882", "interface":"w1"}]}

This is all made possible by a simple configuration file on the hardware which holds the details of the structure of that hardware. Here we have everything we need to know about the device so that the software layer can interface with the devices capabilities. That can be sensors, servos, motors, etc. etc.

Really? Javascript?

There are probably a few people bemoaning the use of javascript, but along with being a very popular language, node is very good a running as a light-weight server. So every device which runs this library is both a server and a client.

Every Device is a server

  • does the 'I' really mean Internet
  • device-to-device communication
  • do me a favour
Now, here is where we get a bit interesting in what this sort of structure does for the internet of things. The way I see it, we talk about devices connecting to the cloud and interacting with servers, but in many ways, I think their is a ton of value in device to device communication, not only internet, but interconnected devices. With this library, a device can ask another local device for their information, and hopefully even take advantage of other local devices abilities. Sure, if they need to get a non-local device, they can pop-up to the cloud and do whatever it is they need to do, but for so many things that we think about around our house, is that really what we need?

Imaginary World Example

I cook alot

Let's talk about a imaginary, we've all seen mock-ups for the future of recipes where they do stuff like weigh our foods, and keep timers and stuff, well, what about a recipe that can set the temperature of our oven? It just says 'hey oven, I need a temperature of 160c', and the oven responds if it's able to accomplish the task. The recipe doesn't need to know what interface the oven uses to control it's heat, if it's gas or electric or something else. It just pops up and says 'any device on my network called oven? Can you turn yourself on to 160 please?' Seems pretty simple, doesn't it?

Wrapping-up

Thank You

pete@kitchon.com

I'm still very early in the development of this framework, and I suspect I'll be open-sourcing it not too far down the road. I'm really keen to hear your feedback and questions, not sure if we have time for questions now, but please seek me out afterward or e-mail me. I've never worked on an open-source framework before, so if anybody has any advice and recommendations on managing an open-source project, I'd be really keen to hear from you. Thanks again for your time.