bleObserverStart(Function)

Top  Previous  Next

Architecture:

NX32L

Firmware version:

2.20.00


 

This function makes the Bluetooth interface start listening for advertising data.

This can both be used to receive advertising data from known devices and to detect new devices.

 

Input:

scan_interval: UINT (4..16384) (default 16384)

The time interval from from one scan is started until the next is started.

The time is provided in ticks of 0.625 ms. This gives a range from 2.5ms to 10.24 s.

 

scan_window: UINT (4..16384) (default 16384)

The duration to scan for. Must be less than or equal to the scan interval.

The time is provided in ticks of 0.625 ms. This gives a range from 2.5ms to 10.24 s.

 

scan_type: USINT (0..1) (default 0)

The kind of scan to perform:

0

-

Passive scan


The device only listens for advertisements from other devices.

1

-

Active scan


The device may request further information when it receives an advertisement.

 

 

filter_policy: INT (default 0)

The policy to use to filter incoming packets:

0

-

Accept all

1

-

Ignore devices not on the accept list.

 

 

 

Returns: INT

1

-

_BLE_OK


Success

0

-

_BLE_ERR_NOT_SUPPORTED


The API is not supported.

-1

-

_BLE_ERR_NOT_OPEN


The interface is not powered(see blePower).

-8

-

_BLE_ERR_INVAL


Invalid parameter.

-13

-

_BLE_ERR_STATE


Already listening

-99

-

_BLE_ERR_GENERIC


Failed to start listening

 

 

Declaration:

FUNCTION bleObserverStart : INT;
VAR_INPUT
   scan_interval   : UINT  := 16#4000;
   scan_window     : UINT  := 16#4000;
   scan_type       : USINT := 0;
   filter_dup      : BOOL  := TRUE;
   filter_policy   : USINT := 0;
END_VAR;

 

Example:

...
   rc := bleObserverStart(
      scan_interval:=bleTimeFromMs(v:=1000), 
      scan_window := bleTimeFromMs(v:=1000), 
      scan_type:=1,
      filter_policy := 1
   );
   DebugFmt(message:="bleObserverStart: \1", v1:=rc);
...