schollz / find-lf

Track the location of every Wi-Fi device (:iphone:) in your house using Raspberry Pis and FIND
https://www.internalpositioning.com/plugins/#using-find-without-an-app
GNU Affero General Public License v3.0
994 stars 123 forks source link

Continual tshark scanning #7

Closed schollz closed 7 years ago

schollz commented 7 years ago

There is really no reason (except for single-wifi computers) for the tshark scanning to stop. I would like to implement a thread for the tshark scanning and then have the output parsed directly from the log file.

Command for scanning, something like:

sudo /usr/bin/tshark -I -i wlan1 -b files:2 -b filesize:10000 -w /tmp/temp

Then, to read:

sudo tshark -r /tmp/tempXXXX -T fields -e frame.time_epoch -e wlan.sa -e wlan.bssid -e radiotap.dbm_antsignal

The two files are to ensure that the data will rollover and not get overwritten. Both files can be read by the python script and determined accordingly.

In Python3, this can be implemented:

# Run tshark in the background
ls_output=subprocess.Popen("/usr/bin/tshark -I -i wlan1 -b files:2 -b filesize:10000 -w /tmp/temp".split(), stdout=subprocess.PIPE,stderr=subprocess.PIPE)

# Check if its running
ls_output1=subprocess.Popen("ps aux".split(), stdout=subprocess.PIPE,stderr=subprocess.PIPE)
output = ls_output1.stdout.read()
isRunning = "tshark" in output and "[tshark] <defunct>" not in output
schollz commented 7 years ago

Implemented here: https://github.com/schollz/find-lf/commit/015707c4430e9e0baba2ef271f05fb30f03a030b