Skip to content

Commit e0fd34d

Browse files
committed
extcap: update to support modern implementation
1 parent 56de1f8 commit e0fd34d

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

host/python/extcap/btle-extcap.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python3
22

3-
# Copyright 2013 Mike Ryan
3+
# Copyright 2013, 2023 Mike Ryan
44
#
55
# This file is part of Project Ubertooth.
66
#
@@ -21,21 +21,29 @@
2121

2222
import getopt
2323
import re
24+
import signal
2425
import sys
2526
from subprocess import Popen, PIPE
2627

28+
child = None
29+
30+
def sig_handler(sig, frame):
31+
if child is not None:
32+
child.terminate()
2733

2834
def main():
35+
signal.signal(signal.SIGTERM, sig_handler)
36+
2937
try:
3038
opts, args = getopt.getopt(
3139
sys.argv[1:], "h",
3240
[
3341
"help",
34-
"list-interfaces",
35-
"list-dlts",
36-
"config",
42+
"extcap-interfaces",
43+
"extcap-dlts",
44+
"extcap-config",
3745
"capture",
38-
"interface=",
46+
"extcap-interface=",
3947
"fifo=",
4048
"channel=",
4149
])
@@ -56,16 +64,16 @@ def main():
5664
if o in ("-h", "--help"):
5765
usage()
5866
sys.exit()
59-
elif o == "--list-interfaces":
67+
elif o == "--extcap-interfaces":
6068
list_interfaces()
6169
exit(0)
62-
elif o == "--list-dlts":
70+
elif o == "--extcap-dlts":
6371
do_list_dlts = True
64-
elif o == "--config":
72+
elif o == "--extcap-config":
6573
do_config = True
6674
elif o == "--capture":
6775
do_capture = True
68-
elif o == "--interface":
76+
elif o == "--extcap-interface":
6977
interface = a
7078
elif o == "--fifo":
7179
fifo = a
@@ -117,8 +125,7 @@ def list_interfaces():
117125

118126

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

123130

124131
def config():
@@ -138,12 +145,14 @@ def config():
138145

139146

140147
def capture(interface, fifo, channel):
148+
global child
141149
p = Popen([
142150
"ubertooth-btle", "-f",
143151
"-U%s" % interface,
144-
"-c", fifo,
152+
"-q", fifo,
145153
"-A", channel,
146154
])
155+
child = p
147156
p.wait()
148157

149158
if __name__ == "__main__":

0 commit comments

Comments
 (0)