ble.start_scanning(scan_time) try: # initialize BLE driver bledrv.init() # Set GAP name and no security ble.gap("Zerynth",security=(ble.SECURITY_MODE_1,ble.SECURITY_LEVEL_1)) ble.add_callback(ble.EVT_SCAN_REPORT,scan_report_cb) ble.add_callback(ble.EVT_SCAN_STARTED,scan_start_cb) ble.add_callback(ble.EVT_SCAN_STOPPED,scan_stop_cb) #set scanning parameters: every 100ms for 50ms and no duplicates ble.scanning(100,50,duplicates=0) # Start the BLE stack ble.start() # Now start scanning for 30 seconds ble.start_scanning(scan_time) except Exception as e: print(e) # loop forever while True: print(".") sleep(10000)
def scan_stop_cb(data): print("Scan stopped") #let's start it up again ble.start_scanning(scan_time)
#let's start it up again ble.start_scanning(3000) try: # initialize BLE driver bledrv.init() # Set GAP name and no security ble.gap("Zerynth", security=(ble.SECURITY_MODE_1, ble.SECURITY_LEVEL_1)) ble.add_callback(ble.EVT_SCAN_REPORT, scan_report_cb) ble.add_callback(ble.EVT_SCAN_STOPPED, scan_stop_cb) #set scanning parameters: every 100ms for 100ms and no duplicates ble.scanning(100, 100, duplicates=0) # Start the BLE stack ble.start() # Now start scanning for 3 seconds ble.start_scanning(3000) except Exception as e: print(e) # loop forever while True: print(".") sleep(10000)