At Electric Imp, we’re getting ready to retire our old friend the Blueprint (or Planner as it’s sometimes called), and we want to make the transition is as seamless as possible for the developers who are still using Blueprint functionality. We’ve been hinting that this change is coming from a few months, and on December 17, 2013 all services associated with the Blueprint will be shut down.

If you’re one of the developers who are still using the Blueprint, fear not, migrating your code to use agents is not that difficult. We’ve already written about Migrating from HTTP In Nodes to http.onrequest, and have replaced the COSM node with a library for interacting with Xively (COSM became Xively in September 2013). This post will look at what’s involved in getting two imps to talk to each other, which turns out to be quite easy with HTTPS requests.

Let’s dive right into an example, such as controlling an LED on one imp with a button on another. We’re going to build the following circuit for each of our imps:


Controlling the LED
The first bit of code we need to write is an API for our LED – luckily, we’ve already done this in the third part of our Getting Started Guide.

Agent Code

Device Code

Sending Messages when the Button is Pressed
Now that we have an API for our LED, we need to write some code to make a button press send an HTTPS request to the API to trigger the LED.

The first thing we’re going to do is write some device code to send button press events to the agent:

Device Code

The next thing we need to do is write some agent code that will catch the “button” message and make a request to the other agent’s URL.

Agent Code

That should do it. If everything is wired up and running correctly, pressing the button on one of your imps should trigger the LED on the other.

This is a fairly simple example, and only scratches the surface of what’s possible in terms of writing APIs and sending HTTPS requests. However, it should serve as a good starting point for migrating any of your projects that are currently using Input and Output ports for communication between imps.

If you have projects that are currently using Blueprint functionality (InputPorts and OutputPorts), you need to migrate them away from that functionality before December 17, 2013 if you want them to continue working uninterrupted.

Please feel free to reach out on our forums if you have further questions about the migration process.

Happy Coding,

Matt Haines
Community Manager