Any advice for iPhone Wireless Comms with Embedded Linux Device? - iphone

I am looking for advice on protocols for use in LAN comms between an iPhone and an embedded Linux device. The embedded Linux device requires the following functionality...
Connectible to Wireless LAN.
Discoverable as a device on the Wireless LAN.
(Virtually) connectible with iPhone.
Remotely Callable API provided to the iPhone.
Able to remotely call back functions on the iPhone.
I am looking to use platform independent protocols to achieve this functionality because the mobile application will be ported from the iPhone to other mobile platforms like Android. Since I am a newbie with Embedded Linux, my research (and possibly naivety) suggests that said functionality could be realised with the following protocols...
DHCP for obtaining dynamic IP address.
DNLA? (Bonjour is native to iOS right?)
Connection-oriented communication implies TCP.
SOAP or REST architecture on HTTP.
SOAP or REST architecture on HTTP.
Can you suggest other, more suitable protocols? Am I barking up the wrong tree? Is there a much more simple way I could achieve this functionality? For example, providing the remote API using only a TCP socket?
Any advice you can offer is welcome...

Look into 0mq. It's a scalable messaging library that provides a message queue without requiring a message broker.
-Has objective-c bindings to help you implement in iOS
-Has java bindings to help you implement in Android.
-Small footprint.

I did something similar - an Arduino that streams data to an iPhone app connected over WiFi using the UDP protocol.

Related

several iPads talking to a single main iPad?

I need to develop an app where several ipads communicate to a single main iPad. Would this be done using Bonjour or Game Kit? I looked at Bluetooth but that seems like a 1 to 1 communication. I have never messed with either of these API's
You could use Bonjour to do this -- but remember that Bonjour is only a framework to advertise services and doesn't do any of the actual connection itself.
For Bonjour, you need to create an NSNetServicesBrowser to scan the network (which can use Bluetooth -- or WiFi) and publish an NTNetService with the port for the other iPads to connect to (this could be the "master" iPad itself).
Then you would need to run a server on the "master" iPad (that is advertising the service) and then have some sockets code to handle all of that. (For which I recommend AsyncSocket (http://code.google.com/p/cocoaasyncsocket/).
Let me know if this is something you would be interested in doing, and I would be able to provide some code snippets as a starting point...
Like Glycerin said earlier, take a look at WebSockets. You can choose to have one-to-one, one-to-many, many-to-many connections, and is insanely fast.
Here's a tutorial on Nettuts
WebSockets are the way to go. I would suggest learning about the basics of sockets, there are implementation in most programming languages. This helped me a lot: http://beej.us/guide/bgnet/ After getting a understanding of what sockets are and what they do u could use the CocoaAsyncSocket-Framework http://code.google.com/p/cocoaasyncsocket/ on iOS. It adds an additional level of abstraction to sockets that helps especially with non-blocking network communication. There is some sample code available.

Publishing a MIDI source as a Bonjour service

I have written a VST/AU/RTAS synthesiser plugin for OSX and Windows that also has an iPhone equivalent. I would like to allow the two to communicate with each other over a local area network so that the iPhone app can be used to send MIDI controller data to the plugin. I plan to create a MIDI source on the iPhone and publish it as a Bonjour service so that the plugin running on OSX or Windows can find it and receive midi from it.
I have a couple of questions to ask about this:
1) Do I actually have to publish the MIDI source as a Bonjour service or does a coremidi host (running on iPhone) automatically publish itself?
2) Are there any code examples available that show how to do this sort of thing?
I have seen the following post but the answer to this only covers the client side, finding a Bonjour service but not the publishing side, and it transmits MIDI via OSC, and it only covers OSX but not Windows (I know, I'm not asking much! ;) )
How to send MIDI or OSC signals to a Mac application from my iOS application?
Cheers,
John.
AFAIK you'll have to publish the service yourself. NSNetService and NSNetServiceBrowser are the classes you need. Check out the companion guide. I found this article on Cocoa for Scientists particularly helpful in getting started. Both have some decent code samples. The Bonjour Browser is useful for testing.
The list of bonjour service types already has
apple-midi
and
imidi
But I think it's best to make up your own application-specific type name unless your app is plug-compatible with one of these services.

How to do peer-to-peer communication in an iPhone app?

I'm trying to write a simple chat application for the iPhone (as an experiment). Is there a simple way for two devices to discover each others' IP addresses, and given the addresses is there a simple API or protocol that would let me send text messages back and forth?
I've investigated SIP (specifically Sofia and eXosip), but these tools exist as C libraries and are beyond my current ability to port them to the iPhone.
Update: I'm trying to connect two devices over the Internet (i.e. not over Bluetooth or a local wireless network, which is what GameKit does).
You're going to need a server that provides the match making service. Game Center makes this pretty easy, but your users will have to have Game Center accounts.
Alternatively, you can set up an XMPP (formerly Jabber, it's what powers Google Chat) server (I've never done this, but there are several available) and use the XMPP Framework for Cocoa. There are instructions for using it in iPhone apps here.
I'm sure there are other chat servers and client source also available. IRC and Mobile Colloquy come to mind.
Finally, you could write your own server using your favorite server language / framework. This isn't too hard (I've done it myself), but it's far from what I'd call simple, and I wouldn't use it for a production system.
There is support for exactly this kind of ad-hoc peer-to-peer networking in GameKit. Have a look at the second half of the GameKit documentation for details:
http://developer.apple.com/library/ios/#documentation/...
NSNetService is a good option.
Take a look at WebRTC Datachannels. WebRTC is a newer option with native iOS support a standard that is still being finalized, but it is more flexible should the iOS app need to communicate with browser or even android peers

how to setup voice chat over wifi and 3G network?

I wanted to add a voice chat feature to my business app. I have been trying hard to find anything useful but there is not much help regarding this. Could anyone plz point me to something concrete??
PS: The skype app makes use of this feature.
This is a lot of work as there is no "built in" sdk features or third party off the self components that will help you do it without a lot of work on your end.
Your options (as far as I know) are:
Build your own solution.
Look for a third party solution.
Look for a open source solution.
Voice "chat" could be one of many things like:
using the voice features of a cellular network to a conference call.
using the voice features of a cellular network with a PBX server that supports conference calls.
using a VOIP solution using a SIP stack with a SIP server
using a XMPP Jingle solution (I believe the google voice service uses this)
using your own SIP setup solution
custom solution
None of these options are easy.
Open Source SIP implementations that have iphone ports (that I know of):
reSIProcate
pjsip
Update:
SIP & Jingle both use RTP for the actual transport protocol between the parties. RTP is a UDP point-to-point protocol. The ports which form a session are negotiated using other protocols such as RTSP (using SDP in the setup method) and SIP. RTP and RTCP typically use unprivileged UDP ports (1024 to 65535).
For easy Server / Client setup check Jingle Nodes in combination with SIP Communicator which is a Desktop application. But as being opensource I presume you can reuse a lot of the code to make it mobile. Specially for Android. Check this draft of a Jingle Nodes Setup Guide

Is it possible, in principle, for an Android device to interface with an iPhone over Bluetooth/GameKit?

(I am not interested in pure theory, but as a practical near or mid-term possibility, say within 12-24 months.)
As a developer familiar with (but not specializing in) two major smartphone platforms, should I expect an Android library to come out which can spoof itself onto an iPhone app's GameKit-based network. It seems reasonable that a Bluetooth interface between platforms might square the opportunity to make useful applications, in the same way that modems benefited PC/Mac platforms via Metcalfe's Law.
I am looking for one of two answers:
Is this obviously not likely (e.g. because of encryption)? If so, what is the reason? Is it possible in principle, but requiring years of reverse-engineering (like SMB/CIFS/Samba)? Or is it a no-brainer and just a matter of time? Please give evidence supporting your reason.
Is there an alternative way to have direct peer-to-peer networking besides GameKit? For example, a hand-rolled network using Bluetooth or ad-hoc WiFi? It would be nice to spoof an Android device into an existing iPhone app but my main question is, can the devices speak with each other at all!
Yes, it is possible. GameKit is a protocol using TCP and/or UDP over a BNEP Bluetooth connection. It also uses a trick to identify other iOS devices using the Extended Inquiry mechanism in Bluetooth 2.1+.
I was able to simulate the EIR responses, now, someone needs to reverse engineer the GameKit protocol. This doesn't need Bluetooth, as it is also used for GameKit connections over WLAN.
If anybody can re-implment GameKit for WLAN connections, I can finish the Bluetooth version.
No, and it wont come soon or even at all... Apple pride themselves with their security features, and bluetooth connections can access private data. There will probably not be any cross platform bluetooth framework until something is agreed upon by both companies.
Bump as said by a previous answerer uses a remote server, and the data transferred is not via BT.
GameKit is Bonjour so a Bonjour (which is on IP) over Bluetooth on Android should work.
That should be possible as Bluetooth is capable of setting up tcp/ip networks. Though I have no knowledge of the IPhone SDK whatsoever, but Android does have a BluetoothSocket and BluetoothServerSocket for TCP connections.
This article, http://blog.moritzhaarmann.de/blog/2014/04/27/sorry-state-of-p2p/ written in 2014, suggest it is possible via Bluetooth LE. Available in Android 4.3+ and iOS6+
Two issues:
According to the Android Dashboard only around 30 percent of Android devices support Bluetooth LE https://developer.android.com/about/dashboards/index.html?utm_source=ausdroid.net
Communication between Android-to-Android must be done using some other method (which is not a big problem) because Android devices cannot act as server for B LE connections.
Bounjour on the iPhone gives you full access to all of the Bluetooth protocols, so you don't have to use GameKit. As for when someone will provide an easy to use iPhone to Android GameKit like framework - hard to tell.
An iPhone can already talk to any other Bluetooth device using Bonjour today.
-t
It is absolutely possible! In fact I am amazed that more people haven't done it!
Theory:
Bluetooth is just a wireless socket that you push data across and it comes across the other side, just like tcp/ip.
Practice:
http://www.techcrunch.com/2009/11/11/bump-goes-cross-platform-with-new-android-app-upgrades-iphone-version-too/
Better yet, Bump is cross-platform, which means that you can bump an Android phone with an iPhone and it should work seamlessly.