0

I've hit my wits end with this one.

I have a typical BluetoothServerSocket that I'm trying to get the A&D Weight scale (UC-321PBT) to connect to. Their company has an app (myFitnessCompanion) which doesn't seem to have many connection issues, yet the scale will only connect to my app if I have the phone 'discoverable'. Mind you this is after I pair with the scale.

The only key code that is really needed here is how the listener is open, beyond that it's typical Bluetooth

serverSocket = adapter.listenUsingRfcommWithServiceRecord("PWAccessP", UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));

(I have also tried listenUsingInsecureRfcommWithServiceRecord and even reflection to open a port)

I interrogated my phones Bluetooth from another phone to list get the 'PWAccessP' value used by the myFitnessCompanion application, and even used the app to get the scale to pair with my phone.

The scale WILL enter into my socket listener when I make the phone discoverable, but other than that I see the BluetoothDevice begin making the low level connection monitoring the intent 'BluetoothDevice.ACTION_ACL_CONNECTED', but unless I have the phone in a discoverable mode it will not trigger my server socket's 'accept()' method. The pairing screen does not appear on new connections.

Any help would be appreciated. Considering I have to have the phone 'discoverable' for the connection to occur in my app vs the myFitnessCompanion allowing the connection at any time after pairing I can't see how the myFitnessCompanion is getting around this.

Thanks in advance.

d3n13d1
  • 200
  • 12
  • 1
    Figured it out ... when NOT paired the Phone needs to be discoverable for the device to find it. Once paired the device saves the port the phone was listening on and attempts to reconnect on that port. If it can find the device, but can't connect on the port then it assumes it shouldn't be connecting and will look for any 'discoverable' device to connect to and will then save the port. As a solution I cached the port once the device was bound, and used reflection to 'reopen' the listenUsingRfcommOn port. – d3n13d1 Nov 14 '12 at 22:00
  • Is there a way to pre-pair the scale with your computer? I am trying the scale too, only in my case I have a computer instead of a phone. So far nothing I did seems to work. My sw doesn't seem to detect the scale period. What BT stack do you have on your phone? Do you know if that makes a difference? – Brian Dec 18 '12 at 17:32

1 Answers1

1

A and D device work as Master and the android device as the slave. So the android device must be in discoverable mode. Me tested with both listenUsingRfcommWithServiceRecord and listenUsingInsecureRfcommWithServiceRecord method.

            try {
                tmp = mBluetoothAdapter
                        .listenUsingInsecureRfcommWithServiceRecord(NAME,
                                MY_UUID); // #2
                // tmp.accept();
                // tmp =
                // mBluetoothAdapter.listenUsingRfcommWithServiceRecord(NAME,
                // MY_UUID);
                // tmp =
                // mAdapter.getRemoteDevice("").createRfcommSocketToServiceRecord(MY_UUID);
                mServerSocket = tmp;
                mPortNumber = getPortNr();

            } catch (IOException e) {
                //Log.e("DROID", "listen() failed", e);
                flag=false;
                return flag;
            }
tkanzakic
  • 5,499
  • 16
  • 34
  • 41
Tony
  • 21
  • 4