btSerialPortProfileConnect (Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

1.10.00

 


 

This function tries to connect to a Serial Port Profile(SPP) on a remote device.

 

Input:

dev : STRING

The address of the device to connect to.

 

UUID : STRING

The UUID of the profile to connect to. If empty, the default SPP profile will be used.

 

Output:

port : SINT

The port number to use with serOpen.

 

 

Returns: INT

1

-

_BT_OK


The connection to the port has been established.

0

-

_BT_ERR_NOT_SUPPORTED


The API is not supported.

-1

-

_BT_ERR_NOT_OPEN


The adapter is not powered(see btPower).

-4

-

_BT_ERR_NOT_FOUND


Could not find device.

-7

-

_BT_ERR_NO_RES


No serial port resources available.

-12

-

_BT_ERR_BUSY


The adapter is busy.

-14

-

_BT_ERR_CON_FAILED


Failed to connect to device.

-15

-

_BT_ERR_NOT_AVAIL


The profile is not currently available.

-17

-

_BT_ERR_TIMEOUT


Timeout

 

 

 

Declaration:

FUNCTION btSerialPortProfileConnect : INT;
VAR_INPUT
   dev      : STRING;
   UUID     : STRING := "";
   port     : ACCESS SINT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
   rc      : INT;
   port    : SINT;
   address : STRING;
END_VAR;
 
// Turn on the Bluetooth library
btPower();
 
BEGIN
   ...
   // Connect to SPP on <address>. The port number is stored in <port>
   rc := btSerialPortProfileConnect(dev:=addressport:=port);
   DebugFmt(message:="btSerialPortProfileConnect "+address+": \1 , port: \2", v1:=rcv2 := port);
   ...
END;
 
END_PROGRAM;