def readGps(): args =["gps", "info"] response = ubus.call(args) # check if the GPS is locked if "signal" in response and response["signal"] == False: return False # else return the data return response
def scanWifi(): device = json.dumps({"device": "ra0"}) args = ["onion", "wifi-scan", device] # perform wifi scan networks = ubus.call(args)["results"] # format the data to hold only what's needed by the API formattedNetworks = {} formattedNetworks["results"] = [] new_json_list = [] for data in networks: new_data = {} new_data["macAddress"] = data["bssid"] new_data["signalStrength"] = int(data["rssi"]) formattedNetworks["results"].append(new_data) return formattedNetworks
def scanWifi(): device = json.dumps({"device": "ra0"}) args = ["onion", "wifi-scan", device] return ubus.call(args)["results"]