I'm using the wclClient can connecting to a device that has it's pin in it's friendly name. I'm pairing as follows. Device.Address := address;
wclClient.Transport := ctBluetooth;
wclClient.BluetoothParams.Address := address;
wclClient.BluetoothParams.Radio := Radio;
wclClient.BluetoothParams.Service := SerialPortServiceClass_UUID;
Cnt := 0;
Res := WCL_E_SUCCESS;
while Cnt < 3 do begin
Res := Device.GetName(Radio, aName);
if (aName <> '') or (Res <> WCL_E_SUCCESS) then Break;
Inc(Cnt);
end;
if Res <> WCL_E_SUCCESS then
raise Exception.Create('Unable to get device name.');
pin := GetPinFromName( aName );
if ( device.GetPaired( radio, isPaired ) <> WCL_E_SUCCESS ) then
raise Exception.Create('Unabled to communicate with device');
if ( (isPaired = false) and (Device.Pair( radio, pin ) <> WCL_E_SUCCESS) ) then
raise Exception.Create('Unable to pair device.');
if (wclClient.Connect <> WCL_E_SUCCESS ) then
raise Exception.Create('Error. Connect failed.');
This seems to work 90% of the time. The onther 10% i get the pairing window prompting me for the pin. Do i need to delay before calling the connect?