Whoah, thanks for posting this. While I’ve used SMS services it never occurred to me how easy this is now - praise the agents! Now that I have deployed electric imps in my summer house I can just send SMS to switch heating etc, and that for much lower price than the readymade things you can buy.
This is all of the code that I use for my security system, including Twilio and talking to my iOS app Pitchfork. The Twilio code is in the agent.nut and is marked with comments.
I’ve been working with Twilio for ~ a month, and electric imp for a bit less. I wired up a simple LED setup based on Agent for imp Web-Controlled LEDs by: Jim Lindblom [SparkFun Electronics, November 1, 2013].
Right now I’m only interested in receiving SMS on the imp, to create an indicator based on who sent the SMS. A couple of questions:
In the agent code: if(t.From=="+18055551212")
device.send(“sendbody”,t.Body);, is this # ^ my Twilio #, or the phone # that the text originated from?
In the device code, is this the whole of it?
imp.configure(“GetSMS”, [], []);
agent.on(“sendbody”,function(value){
imp.onidle(function(){server.sleepfor(5);}); //blinks for 60 secs
});
Or is ‘function()’ a placeholder? I would think there would be more to it than that, i.e. I would pass a parameter on to my LED control() method and go from there.
At some point I would like to move on to both sending and receiving, but for the moment I’m only looking to process based on the inbound message content.