How to use the able.Advertisement.ad_types.manufacturer_specific_data function in able

To help you get started, we’ve selected a few able examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slinger360 / NineRiFt-Lite / py9b / link / bleandroid.py View on Github external
def setaddr(self, a):
		global address
		address = a

	def discover(self):
		self.start_scan()
        self.state = 'scan'

	def on_device(self, device, rssi, advertisement):
		if self.state != 'scan':
			return
		Logger.debug("on_device event {}".format(list(advertisement)))
        scoot_found = False
        name = ''
        for ad in advertisement:
            if ad.ad_type == Advertisement.ad_types.manufacturer_specific_data:
                if ad.data.startswith(self.identity):
                    scoot_found = True
                else:
                    break
            elif ad.ad_type == Advertisement.ad_types.complete_local_name:
                name = str(ad.data)
        if scoot_found:
            self.state = 'found'
            self.ble_device = device
            Logger.debug("Ninebot detected: {}".format(name))
            self.stop_scan()

	def write(self, barray):
		self.write_characteristic(self.receive_characteristic, barray) #writes packets to receive characteristic

	def on_characteristic_changed(self, transmit_characteristic):
github slinger360 / NineRiFt-Lite / py9b / link / droidble.py View on Github external
def on_device(self, device, rssi, advertisement):
        global scoot_found
        if self.state != 'scan':
            return
        Logger.debug("on_device event {}".format(list(advertisement)))
        self.addr = device.getAddress()
        if self.addr and address.startswith(self.addr):
            print(self.addr)
            self.ble_device = device
            self.scoot_found = True
            self.stop_scan()
        else:
            for ad in advertisement:
                print(ad)
                if ad.ad_type == Advertisement.ad_types.manufacturer_specific_data:
                    if ad.data.startswith(self.identity):
                        scoot_found = True
                    else:
                        break
                elif ad.ad_type == Advertisement.ad_types.complete_local_name:
                    name = str(ad.data)
        if scoot_found:
            self.state = 'found'
            print(self.state)
            self.ble_device = device
            Logger.debug("Scooter detected: {}".format(name))
            self.stop_scan()