btleNotifyStart (Function)

Top  Previous  Next

Architecture:

NX32L

Device support:

NX-200, NX-400, NX-900

Firmware version:

1.10.00

 


 

This function will make the adapter start listening for notifications for a characteristic.

When a notification occurs, the event _BT_EVENT_NOTIFY is triggered and the data can be read using btleHandleNotification.

 

 

Input:

dev : STRING

The address of the device.

 

service : INT

The service the characteristic belongs to.

 

char : INT

The characteristic to receive notifications from.

 

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


The device or characteristic could not be found.

-8

-

_BT_ERR_INVAL


This device does not have any characteristics.

-12

-

_BT_ERR_BUSY


The notification is already enabled.

-16

-

_BT_ERR_NOT_PERM


The characteristic does not support notifications.

-19

-

_BT_ERR_NOT_CONNECTED


The device is not connected.

 

 

Declaration:

FUNCTION btleNotifyStart : INT;
VAR_INPUT
  dev      : STRING;
  service  : INT;
  char     : INT;
END_VAR;

 

Example:

INCLUDE rtcu.inc
 
PROGRAM test;
VAR
  rc      : INT;
  address : STRING;
END_VAR;
 
// Turn on the Bluetooth library
btPower();
 
BEGIN
  ...
  // Start listening for notifications from BLE device <address>.
  rc := btleNotifyStart(dev := address, service := 16#18, char := 16#19);
  DebugFmt(message:="btleNotifyStart "+address+": \1", v1:=rc);
  ...
END;
 
END_PROGRAM;