How can I create a bluetooth headset client? - android

I have a raspberry pi with a speaker and a microphone attached. I'd like this to mimic a bluetooth headset for my cell phone. Basically the same way my beats headphones do... it would connect to my phone via bluetooth, stream audio from the mic to my phone, and play the phones audio over the speakers.
I haven't been able to find many resources online about creating a bluetooth client. Is this possible? It seems like it should be fairly straightforward.

On iOS you would need to apply for their BlueTooth development program. They only let businesses that pass their review develop Bluetooth accessories for iOS devices. (Note the Bluetooth low energy devices don't require a license, just streaming devices like headsets.)

Related

Use Linux as a microphone for mobile phones. Proxy voice over Bluetooth or USB

I am looking for a way to turn my pc into a microphone (wireless or USB) to send voice to the connected mobile device (ios and android).
I couldn't find any information regarding of possibility doing so and my knowledge of Bluetooth protocol is pretty bad so before diving deep into it I would like to know if it's even possible.
My thoughts were to use the PulseAudio-Bluetooth module to transfer voice but is it possible to make my Linux be discoverable as a microphone with it?

Android, AOA2, USB Isochronous Audio Streaming

Using AOA v2 protocol, a android device can output its audio stream to some accessory connected over an USB. But is it possible for the accessory to send over its audio stream to android device so that the android device will act as an USB speaker?
I'm actually planning to write a USB speaker driver using AOA protocol, but I just got stuck here. Because I can make the device initialize in AOA mode, but can't get the endpoints for audio interface. So I kind of leaning towards to believe that audio input to android device isn't possible using AOA. Anyone has any experience with that?
As of Android OS v5, Audio to the device ( Mic use-case ) is not supported, what you can do to achieve what you're trying, is, to use BlueTooth to simulate a headset where you have bi-directional audio.
On Linux you can use the BluZ BT stack ( quite powerful )
On Windows you'll have to implement a BT Profile Driver

need idea on sending/receiveing audio over A2DP between android/non-android device

I need to be able to send and receive audio over bluetooth and it seems A2DP is the thing that does this
Using the code given here, I managed to get my phone to detect and pair with the remote bluetooth device, then establish an A2DP connection which sent all the audio output of the android device to the remote one via bluetooth
I was previously able to do such two way data communication with the same remote bluetooth device via RFCOMM (the android phone needed to be the one initiating the communication though, I could not do it through the remote device though I know it is possible). Once the RFCOMM link was established, the android device could send data to the remote device, as well as receive data from it
What I need now is something similar, but for audio (preferrably using A2DP, but I am open to using whatever else, as long as it gets the job done). While snooping around SO I've got hints that receiving audio data on phone (at least an unrooted normal one, rooting is not an option for me) via A2DP is not possible (see for example, here). But I have also seen headsets that allow making phone calls entirely through bluetooth (well, wirelessly actually, I am assuming it must be bluetooth). For example, for an incoming call, you can just press a button on the bluetooth earpiece, then you can talk as well as listen to the other party. If a phone cannot be used as an audio sink, how do such headsets do it?
I need some ideas on how I should go about writing an android app to send as well as receive audio data via bluetooth (for simplicity lets consider it similar to the Bluechat sample program, but involving audio instead of text). Is it possible at all (through java)? Is it possible only through NDK? How do the devices on the market do it? Is it a different profile than A2DP?
PS: My test devices are Samsung Galaxy 2 (phone) with Gingerbread and Asus Nexus 7 (tablet) with KitKat. Incidentally the remote bluetooth device (it is a development board) comes with a sample project that is supposed to turn the board into an A2DP audio source. if I run this sample project on the board, using the phone's and tablet's built-in bluetooth settings, I can sort of pair with the remote board, but the android devices do not receive any audio.
There are two different A2DP profiles, A2DP source and A2DP sink. The A2DP source profile is supported by Android thus allowing you to stream music from your device to a sink like a bluetooth speaker. To my knowledge the A2DP sink profile is not enabled, which is why you're unable to stream music to your mobile phone and have it act as a speaker. I only know this from having googled around some time ago so things may have changed.
It is possible to enable the A2DP sink profile by editing /etc/bluetooth/audio.conf and rebooting your phone. Unfortunately this has the side-effect of disabling the A2DP source profile and thus cannot be used in a widely distributed app. The other downside is that there is not much of a java software stack for working with that profile so you'd have to do quite a bit of work to get things rolling.
To answer your question as to why a headset is able to connect to the Android, that is because headsets use a different profile called Headset profile (HSP), commonly used by headsets, or Handsfree profile (HFP) commonly used in cars. Both profiles have two sides: a client side and the gateway side (mobile phone). The audio quality of both of these profiles is considered voice quality. 8 or 16kHz sample rates and a crappy codec. There is also a lot of protocol for answering/making calls, etc... I'm not sure if you'd even get audio to transmit without an active connection to the phone network.
For A2DP Sink support -
Yes. It is possible. I have done it in Android JB.
Android device as a receiver for A2DP profile - Please read my reply.

Turn Android phone into Bluetooth headset

Let's assume we have a rooted Android OS on a device that supports Bluetooth. Can we build an app that advertises itself as a Bluetooth speaker via Bluetooth A2DP?
If that was possible, then any other device could pair / connect to our Bluetooth server app and stream any music / sound. This server app could then take the music stream and play it locally or even send it to other devices via Wi-Fi. This would theoretically enable a multi-room Bluetooth solution.
Any idea how to achieve this? Where would I start?
Turns out there is a very good and detailed answer to a related question here.
Short Answer: Possible, but requires to modify the Android OS configuration and quite some low level NDK development to expose the A2DP Sink role as API to be used.
Thanks #BartPlatak for the pointer!

How to Stream Audio from PC through Bluetooth

Here's what I am trying to do. Capture any audio being currently played on the PC and stream it through Bluetooth and then play it through the Android device paired with the PC. I have worked with Bluetooth a little but very basic stuffs. And I have very less idea on how to go about on this. My target device is Android 2.2 (and above). I guess I have to use Bluetooth profiles, but not too sure. Also, I am not aware of any other caveats that I may have to face.
Would anyone like to point me at the correct direction. Any tips, links would help. Thank You.
It depends on the capability / profile that your android device supports, for streaming you normally will use the A2DP profile and the android device will need to support the A2DP sink role. Typically this role is supported by Stereo headsets , speakers etc. Android phones do not support sink - phones are A2DP source (or initiator of the streaming)

Categories

Resources