About ELECTRIC IMP
Electric Imp provides a powerful Internet of Things platform that securely connects devices with cloud computing resources. Their solution consolidates a system of fully integrated hardware, OS, security, APIs and cloud services. Their platform enables innovative commercial and industrial applications and empowers manufacturers to manage and quickly scale their connected products and services to millions of users.
Electric Imp provides developers with a set of Imp APIs as well as build APIs. Imp APIs are a set of classes and global objects accessible from the device and agent code on the Imp Platform. It allows programing the local hardware beside other remote cloud functionalities.
The Electric Imp Build API provides developers with a means to access the functionality of Electric Imp’s web-based IDE, allowing them to develop imp application models using the tools of their choice. For example, it provides a way to list the models the developer has created and any devices associated with them. Devices can be moved from model to model, their human-friendly names changed, or placed in an unassigned state. Device logs can be downloaded for inspection. New models can be created, old one deleted. Agent and device code can be uploaded, and older versions accessed. Devices can be restarted.
Scriptr.io-Electricimp Connector
Beside performing functionality actions on the Electric Imp’s web-based IDE, developers would be interested in executing backend logic and data processing in javascript code on the Electric Imp’s web-based IDE functionalities. Scriptr.io can provide this privilege. To make it easier, scriptr.io have wrapped Electric Imp build APIs into a javascript connector that can be easily deployed into your scriptr.io account from your workspace.
Simulating the APIs
We have implemented a simple application to demonstrate the feasibility of calling the Electricimp API set from a scriptr.io connector.
Pre-requisites
In order to implement the following sample application, you need to:
- Sign up for an account at Electric Imp
- Create a scriptr.io account
- Install the Electric Imp module in your scriptr.io account (Code on Github)
- Access the Electric Imp online IDE to monitor the applied API results
Test Example
In the test example below we will create, update, retrieve details and delete anElectric Imp model.
var resp = new model.Model("FirstModel"); var updateNameResult = resp.updateName("FirstModelUpdated"); console.log("Model name update result: " + updateNameResult); var modelDetails = resp.getDetails(); console.log("Model details result: " + modelDetails); var deleteResults = resp.delete(); console.log("Model delete result: " + deleteResults);
Below is the response of updating an Electric Imp model:
{ "model":{ "id":"Aj5-ygNHmIZF", "name":"FirstModelUpdated", "latest_version_created_at":"2017-01-24T12:25:17.690Z", "devices":[] }, "success": true }
GET THE CODE
You can get the source code of this sample application from Github.