#!/usr/bin/python3 import time import json import paho.mqtt.client as mqtt circleOpacity=0.2 useLeafletLocal=1 MAPBOXTOKEN="pk.eyJ1IjoieWFuaWtjYXdpZHJvbmUiLCJhIjoiY2p4dmlheGtzMDN0dTNoa2R2b2sxZndkNSJ9.Tfd-xcohTT4x7nEe5_6Rxg" # Leaflet # https://unpkg.com/leaflet@1.7.1/dist/leaflet.js # https://unpkg.com/leaflet@1.7.1/dist/leaflet.css def networkSurveyColor(rssi): color="#888" if float(rssi) < -105: color="#f00" elif float(rssi) < -95: color="#ff6600" elif float(rssi) < -85: color="#ffa500" elif float(rssi) < -80: color="#ffab40" else: color="#15ab00" return color def networkSurveyAddLeaflet(): global useLeafletLocal leaflet="" leafletCssPath="leaflet.css" leafletJsPath="leaflet.js" if useLeafletLocal is 0: leafletCssPath="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" leafletJsPath="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" leaflet+=" \n" leaflet+=" \n" return leaflet def networkSurveySetMapboxApiToken(): global MAPBOXTOKEN return MAPBOXTOKEN def networkSurvey(filename, subId): global circleOpacity start_time = time.time() htmlOutput="\n" htmlOutput+="\n" htmlOutput+="\n" htmlOutput+=" networkSurvey\n" htmlOutput+=" \n" htmlOutput+=" \n" htmlOutput+=" \n" htmlOutput+=networkSurveyAddLeaflet() htmlOutput+="\n" htmlOutput+="\n" htmlOutput+="\n" htmlOutput+="
\n" htmlOutput+="\n" htmlOutput+="\n" deltaTime = float(int(100*(time.time() - start_time)))/100 htmlOutput+="

Took: "+str(deltaTime)+" seconds

\n" if countRaw != 0: #print(lastLine) part=lastLine.split(',') lastOutput="

\n" lastOutput+="

"+part[1]+"
\n" lastOutput+="
"+part[4]+"
\n" lastOutput+="
"+part[2]+"
\n" lastOutput+="
"+part[5]+" "+part[6]+" "+part[7]+"
\n" lastOutput+="
\n" lastOutput+="

\n" htmlOutput+=lastOutput htmlOutput+="\n" htmlOutput+="\n" filenameSurvey="networkSurvey-"+str(subId)+".html" with open(filenameSurvey,"w") as f: f.write(htmlOutput+"\n") f.close()