Author Topic: Pairing Devices  (Read 1322 times)

Offline Friz

  • Newbie
  • *
  • Posts: 14
  • Karma: 0
Pairing Devices
« on: December 19, 2006, 04:52:56 PM »
Hi Mike!

As you know i'm building a software for mass sending. One question: How can i know wich devices need to be paired before sending a file, and wich devices don't need pairing? One example to let you understand in a better way what i mean and what happens with my software:

I have 2 devices: one Motorola V3 and one QTek 9000 (Windows Mobile 5). Both devices have the service "OBEX Push Object" open, so i have to send a file to both device.
The problem is that, in Windows Mobile 5, in Bluetooth menu of the PDA, i can make visible the device, but you can also set a flag "Compulsory (obligatory) Passkey"). Setting this flag makes trouble with the software.

If i try to send the file, without BFAuthenticator, Motorola V3 get the file without problems. A message is shown on the screen of the Motorola, like: "Accept a file from Computer1?", i accept, and everything it's ok. But if i try to send the file to QTEK 9000 (Windows Mobile 5), the PDA say: "'Computer1' is trying to connect... Woud you add 'Computer1' to paired devices?". If i say yes, the PDA ask me for a PIN (passkey). I write a PIN in the PDA, but the software crashes (and in the PDA nothing happens).

If i try to send the file, using BFAuthenticator, i add these 2 lines of code on the Form.Create:

        ObexClient.BluetoothTransport.Authentication := true;
        Authoring.Open;

with this code, QTek 9000 (Windows Mobile 5) works fine. The device become paired, and the file is sent to the PDA.
But in the same situation, Motorola V3 when i try to send the file, begins the pairing process, wich is long and not "user friendly" in this Phone.

The solution seems to be: using BFAuthenticar with QTek 9000, and not using BFAuthenticator with Motorola. But how can i know wich device need to be paired and wich not?!
There is a way to know this information before opening connection?

Thank you a lot, i hope everything i wrote is clear. Sorry for my english.

Davide

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2491
  • Karma: 1000
    • Wireless Communication Library
Re: Pairing Devices
« Reply #1 on: December 19, 2006, 05:34:16 PM »
Good time of the day!

Well. There is no clean method to detect when device need authentication and when no. But.
I use the following algorithm:
1. Try connect without authentication (BluetoothTransport.Authentication = False);
2. catch error (try/except, on Error. catch/except).
3. If error message containt error code 10013 or 10051 then device require authentication and I set Authentication to True and trying reconnect to device.
4. If error containt code 10110 then device does not has this service end I try useing other (FileTransfer estead ObjectPush).
5. If error containt code 10064 then user reject connection.

P.S. Strongly recomened to use Microsoft Bluetooth stack to such applications type.
P.P.S. For other stacks error codes will be others.
WCL - Wireless Communication Library
TextBlue - Bluetooth Proximity Marketing Software
WCL Phone Explorer - Free Phone Content Manager