1# pip install blatann
2from blatann import BleDevice
3from blatann.examples import example_utils
4import time
5from blatann.nrf.nrf_types.gatt import BLEGattCharacteristic
6from pc_ble_driver_py.ble_driver import BLEGattExecWriteFlag, BLEGattWriteOperation, BLEGattcWriteParams
7
8logger = example_utils.setup_logger(level="INFO")
9
10def main(serial_port):
11 # Create and open the device
12 address = ""
13 ble_device = BleDevice(serial_port)
14 ble_device.open()
15 ble_device.scanner.set_default_scan_params(timeout_seconds=4)
16
17 # Start scanning and iterate through the reports as they're received
18 for report in ble_device.scanner.start_scan().scan_reports:
19 if not report.duplicate:
20 stringreport = str(report)
21 logger.info(report)
22 print(str(report.peer_address))
23 print(str(report.device_name))
24
25if __name__ == '__main__':
26 main("COM11")