Commit 4a44c8d8 authored by ernesst's avatar ernesst
Browse files

Update the Readme and add command to shutdown Test_gps once position is capture.

parent bf20b34d
#!/usr/bin/env python3
#Copyright (C) 2019 Ernesst <ernesst@posteo.net>
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; version 3.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.
import time
import subprocess
import re
......@@ -9,11 +23,9 @@ import sys
import json
import requests
import os
#from subprocess import Popen, PIPE, STDOUT
i = 0
# Version 0.1
import multiprocessing
i = 0
def read_gps():
global latitude
......@@ -27,7 +39,6 @@ def read_gps():
stderr = subprocess.STDOUT, shell = True)
for line in p.stdout:
line = line.decode('utf-8')
#print(line)
if re.search("^latitude", line):
latitude = line.split()
latitude = latitude[1]
......@@ -43,6 +54,7 @@ def read_gps():
#print(line + "=> accuracy : " + accuracy)
#print(line + "=> longitude : " + longitude)
#print(line + "=> latitude : " + latitude)
p.kill()
return accuracy,longitude,latitude
def read_wifi(lat, lon, acc):
......@@ -110,18 +122,38 @@ def read_wifi(lat, lon, acc):
except:
data["items"].append(json_item)
#print(data)
with open('data.txt', 'w+') as outfile:
json.dump(data, outfile)
try:
print("\n***************************")
print("** UTouch-MLS tool **")
print("***************************")
print("\nWelcome to the UTouch-MLS tool to enhance the Mozilla Location Service database for your own convience.")
print("The scan will start automatically, scan result will be recorder in the data.txt file next to this file.")
print("To close the application simply select Ctrl+c virtual key, the data will be automatically uploaded to https://location.services.mozilla.com")
print("Be sure your phone is connected to internet for the upload.")
print("Enjoy !")
print("\n")
while True:
print("Scan No : " + str(i))
# p = multiprocessing.Process(target=read_gps)
# p.start()
# Wait for 10 seconds or until process finishes
# p.join(40)
# If thread is still active
# if p.is_alive():
# print("Process is hanging, let's restart it...")
# Terminate
# p.terminate()
# p.join()
read_gps()
print("Scan No : " + str(i))
print("lat : " + latitude + " lon : " + longitude)
read_wifi(latitude,longitude,accuracy)
time.sleep(4)
time.sleep(3)
i = i + 1
except KeyboardInterrupt:
......@@ -133,19 +165,16 @@ except KeyboardInterrupt:
try:
response = requests.post(url, data=json.dumps(payload), headers=headers)
if response.status_code == 200:
print("***************************")
print("Data uploaded successfully")
print("\n***************************")
print("Data uploaded successfully.")
print("***************************")
os.remove("data.txt")
else:
print("Sorry an issue happen during the upload, the collect is not lost see data.txt")
print("\nSorry an issue happen during the upload, the collect is not lost see data.txt.")
time.sleep(2)
print("\n***************************")
print("\nThanks for the contribution")
print("Thanks for the contribution. \n")
except:
print("\nSorry an issue happen during the upload, the collect is not lost see data.txt")
print("\n !!!Sorry an issue happen during the upload, the collect is not lost see data.txt")
sys.exit()
#dbus-send --system --print-reply=literal --type=method_call --dest=org.ofono /ril_0 org.ofono.NetworkRegistration.GetProperties
# MLS-for-Utouch
UTouch-MLS is a python tool which need to be run from an ubuntu touch terminal, if the terminal is set to run in background UTouch-MLs should run in background too.
This tool is able to scan wifi around your device and capture the GPS location to populate the Mozilla Location Service database.
The python tool is a wrapper using :
- for the GPS : test_gps Location
- for the Wifi scan : sudo iwlist wlan0 scanning
- Upload data address : https://location.services.mozilla.com
Note :
So far this tool has been only test on a Nexus 5 - Hammerhead device.
bug report are welcome, any integration as a qml app too.
Ernesst.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment