Using electric imp with an iPhone app

I’ve been searching the internet, but haven’t been able to find any code for how to get an iOS app and an electric imp to communicate. How would I send messages from an electric imp to an iPhone and vice versa?

Any help would be greatly appreciated

All communication with the imp is done using HTTP requests. This works best with the features in our agents beta (which I can set you up on if you are not already).

For an application like you’re describing, you would probably (although not necessarily) have a server that sits between the imp and the iPhone app. The imp would write information to the server, and the iPhone would read it (and vice versa).

Another option is to have the iPhone talk directly to the imp cloud (again using HTTP requests), and have the imp use a push notification system to send information to the phone. For a generic push platform, I like to use Prowl… if you want something app specific take a look at Urban Airship.

I just posted the code for my iOS app “IoT Buddy”, which is designed to work with the Electric Imp. Currently, it only sends HTTPS from the application to the Imp for control, but its a start. I use xively.com and zapier.com to move data back and forth between my iPhone for some projects, as well as set up triggers and alerts. Xively has an excellent example app that shows you how to fetch and subscribe to services that you set up with them. Here is my code for IoT Buddy

https://github.com/joel-wehr/IoT-Buddy

Thanks for this jwehr.

I’m stuck in making a HTTP request in Android that sends JSON to the imp I used this example>> http://devwiki.electricimp.com/doku.php?id=httpapi which works completely in HTML but forming the JSON like in the link example and sending through android doesnt work I know my Android code is all good >> http://stackoverflow.com/questions/17968947/posting-json-using-http-fedup-and-failed?noredirect=1#comment26267226_17968947

you can use html to make a website at neocities for free and then just make it an icon on your homescreen

I hope this doesn’t count as spam, but it seems that NetIO is able to do what you want… it sends HTTP GET requests and the responses can be parsed with regular expressions, so besides thinking about the regexes there is no programming involved and it works for iOS and Android…

I want to write an mobile app for imp,can i connnect and control the imp direct via socket?

No, all imp comms go via the server. On the upside, this is accessible from anywhere you have internet access without any need to configure a firewall.

can i build the server by myself?the speed accessing the imp’s server often was too slow.

the imp can only connect to the impserver

@myseiun can you define “slow”?

On the flip side, last night I was testing the relay circuit that triggers the siren on my security system. Sending on/off commands using an iOS app. I’m sure the Imp was not sleeping, but wow, it responded quickly. I’m sure the dog appreciated it, because he hates that siren. Maybe my Imp’s are all wired up on caffeine. :wink:

Should be less than 200ms in actual real life, if you have a good connection. From iOS to Imp.

My Comcast connection is pretty snappy. I’d say it was way under 200. Wonder if NSURLConnection has any response time properties?

Jwehr, thanks for sharing the code!