python.test

Module Contents

class python.test.SimpleBleDevice(client, addr=None, addrType=0, iface=0, data=None, rssi=0, connectable=False, updateCount=0)

This is a conceptual class representation of a simple BLE device (GATT Server). It is essentially an extended combination of the bluepy.btle.Peripheral and bluepy.btle.ScanEntry classes

Parameters:
  • client (class:simpleble.SimpleBleClient) – A handle to the simpleble.SimpleBleClient client object that detected the device
  • addr (str, optional) – Device MAC address, defaults to None
  • addrType (str, optional) – Device address type - one of ADDR_TYPE_PUBLIC or ADDR_TYPE_RANDOM, defaults to ADDR_TYPE_PUBLIC
  • iface (int, optional) – Bluetooth interface number (0 = /dev/hci0) used for the connection, defaults to 0
  • data (list, optional) – A list of tuples (adtype, description, value) containing the AD type code, human-readable description and value for all available advertising data items, defaults to None
  • rssi (int, optional) – Received Signal Strength Indication for the last received broadcast from the device. This is an integer value measured in dB, where 0 dB is the maximum (theoretical) signal strength, and more negative numbers indicate a weaker signal, defaults to 0
  • connectable (bool, optional) – True if the device supports connections, and False otherwise (typically used for advertising ‘beacons’)., defaults to False
  • updateCount (int, optional) – Integer count of the number of advertising packets received from the device so far, defaults to 0
getServices(self, uuids=None)

Returns a list of bluepy.blte.Service objects representing the services offered by the device. This will perform Bluetooth service discovery if this has not already been done; otherwise it will return a cached list of services immediately..

Parameters:uuids (list, optional) – A list of string service UUIDs to be discovered, defaults to None
Returns:A list of the discovered bluepy.blte.Service objects, which match the provided uuids
Return type:list On Python 3.x, this returns a dictionary view object, not a list
setNotificationCallback(self, callback)

Set :param callback: A function handle of the form callback(client, characteristic, data), where client is a handle to the simpleble.SimpleBleClient that invoked the callback, characteristic is the notified bluepy.blte.Characteristic object and data is a bytearray containing the updated value. Defaults to None :type callback: function, optional

getCharacteristics(self, startHnd=1, endHnd=65535, uuids=None)

Ret :param startHnd: Start index, defaults to 1 :type startHnd: int, optional :param endHnd: End index, defaults to 0xFFFF :type endHnd: int, optional :param uuids: a list of UUID strings, defaults to None :type uuids: list, optional :return: List of returned bluepy.btle.Characteristic objects :rtype: list

connect(self)

Att :return: True if connection was successful, False otherwise :rtype: bool

disconnect(self)

Dro

isConnected(self)

Che :return: True if connected, False otherwise :rtype: bool

printInfo(self)

Print