Android: Access to an already paired connection
I have a question on accessing alread开发者_JS百科y 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 :)
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.
精彩评论