Skip to content

Commit

Permalink
extcap: update to support modern implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeryan committed Apr 3, 2023
1 parent 56de1f8 commit e0fd34d
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions host/python/extcap/btle-extcap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3

# Copyright 2013 Mike Ryan
# Copyright 2013, 2023 Mike Ryan
#
# This file is part of Project Ubertooth.
#
Expand All @@ -21,21 +21,29 @@

import getopt
import re
import signal
import sys
from subprocess import Popen, PIPE

child = None

def sig_handler(sig, frame):
if child is not None:
child.terminate()

def main():
signal.signal(signal.SIGTERM, sig_handler)

try:
opts, args = getopt.getopt(
sys.argv[1:], "h",
[
"help",
"list-interfaces",
"list-dlts",
"config",
"extcap-interfaces",
"extcap-dlts",
"extcap-config",
"capture",
"interface=",
"extcap-interface=",
"fifo=",
"channel=",
])
Expand All @@ -56,16 +64,16 @@ def main():
if o in ("-h", "--help"):
usage()
sys.exit()
elif o == "--list-interfaces":
elif o == "--extcap-interfaces":
list_interfaces()
exit(0)
elif o == "--list-dlts":
elif o == "--extcap-dlts":
do_list_dlts = True
elif o == "--config":
elif o == "--extcap-config":
do_config = True
elif o == "--capture":
do_capture = True
elif o == "--interface":
elif o == "--extcap-interface":
interface = a
elif o == "--fifo":
fifo = a
Expand Down Expand Up @@ -117,8 +125,7 @@ def list_interfaces():


def list_dlts():
# -c emits DLT_PPI + DLT_BLUETOOTH_LE_LL
print("dlt {number=192}{name=PPI}{display=Bluetooth Low Energy}")
print("dlt {number=256}{name=DLT_BLUETOOTH_LE_LL_WITH_PHDR}{display=Bluetooth LE}\n");


def config():
Expand All @@ -138,12 +145,14 @@ def config():


def capture(interface, fifo, channel):
global child
p = Popen([
"ubertooth-btle", "-f",
"-U%s" % interface,
"-c", fifo,
"-q", fifo,
"-A", channel,
])
child = p
p.wait()

if __name__ == "__main__":
Expand Down

0 comments on commit e0fd34d

Please sign in to comment.