btSerialPortProfileEnable (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, NX-400, NX-900

Firmware version:

1.10.00

 


 

This function enables or disables a Serial Port Profile(SPP) service on the local device.

When remote devices then connects to the port, the _BT_EVENT_INCOMING event is triggered.

 

Input:

ch : SINT

The channel to listen on. A typical value for SPP is 22.

 

UUID : STRING

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

 

enable : BOOL

Set to TRUE to enable the profile, set to FALSE to disable it.

 

max_con : SINT

The maximum number of simultaneous connections from different devices to the same profile. Use 0 to allow all connections, 1 to only allow a single connection.

 

 

Returns: INT

1

-

_BT_OK


Success.

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 profile resources available.

-8

-

_BT_ERR_INVAL


Invalid value for max_con.

 

 

 

Declaration:

FUNCTION btSerialPortProfileEnable : INT;
VAR_INPUT
  ch        : SINT;
  UUID      : STRING := "";
  enable    : BOOL := TRUE;
  max_con   : SINT := 0;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc      : INT;
END_VAR;
 
// Turn on the Bluetooth library
btPower();
 
// Enable SPP on channel 22
rc := btSerialPortProfileEnable(ch := 22, max_con := 1);
DebugFmt(message:="btSerialPortProfileEnable: \1 ", v1:=rc);
...
 
BEGIN
  ...
END;
 
END_PROGRAM;