mirror of
https://github.com/markqvist/Sideband.git
synced 2025-11-29 19:56:39 -05:00
1.7 KiB
1.7 KiB
| jupyter | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Setup
%run init.ipynb
%%there
class BLE(BluetoothDispatcher):
def on_scan_started(self, success):
results.started = success
def on_scan_completed(self):
results.completed = 1
def on_device(self, device, rssi, advertisement):
results.devices.append(device)
def get_advertisemnt_count():
return len([dev for dev in results.devices if dev.getName() == "KivyBLETest"])
ble = BLE()
Run SCAN_MODE_LOW_POWER
%%there
results = Results()
ble.start_scan(
settings=ScanSettingsBuilder().setScanMode(ScanSettings.SCAN_MODE_LOW_POWER)
)
sleep(20)
%%there
ble.stop_scan()
sleep(2)
%%there
low_power_advertisement_count = get_advertisemnt_count()
print(low_power_advertisement_count > 0)
Run SCAN_MODE_LOW_LATENCY
%%there
results = Results()
ble.start_scan(
settings=ScanSettingsBuilder().setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
)
sleep(20)
%%there
ble.stop_scan()
sleep(2)
%%there
low_latency_advertisement_count = get_advertisemnt_count()
print(low_latency_advertisement_count > 0)
Check that received advertisement count is greater with SCAN_MODE_LOW_LATENCY
%%there
print(low_latency_advertisement_count - low_power_advertisement_count > 2)