Connecting to a non-symbian device
| Tue, 2006-04-04 20:06 | |
|
I am currently working on a project that the goal is to connect a phone to a device that we are designing. The device will be running a version of linux and will have the bluetooth stack and everything that is need for connecting to bluetooth devices.
My problem is, almost every sample bluetooth application I have come across generally is just how to connect two phones together. While this gives me an idea of what is necessary, I think it will probably be a bit more complicated. So what I would like to do for now, since we don't have the base station up and running, is to just have the phone recognize a connection attempt from my PC, and accept it. This way I might be able to work out some kinks in the coding on the phone at least. I have been using BTPMP and btpointtopoint examples as a guide in programming, but some of it might be a bit over my head for the time being. I think that I need to open a Rsocket and listen for a connection attempt? Eventually I want to advertise a service, but I wouldn't think that is required to just look for a connection attempt. Anyone have any pointers on how to have a program recognize a connection attempt from a PC? Perhaps an example thats out there that I haven't found yet? Any help would be appreciated. |
|






Forum posts: 183
Have a look here http://bemused.sourceforge.net
Computer and phone connecting but the phone is the client and the PC is the server. ie phone initiates the connection. Got source code for both client and server.
Regards,
Isseyp
Forum posts: 9
Shortly after I posted last time, I found this bemused project. However, the roles are reversed in my application, that is, the cell phone is the server, and the PC is the client (initiates the connection).
I actually have gotten a little further in my coding. On the cell phone side I am able to advertise my new service, and I can see the service on my linux desktop. The next step would be to initialize a connection from the PC to the phone. This I have also accomplished to some degree. However, I would like to have the cellphone automatically accept the connection without authentication or authorization. This is done in the PMP example by opening a listening channel and setting those security settings to false. I have also gotten this to work.
However, I am somewhat concerned with the security of this method. This seems to allow any device that knows to connect to that specific channel access to connecting to the phone. I would like to make it so that only my device will be able to connect to it. This could be done by pairing the phone and the device, but I would like to work around that, because the idea is that I could make more than one device (and thus different mac addresses, which is what it seems to pair to), and I want it to be able to connect to those as well. So maybe not just connecting to my device, but a program or service running on my device.
There are 2 ways I can see maybe being able to do this with my limited knowledge of how this works:
1) Somehow detect the "service" of my PC that is trying to connect to the phone, accepting the connection if it is my service/device, and rejecting it if it is not.
2) Reverse the roles of my PC/phone, but somehow sending a command from the PC to the phone that tells the phone to initiate the connection. (I don't want the phone to constantly be searching for bluetooth devices).
Is there any conceivable way of accomplishing this?
Forum posts: 9
Perhaps allow any connection to that port, but after the connection is accepted, check and see what service the connected device is running, and if it isn't our device, disconnect. Is that possible maybe?
Forum posts: 183
The first one, not sure you can detect the ServiceID of the connecting device, anyway, someome could always write a nasty client with the same service ID as yours if they really wanted too - depends on ur application, if anyone would go to the trouble...
The second one would be easier I think...
Have your phone listening ie just a small server running, when a connection is made to your server from anything, it just disconnects and then does a search for your PC. This would be easy to implement since u already have the bemused code to refer too.
Only things is you need both a client and server on both the phone and the PC, also you then need to worry about the server always running on the phone (Start the server on boot) etc.
Regards,
Isseyp