2

In java (but not android) I need to connect to a 'hidden' bluetooth device. I'm using bluecove. I know the devices MAC address already.

In principle I can do this with:

StreamConnection conn = (StreamConnection) Connector.open("btspp://<mac>:1;authenticate=true;encrypt=tue;master=false;"

however the problem is that I need to use an authenticated connection (with a PIN).

Searching the web, I found this: Detect hidden bluetooth device with known ID

which allows me to create a RemoteDevice and then pass in a PIN to authenticate it, but I cannot find out how to use that RemoteDevice to then open a connection?

Answers like this: How to create a (javax.bluetooth.)RemoteDevice / connect with mac-address

suggest it can be done.

EDIT

To clarify, I believe that I can do the pairing and authentication with:

RemoteDevice rd = new RemoteDevice("<mac>");
RemoteDeviceHelper.authenticate(rd, "<pin>");

But then how do I use that "rd" object to open a (serial) connection to my bluetooth device?

Community
  • 1
  • 1
bevis
  • 129
  • 1
  • 13
  • I would say that if a PIN code is needed, that's because the connexion requires to be secured following the pairing protocol (a paired device is a trusted device). Regarding the remote hidden device in question, I do not know if it requires to be paired. However, from what you provided, your **connexion URL** does stipulate : **authenticate=true** which means the connexion must be on two paired devices, hence the required PIN code which means **they are not paired**. Futhermore, there is a typo in your URL **encrypt=tue** is missing a **r** in **tue** -> encrypt=t**r**ue – Mackovich Jan 30 '16 at 08:39
  • I've edited the question to clarify the problem a bit – bevis Feb 01 '16 at 08:52
  • For reference for others who may follow, I was unable to find out how to do solve my problem, and instead compiled the bluez "agent.c" test code and used that for authentication outside of java (no python installed so I couldn't use simple-agent). – bevis Feb 16 '16 at 13:26

0 Answers0