Skip to content

Commit 42b7d3d

Browse files
authored
Merge pull request #20 from PzmuV1517/search-and-freeze-search
added per graph SSID and MAC address filtering as well as per graph freeze search
2 parents 9820e1b + d427b93 commit 42b7d3d

2 files changed

Lines changed: 370 additions & 25 deletions

File tree

tiny_wifi_analyzer/__main__.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
update_queue = queue.Queue()
3131
is_closing = False
3232
scanner_thread = None
33+
scanner_pause_event = threading.Event()
3334
debug_scan_count = 0
3435

3536
webview.settings["ALLOW_DOWNLOADS"] = True
@@ -122,6 +123,9 @@ def get_supported_bands():
122123
def start_scanner(interval_ms: int) -> threading.Thread:
123124
def loop():
124125
while not is_closing:
126+
if scanner_pause_event.is_set():
127+
sleep(0.1)
128+
continue
125129
try:
126130
name, nws = scan()
127131
update_queue.put((name, nws))
@@ -149,6 +153,8 @@ def to_series(nws):
149153
def update(window, supported_bands):
150154
if is_closing:
151155
return
156+
if scanner_pause_event.is_set():
157+
return
152158

153159
try:
154160
# If there are multiple queued updates, take the most recent snapshot
@@ -248,6 +254,19 @@ def show_dialog(self):
248254
AppKit.NSApplication.sharedApplication().terminate_(None)
249255

250256

257+
class Api:
258+
def pause_scan(self):
259+
scanner_pause_event.set()
260+
return {"paused": True}
261+
262+
def resume_scan(self):
263+
scanner_pause_event.clear()
264+
return {"paused": False}
265+
266+
def get_scan_state(self):
267+
return {"paused": scanner_pause_event.is_set()}
268+
269+
251270
def request_location_permission():
252271
location_manager = CoreLocation.CLLocationManager.alloc().init().retain()
253272
delegate = LocationManagerDelegate.alloc().init().retain()
@@ -276,7 +295,7 @@ def main():
276295
AppKit.NSApplication.sharedApplication().activateIgnoringOtherApps_(True)
277296

278297
index_html = os.path.join(os.path.dirname(__file__), "view/index.html")
279-
window = webview.create_window("Tiny Wi-Fi Analyzer", index_html)
298+
window = webview.create_window("Tiny Wi-Fi Analyzer", index_html, js_api=Api())
280299
window.events.closing += on_closing
281300
window.events.loaded += setup_client
282301
webview.start(startup, window, debug=True)

0 commit comments

Comments
 (0)