How to control any IR based home appliance using iPhone? Will it require SSH/UPnP based application? - iphone

I want to use ssh protocol. I want to make an app to transmit signal that would ultimately converted to control IR based home appliances (like controlled by IR remote control. i.e. TV)
This stuff is new to me. I don't have any clear understanding about how it will be possible.
I got suggestion to use SSH:
->Install SSH on your server.
->Configure your Network / Router to forward the SSH port to server and
->Use the SSH client on the iPhone.
Now. Is it the only way?
Someone also suggested to develop UPnP base app!
Is there any sample code available using which I can learn How to transmit the signal from iPhone to do above.
Please give some guidence if anybody has done such thing before or if they know how to do?
So that I can understand the flow and put my efforts afterwards.

If I understand correctly, you want to go iPhone->IR transmitter->(some device that is controlled by IR)
If so, you probably want to use whatever protocol the IR transmitter device is expecting.
If it's not expecting anything, I would look to HTTP, rather than SSH. Implementing SSH on the iPhone sounds like a huge hassle, and the only benefit of it is the tight security. Unless the device you are controlling is a nuclear weapon, I would go with some simple HTTP authentication.
For example, if it was a TV you were controlling, you could just request http:///remote.php?action=turnonthetv from your server. Then you'd use a PHP script to generate the IR signal to turn on the TV. This moves a lot of the logic off of the iPhone, which may or may not work with what you're doing.

Related

Remote Access of iPhone

I am new to remote access programming, please dont feel bad to place this question here. I didn't get a beginning yet after a long search.
I heard iPhone can be used as remote for cars, electric devices and even accessing iPhone from another iPhone. Which library should I use for remote access? Any tutorial available?
Take a look at the External Accessory Framework. This framework allows you to communicate with "connected devices" (either through bluetooth, or via a physical connection).
If you want anything a bit more complicated you're probably going to have to set one device up as a server and the other as a client and have the two communicate as such.
Another way you could do it is to use an XMPP (aka Jabber) central server and set the two devices up as clients which can push messages to each other to control each other.

testing socket communication offline as a simulation

Whenever having to test my app which basically is some kind of communication via sockets with external devices, the device itself has to be available and connected.
I would like to ask,if there is a way to do the testing offline in some kind of simulation mode?
For instance, redirecting the socket communication to some kind of stored file. And the file itself is a log of a previous session with the real device stored in an appropriate structure. Of course one could only simulate a recorded session, but that would help a lot already.
thanks!
You should have a look at netcat. If you have a record of your "session" in a file, you can use nc to "play it back" on a socket with something like:
nc -l -p port_number < your_file
You can then connect to that port number with telnet and you'll see the session data coming in.
(You can do it the other way around too, i.e. have nc connect to your app and replay the session.)
Don't know iphone, but having a local client, (or server), app. as a simulator is very common on other platforms. It's especially useful if the peer app is under development as well - having a simulator often surfaces protocol bugs at both ends, (as well as in the simulator:).
Given an app spec that includes the protocol, but no peer yet, I usually start work on the simulator first - it gives me time to get experience with the protocol in an non-critical, non-deliverable way while the customer is still bolting on changes to the main app UI :)
Rgds,
Martin

How to create a Mac/PC server app that interacts with iPhone/iPad App?

Can someone please point me in the right direction to create a Mac/PC server app that runs in the background and connects to an iPad app over the local WiFi network?
No matter how I phrase a search on Google it just brings up various apps like Remote Mouse and whatnot and no tutorials or even a hint of where to start.
I just need to send simple commands from iPad to computer over local wifi. A point in the right direction and I can likely fill in the blanks.
Thank you.
Thomas
EDIT: I am using web languages for the iPad version that I will build as a native app using open source tools.
OK, then. It actually depends on what you really need. I made the assumption you need real-time and perhaps binary data transfer.
Your best bet is to write your server application using standard C or C++ so it compiles on both as simply as possible.
If you want to avoid all the burden of writing a protocol for service discovery or asking users to enter the ip address of your server you will use a mDNS implementation for your server and your iPhone app.
If I were you I would try bonjour: http://www.apple.com/support/bonjour/
on iPhone You could start here: http://developer.apple.com/library/mac/#documentation/Networking/Conceptual/NSNetServiceProgGuide/Articles/PublishingServices.html
Once you have your sockets you will have to implement a networking protocol between your server application and your iPhone app.
You will have to be careful about byte ordering and little subtle problems with latency, disconnections and other problems inherent to networking and WiFi.
In windows you will want to register your application as a service and in Mac OS X/UNIX you'll probably want to deamonize it.
Good luck!

How can I debug network requests from my iPhone?

I want to check the network requests an app is making from my iPhone. It's on the same WiFi network as my computer (or if it makes things easier, I can set it up to use an ad-hoc network). I don't want to see every packet, just the URLs which my iPhone is requesting. I don't care about the returned data all that much.
A simple solution would be much appreciated.
If you want to intercept the phone itself you'll need to point it at an http proxy you set up on a computer and watch the requests come through. Something like http://www.charlesproxy.com/ or there are most likely many free proxies.
Connect your computer to the rest
of your local network via Ethernet.
Turn on Internet Sharing from the
Sharing System Preference to share
your Ethernet connection via
AirPort.
Set your iPhone to
connect to the computer as its base
station.
Use Wireshark to
capture and analyze the packets.
I found a really nice repo on github named Wormholy https://github.com/pmusolino/Wormholy it will show every network request on your iphone, you only add it to your pod file and then on your app, you shake your phone and you will see all requests.
Easy to install
Transparent on your app usage
Overview and details of your request
Like so
Screenshot of wormholy usage

How to write an iphone application to control a device that exposes a telnet api

I have to write an iphone application that controls a device. This device exposes a telnet based interface. The application should ideally have user access control and customizability for each user.
I was thinking of writing C++ classes that would communicate with the device using sockets. This functionality can then be exposed through web-services that can be called by the iphone application.
However as i looked into it deeper, the api allows you to register for events using telnet and then you can receive notification when those events occur. That kinda put a spanner in the works for me. I for one dont know a "push" scenario can work with webservices.
First off i have never programmed for the iphone so far. So i am not really sure what can be done. So i was thinking if instead of having a webserver to go through, why not have the application independently running on the iphone, directly communicating with the device using sockets. The question though is, is that possible and second i am thinking it would raise a security aspect. First we could control security as everything was going through our central server. Is there a way to handle security (in the sense who has access to the device) without having a central server.
I am sorry that this seems like an unorganized post, but iam trying to brainstorm here.
Looking forward to hear your opinions.
Look up the NSPort and NSStream classes.
I'm looking to do this same thing. Have a program running on one computer and want to send/receive telnet commands from iOS. Built one for Android using the Commons library- which has a telnet client API, but don't know the best way to do it in Objective-C (without writing a telnet client library).
As a start, however, I found the OFC library on Google Code. Looks like something of a Commons-like feel, and there seems to be a telnet client. You might take a look at that.