Quote: Originally Posted by
Zimans 
So a daemon huh. I'd suggest using sockets over pipes (Unless that is what you meant), be it UNIX-sockets or tcp/udp.
Hmm. I'm not sure, really. I was going to use mkfifo to create a "named pipe" (at least that's what it's called in the windows world), and then open that like a file and read from it or write to it. Is there a more efficient way of doing this? I'd like the least amount of lag possible.
Quote: Originally Posted by
Zimans 
Is this something that will be started by the front-end app, or will it be started as a system service? Is this something that has to be able to handle multiple apps trying to access it? Or will it be owned by the spawning app, possibly using stdin/stdout.
That's up to you. I was going to make a --nodaemon parameter so you could either start it as a system service (that's what I will do), or start it up from your frontend and own it.
Quote: Originally Posted by
Zimans 
Will configuration be done before hand through a .conf file? Will the daemon simply start and wait for a controlling entity to tell it what to connect to. Will it just try to connect to any phone that happens to wander by?
Yes, there will be a conf file. It will, among other things, contain the list of named pipe locations (so you could have /tmp/audioIn or ~myhome/carpc/audioIn) - assuming I go with these named pipes.
I had come up with two ways for it to behave:
#1.
when nothing is connected, it will scan for devices that appear to be phones that support handsfree. Whenever one comes in range or goes out of range, it will send the list of nearby phones to the frontend.
Also, it listens for incoming connections. When you tell your phone to connect to your PC, it will connect as a handsfree kit. Scanning would still go on in the background, if this works (I haven't tried with my adapter).
The frontend can also tell the handsfree service to connect. It can send multiple bdaddr's, and that will be the priority. i.e.
CONNECT <myphone> <yourphone>
That means as soon as myphone is in range, it will connect to it. If myphone is not in range, but yourphone is, it will connect to yourphone. If myphone then comes in range, it will not disconnect. But then if yourphone is disconnected, it will connect to myphone.
The frontend can also say DISCONNECT, which will drop the connection and not try to initiate any more (but will still listen for incoming ones). Or you could say SWITCH <bdaddr1> <bdaddr2>, etc. to re-prioritize the list and reconnect to the highest priority one.
I know that sounds a little complicated, but I think I'm just not explaining it well. Simplest case, you don't send any CONNECT string, and just wait for somebody to click connect on their phone, like most headset earpieces. Or, if you only have one phone, use CONNECT <myphone> to auto-connect to your phone whenever it is within range and DISCONNECT to stop auto-connecting.
#2.
This is a little simpler (for the handsfree daemon). It constantly scans and reports in-range and out-of-range occurences to the frontend. The frontend can say CONNECT <bdaddr> for a single shot connection, when the connection dies (say the device goes out of rantge then comes back in) the frontend would have to re-issue the CONNECT to get it to reconnect.
It would also listen for incoming connections with #2, just like #1.
Quote: Originally Posted by
Zimans 
Is this something that has to be able to handle multiple apps trying to access it?
Good point. The right thing to do would be to solve that. The easy thing would be to assume only one program will ever try to access the handsfree service at a time. I can't imagine a realistic situation in which multiple apps would be all trying to act as a speakerphone at the same time. Although I suppose you could have more than one bluetooth adapter, and more than one cell phone, and try to carry out more than one conversation at a time