views:

204

answers:

1

Hi community, I have a question on accessing already existing paired bluetooth connections...

How can a remote service detect an already paired connection and await a file transfer from it?

In all comments on stackoverflow, on tutorials, ebooks or on google there is always shown how to create a new connection using sockets and so on, but no word about accessing to an existing one.

Is it possible at all? If yes, can you also tell/show me how? At the moment I have no clue how to get started with it.

Would be great if someone can help me get started :)

+2  A: 

Pairing just means that the two devices have authenticated eachother. It does not imply an open socket connection.

After pairing, comes connecting: One side creates a server socket and the other device can then connect to it with a client socket.

I think the confusion is coming from the blending of two concepts: "already paired" with "already connected". Pairing just means they are authenticated. The devices cannot connect without first pairing, but pairing does not connect the devices.

To make an app wait for a file transfer it would go something like this:

  • Make device A pairable.
  • From device B, search for nearby devices and when you find A, pair with it (this is where you enter a secret PIN code that has to match on the two devices)
  • Now that the devices are paired, start your file server on device A or B (It then creates a server socket and awaits incoming connections)
  • Then initiate a connection to the file server from the other device.
  • With the sockets open, data can then flow.
Brad Hein
hi, thanks for your answer. I did several tests regarding to my issue:My file is pushed via "Object Push Profile"...in my tests there is no "Connection" needed to initiate a file transfer...even pairing isn't needed. But the problem is now, that there is just a few file types supported (such as gif, jpg,...), but not the one I need (gpx). How can I change that?My issue is to open an app when this specific filetype arrives on my phone...is this possible here?
poeschlorn
Sure, you can just create a service which opens a listening socket (you have to have a socket) and awaits an incoming connection. Upon receiving a connection, it gets the data and then fires off an intent to launch an app or activity or whatever you want.
Brad Hein
ok, I'm gonna try this out
poeschlorn