CoreAudio AudioQueue i/o redirect to/from phone app? - iphone

I've been reading up on some of the iPhone audio services in considering an audio recording/playback app, but ideally I'd like to be able to use the other end of a phone connection as inputs and outputs, i.e. remote speaker and remote microphone via cellular (or VoIP, but for now cellular's the question), when it's on, as input and output targets for redirect... I can't seem to find any documentation saying this is possible or impossible... obviously apple phone app is closed source, and I can't modify it, but can I just hook up to either or both of its streams? Does it make any difference if it's a call initiated by my app or not?

I'm afraid that is not possible to reroute the audio source and sink of a phone call on iPhone. It is possible on other smartphone platforms.
You could route the local mic and speaker over a network connection that would use the default network route (either WiFi or cellular data) to achieve your goals.

Related

Accept or reject a call on bluetooth device (like smart watch) from iPhone?

In some of the Smart watches like pebble and meta watch,it is possible to accept and reject calls on the smart watch.how the call related info be transferred between iPhone and bluetooth device using MAP or PBAP. I would like to accept the call from the bluetooth device similar to earphone where I can accept the call via bluetooth.
Is there any legitimate api or any pointers to accomplish this ?
EDIT
Metawatch has inbuilt microphone and speaker and it implements HFP and PBAP.If smart watch has in built microphone and speaker and if it implements HFP,calls can be accepted from the watch,but Pebble does not have in built microphone and speaker. Still Pebble is able to accept the call and route it to headset. Pebble supports HFP,MAP,AVRCP and SPP on iOS and it is an MFi.How can the same be implemented in an app?
You can write your own application to intercept incoming call events and using your own communication mechanism (over Bluetooth) communicate this info to your device (i.e. watch)
With this you can fairly easily pass incoming call indication to the watch,
Accepting call is more involved as you need to have the ability to intercept an ongoing bluetooth profile connection, Android has the BluetoothHeadset Class that provides some capability, with iOS there is no straight forway way (but it is possible)

iOS and Bluetooth low energy, possibilities?

I want to connect a robot, via Bluetooth, with an iPhone (4S or more) via Bluetooth low energy (BLE) 4.0. This robots require to send all the notifications of the iPhone to the device.
For example: If the iPhone gets a new email, I must send the event to the robot, and it will blink an LED. Stop.
I want to know if the iOS Bluetooth APIs of the Bluetooth framework can do this, or better, can share the Internet connection or whatever that can do this work.
I'm asking this, because I have heard that the APIs have some restrictions.
PS: ANY solution that can do this is very accepted (no Wi-Fi connection solution).
Bluetooth LE would be the way you want to go here, because standard Bluetooth requires your device to be MFi-compliant. Standard Wi-Fi could also work, if you're able to require the presence of the supporting network.
As of iOS 6.0, you can set up your iPhone as a Bluetooth LE peripheral, which would allow it to send notifications to your device, if it is configured in a central role. That would be a pretty power-efficient way of updating your device with new data.
However, there's one large hurdle to doing what you want here. iOS applications have no access to system-wide notifications, so you won't be able to listen for incoming emails or other notifications like that. You'll be able to send data to your device via Bluetooth LE, but you're not going to know when emails come in so that you could send that to your device.
With bluetooth 4, you could control a robot, as well as create a "notification" bot. It could be done quite easily. However as mentioned, you can't access system wide notifications in iOS.
However, you could use an external solution to listen for system notifications and then an API to listen a singular encoded notification and have your app listen to that.
One such system is https://ifttt.com (no affiliation)
There are also some great plug and play BLE options for rapid prototyping.
You can do it. A simple solution would be let a phone check your email periodically. Don't rely or try to use external Apple applications to do that, but use services provided by your mail.
In the case of Gmail, try to go to https://mail.google.com/mail/feed/atom. If you are logged in your Gmail, you will see the unread mail in XML format. The way you would login using a URL is: https://username:password#mail.google.com/mail/feed/atom
So what you can do is periodically parse the output and when <fullcount>0</fullcount> value changes call your robot service via BLE which should act as a callback for this specific event.

iOS SDK Disable Internal Microphone

I am developing an iOS application that receives data through the auxiliary port (microphone).
We got oscilloscopes hooked up and are at the point where we can measure frequencies and amplitudes on a testing iPhone.
However, even with the auxiliary cable connected, the iPhone still listens to the internal microphone in addition to our external AUX input thus watering down our measurements.
The iPhone definitely recognizes the connected AUX cable (internal speakers are turned off).
Is there any way to programmatically disable the built-in microphone?
or
Is there some special signal we can send through the AUX port to disable the internal microphone?
After much research on this topic, there is no way to do it at this moment in time.
If you look at the Audio Session Programming Guide and the AVCaptureDevice Class Reference, all the properties relating to the devices input sources and audio routes are readonly.
If it's of any use, you can detect whether or not headphones or an external mic are plugged in. Here's a question relating to that.
I don't believe you can disable the built-in microphone without the user physically pressing the silent switch, but maybe you could store the data recorded by the built-in mic and then filter it out of the measurements taken by the oscilloscopes? I don't know how you would go about implementing this; it's just a theory.
Hope this helps!

iOS adhoc wifi sensor data

My iPhone connects over adhoc wifi to a wifi sensor module.
The challenge is to code an app that uses this sensor module. But I'm not sure what specific API's to use to best architect this implementation.
I've started looking into the CocoaAsyncSocket class as it seems to be an appropriate tool for such use.
Does the user always have to manually connect to the adhoc wifi device? (through the Settings app) or can my own app handle the searching, making, and breaking of the wifi connection?
I doubt iOS lets me programmatically toggle whether Wifi is on/off.
Once the sensor data is being received, what container would best handle the stream?
For example, on other platforms, I coded a rotating queue buffer.
Thanks for your input.
Edit: The protocol in question is straight CSV formatted ASCII. Not HTTP, FTP, etc. Just raw data. The app is to simply open a port on the connected IP, and read/write.
Your application cannot turn wifi on/off, or select a wifi network.
Without more information on what protocols this wifi sensor module speaks, it will be impossible for anyone to give more than vague recommendations. If the module can serve data over an http connection, that would probably be ideal. If it requires your software to open a connection on a specific port and communicate over something other than http or ftp, your job will be a bit more complicated. CFNetwork and projects derived from it's usage, such as CocoaAsyncSocket which you mentioned. You can see another implementation of an HTTP connection over CFNetwork in ASIHTTPRequest, that may help as a reference for handling download streams, queuing operations, etc.
As for storing the data, again it's hard to give any concrete recommendations without more information. If you want to store the data to the filesystem of the iOS device, NSData will probably meet your needs. If you need/prefer to use a queue for buffering data, there is a simple category on NSArray which provides queue semantics. The link to CHCircularBuffer in that SO article is dead, but this github project appears to have it.
edit: Here is the official version of the CHDataStructures. I don't know if it's an improvement over the previous link, but it appears to be updated for the more recent iOS SDK.
Add the SSID of your wifi ad hoc networks in settings. When you see the SSID of the network, click the arrow and choose connect automatically. After this, the phone will automatically connect whenever it comes in range. After this, the two devices can communicate using regular socket APIs.

How does "Truphone Anywhere"<TM> place a GSM call on the iPhone?

As far as I understand, the only way to place a call from an app is using the tel:// URL scheme, which launches the native phone app. But the Truphone app available on the App Store can place VOIP call even when there is no WIFI available. They say they do it by making a GSM call to their server and routing the VOIP packets over the internet from there.
Rerference: http://blog.truphone.com/2008/12/truphone-on-the-iphone-now-works-without-wi-fi.html
How can I do something similar in my app?
As far as the phone's cell hardware is concerned this isn't a call. Its just a 2 way data stream. They are activating the mic and encoding its input and sending that stream to their server, while they receive another stream and play it on the speaker. Their servers then decode the streams and then connect it to a normal phone system so you can talk to someone who doesn't use their service.
Do you want to allow users to contact people outside your userbase? If so that's going to require you to set up a server to decode your streams and then find a VOIP provider that has an API so your server can stream to them. This is possible but it costs.
If you only want user to user this can be done for free but its almost identical to the previous option, just take out the VOIP provider.