Feeds
Electric Imp

Little devil: Electric Imp is an Internet of Things Wi-Fi PC-ON-AN-SD-CARD

The card micro that makes connecting projects to the cloud easy

SANS - Survey on application security programs

Blink me

The phone’s favoured wireless network is already listed for the Imp to use, but you can enter others, along with their passwords. I had to do this: my main WLAN, presented by the app, sits in the 5GHz band, a region the Imp’s 2.4GHz radio can’t access. The Imp currently remembers only one wireless network, but Electric Imp developer relations chief, Matt Haines, tells me upcoming ImpOS upgrades may allow multiple networks to be recorded and add the ability to hop onto free hotspots out in the wild.

Whether you use the network the phone already knows about or key in the details of another one, you next hold the phone’s screen up against a tiny window on the end of the Imp, and the SSID and associated WPA key are literally flashed across. Audio tones tell you when to put screen to card and take it away again. If all’s well, the card will now connect to the internet and Electric Imp’s servers, download and apply any firmware updates.

Now it’s ready to use.

Electric Imp app

Electric Imp’s app: choose or enter your WLAN’s details (left) then prepare to flash the data to the Imp (right)

Programming the Imp is carried out in an online IDE. Imp uses an object-oriented scripting language called Squirrel to code two event-driven programs that run in parallel: one in the Imp, the other on Electric Imp’s servers. The latter program is called an “Agent” and it provides a web-based (HTTPS) mechanism for routing control commands and data over the internet to your Imp. Electric Imp manages the security and handles accessing Imps across routers’ NAT tables and firewalls, but of course you’ll need to sign up for a free account to make use of it.

Each Agent is assigned a unique web address which can then be embedded in a local HTML page presented by a browser or coded into a mobile app and accessed using Android and iOS stock URL handlers. You can pass named parameters tacked onto the end of the URL just as you would if you were scripting basic browser-server interaction, and code the Agent to parse those parameters when it’s passed an inbound request.

One response the Agent can make is to fire off a message to the device. The second program, running on the Imp, in turn reacts to this message by calling functions that can examine data sent by the Agent and perform actions accordingly, typically by sending signals out through the GPIO ports, the three-channel UART, two-channel I2C and two-channel SPI buses, either to control another device or to read data from it.

The Imp code can then send a message back to the Agent, to which it can respond, perhaps by informing the browser or app in front of the user, or to send further messages back to the device. You might, for instance, want to perform particularly weighty calculations on the back end to help keep the device’s power consumption as low as possible. But the Imp has processing resources to apply logic to the data coming in off through the GPIO.

Electric Imp IDE

You code a Model’s Agents and Imps in an online IDE
Click for larger image

It’s not hard to imagine a typical usage scenario. A mobile app asks for, receives and displays the temperature in your living room, from the Imp, then allows you to turn the central heating on if it’s getting a bit nippy. A more advanced version might detect that you’ve left work for home, that it’s the middle of winter and so interrogate an online weather service to see if it had better get the boiler fired up on your behalf.

The big question, of course, is whether the intelligence to handle this goes in the device - via the Imp, say - or resides in the app. By giving the Imp compute capability, it can also run code that doesn’t need user interaction.

Electric Imp’s IDE presents Agent code side by side with the Device code so it’s easy to look back and forth between them to ensure, say, you’ve got your message parameters applied consistently. You can have the IDE error-check the code without beaming it to the Imp, or upload and run Agent code and device code immediately.

Together Agent code and device code form what Electric Imp calls a “Model”. Only one Model can be applied to an Imp at once, and Electric Imp could improve how you work on multiple Models in parallel. As it stands, a Model that’s not currently associated with an Imp can’t be edited. Multiple Imps can be assigned the same Model.

Electric Imp

Breadboarded, powered and connected

The IDE doesn’t compile code: ImpOS incorporates a Squirrel interpreter. There’s clearly a small memory penalty involved in storing tokenised source code on the device rather than machine code, admits Haines, but the quid pro quo is that it makes it almost impossible to crash the hardware: the interpreter should be able to catch and stop any code before it takes out the system. On a lightweight embedded device in particular, compiled bare-metal code may find it has the freedom to cause more havoc.

The Squirrel language itself is not too hard to get to grips with if you’ve programmed C or Python before, and you’re doing relatively simple stuff. More complex code has a steeper learning curve. Being interpreted, it has one or two weak spots, bit-level maths operations in particular. The language has been used in a number of video games as a scripting language, but its use isn’t widespread. The available documentation is aimed more at the computer scientist than at the amateur programmer.

Squirrel is available under the open source MIT licence, but at this stage only its creator, Alberto Demichelis, is working on its future development and expansion.

High performance access to file storage

More from The Register

next story
This time it's 'Personal': new Office 365 sub covers just two devices
Redmond also brings Office into Google's back yard
Oh no, Joe: WinPhone users already griping over 8.1 mega-update
Hang on. Which bit of Developer Preview don't you understand?
Microsoft lobs pre-release Windows Phone 8.1 at devs who dare
App makers can load it before anyone else, but if they do they're stuck with it
Half of Twitter's 'active users' are SILENT STALKERS
Nearly 50% have NEVER tweeted a word
Internet-of-stuff startup dumps NoSQL for ... SQL?
NoSQL taste great at first but lacks proper nutrients, says startup cloud whiz
IRS boss on XP migration: 'Classic fix the airplane while you're flying it attempt'
Plus: Condoleezza Rice at Dropbox 'maybe she can find ... weapons of mass destruction'
Ditch the sync, paddle in the Streem: Upstart offers syncless sharing
Upload, delete and carry on sharing afterwards?
New Facebook phone app allows you to stalk your mates
Nearby Friends feature goes live in a few weeks
Microsoft TIER SMEAR changes app prices whether devs ask or not
Some go up, some go down, Redmond goes silent
prev story

Whitepapers

Securing web applications made simple and scalable
In this whitepaper learn how automated security testing can provide a simple and scalable way to protect your web applications.
3 Big data security analytics techniques
Applying these Big Data security analytics techniques can help you make your business safer by detecting attacks early, before significant damage is done.
The benefits of software based PBX
Why you should break free from your proprietary PBX and how to leverage your existing server hardware.
Top three mobile application threats
Learn about three of the top mobile application security threats facing businesses today and recommendations on how to mitigate the risk.
Combat fraud and increase customer satisfaction
Based on their experience using HP ArcSight Enterprise Security Manager for IT security operations, Finansbank moved to HP ArcSight ESM for fraud management.