Python bluepy.btle.DefaultDelegate() Examples

The following are 12 code examples of bluepy.btle.DefaultDelegate(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module bluepy.btle , or try the search function .
Example #1
Source File: read_waveplus.py    From waveplus-reader with MIT License 7 votes vote down vote up
def connect(self):
        # Auto-discover device on first connection
        if (self.MacAddr is None):
            scanner     = Scanner().withDelegate(DefaultDelegate())
            searchCount = 0
            while self.MacAddr is None and searchCount < 50:
                devices      = scanner.scan(0.1) # 0.1 seconds scan period
                searchCount += 1
                for dev in devices:
                    ManuData = dev.getValueText(255)
                    SN = parseSerialNumber(ManuData)
                    if (SN == self.SN):
                        self.MacAddr = dev.addr # exits the while loop on next conditional check
                        break # exit for loop
            
            if (self.MacAddr is None):
                print "ERROR: Could not find device."
                print "GUIDE: (1) Please verify the serial number."
                print "       (2) Ensure that the device is advertising."
                print "       (3) Retry connection."
                sys.exit(1)
        
        # Connect to device
        if (self.periph is None):
            self.periph = Peripheral(self.MacAddr)
        if (self.curr_val_char is None):
            self.curr_val_char = self.periph.getCharacteristics(uuid=self.uuid)[0] 
Example #2
Source File: cbluepy.py    From pylgbst with MIT License 5 votes vote down vote up
def __init__(self, handler):
        btle.DefaultDelegate.__init__(self)

        self._handler = handler 
Example #3
Source File: __init__.py    From python-awox-mesh-light with MIT License 5 votes vote down vote up
def __init__(self, light):
        self.light = light
        btle.DefaultDelegate.__init__(self) 
Example #4
Source File: bluetoothScanner.py    From sensorReporter with Apache License 2.0 5 votes vote down vote up
def getTag(self):
        """Scans for BT LE devices and returns the choosen keywords"""
        self.count = 0
        scanner = Scanner().withDelegate(DefaultDelegate())
        devices = scanner.scan(self.scanTimeout)
        for dev in devices:
            if dev.addr == self.address.lower():
                self.count = 1
			
        if self.count > 0:
            self.count = 0
            return self.found
        else:
            return self.missing 
Example #5
Source File: ble.py    From HomePWN with GNU General Public License v3.0 5 votes vote down vote up
def scan_devices(self, delegate=DefaultDelegate, timeout=5):
        devices = Scanner(self.iface).withDelegate(delegate()).scan(timeout=timeout) 
        return self._package_data_devices(devices) 
Example #6
Source File: _P512_BLEMijia.py    From rpieasy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,callback):
   self.callback = callback
   btle.DefaultDelegate.__init__(self) 
Example #7
Source File: _P510_ITag.py    From rpieasy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,keypressed_callback,KPHANDLE):
        self.keypressed_callback = keypressed_callback
        self.keypressed_handle = KPHANDLE
        btle.DefaultDelegate.__init__(self) 
Example #8
Source File: _P518_BLECGG1.py    From rpieasy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,callback):
   self.callback = callback
   btle.DefaultDelegate.__init__(self) 
Example #9
Source File: _P517_BLELYWSD03.py    From rpieasy with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self,callback):
   self.callback = callback
   btle.DefaultDelegate.__init__(self) 
Example #10
Source File: connection.py    From python-eq3bt with MIT License 5 votes vote down vote up
def __init__(self, mac):
        """Initialize the connection."""
        btle.DefaultDelegate.__init__(self)

        self._conn = None
        self._mac = mac
        self._callbacks = {} 
Example #11
Source File: open_myo.py    From Open-Myo with GNU General Public License v3.0 5 votes vote down vote up
def __init__(self, mac=None):
        btle.DefaultDelegate.__init__(self)
        self.services = Services(mac=get_myo(mac))
        self.services.setDelegate(self)

        self.emg_event_handlers = []
        self.imu_event_handlers = []
        self.sync_event_handlers = []
        self.classifier_event_handlers = []
        self.battery_event_handlers = [] 
Example #12
Source File: commBLE.py    From blue-loader-python with Apache License 2.0 5 votes vote down vote up
def __init__(self, dongle):
		btle.DefaultDelegate.__init__(self)
		self.dongle = dongle