Beispiel #1
0
 def did_discover_services(self, p, error):
     for s in p.services:
         if s.uuid == UART_SERVICE_UUID:
             self.event = {
                 'src': self.src_name,
                 'ok': True,
                 'status': 'STATUS_DISCOVERED_SERVICES',
                 'resp': {
                     'peripheral': p.name,
                     'service': 'UART_SERVICE'
                 }
             }
             self.event_queue.append(self.event)
             p.discover_characteristics(s)
             cb.stop_scan()
Beispiel #2
0
def discover_BLE_characteristics(lodBLE):
	""" discover bluetooth le peripherals and their chracteristics
		expects lodBLE : a list of dictionaries defining what to be searched
		returns bleDelegate object
	"""
	cb.set_verbose(True)
	cb.reset()
	Delg = bleDelegate(lodBLE)
	cb.set_central_delegate(Delg)
	cb.scan_for_peripherals()
	logger.info('Waiting for callbacks state=%s' % (cb.get_state()))
	while not Delg.allFound():
		time.sleep(1)
	logger.info('found %d characteristics' % len(Delg.charFound))
	cb.stop_scan()
	return Delg
Beispiel #3
0
		print "Services:"
		for s in p.services:
			print "-" + str(s.uuid)
		p.discover_characteristics(s)
		
	
	def did_discover_characteristics(self, s, error):
		print "Characteristics:"
		for c in s.characteristics:
			print "-" + str(c.uuid)
	
	def did_write_value(self, c, error):
		time.sleep(0.5)
	
	def did_update_value(self, c, error):
		time.sleep(0.5)

delegate = codeBlue()
for i in range(4):
	sys.stdout.write("\rScanning For Devices" + "." * i)
	time.sleep(1)
cb.set_central_delegate(delegate)
cb.scan_for_peripherals()

try:
	while True: pass
except KeyboardInterrupt:
	cb.reset()
	cb.stop_scan()
	sys.exit()