digi.xbee.ble module

class digi.xbee.ble.BLEManager(xbee)[source]

Bases: object

Helper class used to manage the BLE Interface on the XBee.

NOTE: For more information about Shortened and Local Names when running a GAP scan, see: <https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Assigned_Numbers/out/en/Assigned_Numbers.pdf?v=1707939725200

Class constructor. Instantiates a new BLEManager with the given parameters.

Parameters:

xbee (AbstractXBeeDevice) – XBee to manage its BLE interface.

GAP_SCAN_DURATION_INDEFINITELY = 0

Value to have the GAP scan run indefinitely

open()[source]

Opens the communication with the BLE Manager.

This method guarantees that all callbacks are started.

close()[source]

Closes the communication with the BLE Manager.

This method guarantees that all callbacks are stopped/deleted.

property xbee

Returns the XBee of this BLE manager.

Returns:

XBee to manage its BLE interface.

Return type:

AbstractXBeeDevice

start_ble_gap_scan(duration, window, interval, enable_filter, custom_filter)[source]

Starts a Bluetooth BLE GAP Scan request

Parameters:
  • duration (Integer) – Scan Duration The Scan Duration parameter defines how long the scan should run. Scan duration should be between 0 - 65535 (x 1s) (18.20 hr.) If the scan is set to 0 the scan will run indefinitely.

  • window (Integer) – Scan Window The Scan Window parameter defines how long to scan at each interval. The range is from 2500 – 40959375 (x 1 us) (41 seconds) The window cannot be bigger than the scan interval.

  • interval (Integer) – Scan Interval The Scan Interval parameter is the duration of time between two consecutive times that the scanner wakes up to receive the advertising messages. The range is from 2500 – 40959375 (x 1 us) (41 seconds) The Interval cannot be smaller than the scan window

  • enable_filter (Bool) – Filter Type Supported Filter Types: False = Filter Disabled True = Filter advertisements containing the Shortened or Complete Local Name.

  • custom_filter (bytes) – Filter (optional) When the ‘enable_filter’ option is enabled, the scan will filter the results returned by matching the filter against the Shortened or Complete Local Name. Only items that match will be returned. The range for the Filter is from 0-22 bytes In other words, it can only accept up to 22 characters.

Returns:

Received response packet.

Return type:

XBeePacket

Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.

  • TimeoutException – If response is not received in the configured timeout.

  • XBeeException – If the XBee’s communication interface is closed.

stop_ble_gap_scan()[source]

Stops a Bluetooth BLE GAP Scan request

Returns:

Received response packet.

Return type:

XBeePacket

Raises:
  • InvalidOperatingModeException – If the XBee’s operating mode is not API or ESCAPED API. This method only checks the cached value of the operating mode.

  • TimeoutException – If response is not received in the configured timeout.

  • XBeeException – If the XBee’s communication interface is closed.

add_ble_gap_advertisement_received_callback(callback)[source]

Adds a callback for the event BLEGAPScanReceived.

Parameters:

callback (Function) –

The callback. Receives one argument.

del_ble_gap_advertisement_received_callback(callback)[source]

Deletes a callback for the callback list of BLEGAPScanReceived event.

Parameters:

callback (Function) – The callback to delete.

is_scan_running()[source]

Returns whether a Bluetooth BLE GAP scan is currently running

Returns:

True if scan is running, False otherwise.

Return type:

Boolean