The Object Network

NetObjects for the Internet of Things

Internet of Things and state dependencies

If you imagine a local Internet of Things in your home, say you have lights and switches or buttons, sensors, motors to open and close blinds and doors and locks, and so on. There are many devices, all connected to the network. Each device has a current state (on/off, open/closed, 21 degrees, etc).

You may want to set up dependencies between the states of Things: a light that is on or off depending on the state of a switch, or of a sensor measuring temperature or motion, a lock that is always locked as long as the porch light is off.

Take, for example, the light and the switch: they have a current state - the light has a state of 'on'/'off' (or 0-100% or RGB colour) and the switch can be 'on'/'off' (or 0-100% if it's a dimmer or rotary control). Say we want the light to depend on the switch.

It's possible to let the light itself determine how its state depends on the switch without any central or intermediary controllers (e.g. in a 'hub' or in 'the cloud').

That's how the Object Network works, modelling the world using "NetObjects". NetObjects allow you to write software to model such direct, peer-to-peer interactions very naturally. NetObjects represent an easy and powerful programming model.

NetObjects for the Internet of Things

NetObjects are persisted objects that are essentially lists of properties such as sensor values. They are found on URL-like identifers or links, which can be used to link up to local and remote peer NetObjects. They can then observe each other's state and be notified of changes to their state. These interactions can occur over radio, serial or IPv6 networks. They use a single, end-to-end, peer-to-peer protocol that can work across mesh radio and the internet, linking up Things and homes.

NetObjects make it easy to program the data transfers and update notifications in your Network of Things. Updates to NetObject properties are notified to other NetObject listeners via a local or remote peer network, around and between homes, schools or offices - factories, farms or shops. NetObjects can be used to create a single, shared "Thingspace" of updating Thing data. They allow you to build a simple distributed system comprising devices, wearables, hubs and servers communicating state changes over radio and the 'net.

NetObjects can see each other's properties or current state through their links, whether they're local or remote, making it easy to program dynamic mutual dependencies between Thing data that can be held on the same device or across the planet.

How NetObjects model your Things

Each Thing (light, switch) can have its own NetObject representing its current state in the form of a persisted bundle of properties with current values (such as "state: on"). If any Thing changes its state - e.g. a sensor value updates or a switch is turned on - then its corresponding NetObject's state can update to reflect that new property value.

Now, obviously the light needs to know about the switch, in order to depend on it.

NetObjects have unique identifiers to locate them by called UIDs. UIDs can be formed into network identifers which are like Web URLs: short strings that you can use to view content from the net - Thing state or property data in our case.

Again, just like on the Web, content can itself contain more links, more UIDs. Our Thing NetObjects can contain the UIDs of their peers.

So we just need a link within the light's NetObject pointing to the UID of the switch's NetObject in order for it to have a handle on the switch so it can depend on it.

Now, if a NetObject is watching or observing the state of another NetObject, via its link UID, then it gets notified of the updating property values of that observed peer. This link-observe-update-notify mechanism is built in to NetObjects.

So the light may be observing the linked switch and will be notified as the switch changes state from 'off' to 'on' and back. Then the light can itself change state (turn 'on' or 'off') in reaction to that.

Further, anything watching the light's state, such as that door lock, can update its own state in turn.

Here's what that looks like in a picture:

Notice how the light observes the button state through asking for the value of 'button:state' - which jumps through the link to the button and attempts to access the button's 'state' property. This kicks off the observation of the whole button NetObject state.

The simple path "button:state" encapsulates everything that is interesting and useful about how NetObjects work:

The "button" property of the light is a link to the button NetObject. That NetObject has a "state" property. By asking for "button:state", you're jumping 'over' that link and trying to see the "state" property, but if you don't have a local copy, this won't be possible and will return null.

But simply asking for this also sets up an observation of the remote NetObject, so when that state is available - once the remote NetObject is cached in locally - its "state" property can be read. And if the button NetObject updates, the light NetObject is notified and can respond accordingly.

NetObjects and other approaches

This may all seem so incredibly obvious that you'd wonder why no-one else does things this way! But NetObjects are completely unique.

This simple modelling and interaction approach differs from existing IoT approaches in that, instead of messages or events over a mesh, which have to be laboriously marshalled around using a low-level interface, NetObjects give you a higher level perspective - of the current and updating state of local and remote Things. The underlying NetObject protocol deals with proxy-cacheing of NetObjects and cache updates, not in messages and events.

A NetObject representing a Thing simply watches its peer NetObjects - whether in the same device or even right across the planet - and is notified of changes in those peers' states. Instead of a mesh of messages, you get a network of local or intermediary caches of NetObjects' state being updated following observation requests.

Why this approach is better

Working with the model of 'NetObjects observing linked NetObjects' means you don't have to think about or manage all of the low-level, piecemeal network activities at all. There's no need to think about messages or events coming and going and then working out the current state of Things by yourself.

You just think in terms of the current state of all the NetObjects as if they're all local (even though they may be in your grannie's living room) and how they update when peer NetObject state changes.

This is a much higher-level model that lets you view your and other's state and set your own state for others to then themselves view. NetObjects make sure you're told when data changes, and your changes are propagated where needed.

Also, this approach works peer-to-peer, not requiring centralised hubs or cloud services. This is more secure, robust and efficient.

Why the NetObject model is good for the IoT

NetObjects create a single, shared "Thingspace" of updating Thing data on links.

NetObjects:

Duncan Cragg, 2016

Contact me and/or subscribe to my blog and/or follow me on Twitter.