#!/usr/bin/python3 import time import configuration circleOpacity=0.2 useLeafletLocal=1 MAPBOXTOKEN="pk.eyJ1IjoieWFuaWtjYXdpZHJvbmUiLCJhIjoiY2p4dmlheGtzMDN0dTNoa2R2b2sxZndkNSJ9.Tfd-xcohTT4x7nEe5_6Rxg" server = configuration.get_server() # Leaflet # https://unpkg.com/leaflet@1.7.1/dist/leaflet.js # https://unpkg.com/leaflet@1.7.1/dist/leaflet.css def networkSurveyColorRSSI(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 networkSurveyColor(snr): color="#888" if float(snr) <= -7.5: #sf12 color="#f00" elif float(snr) <= -5: #sf11 #color="#ff6600" color="#a35c00" elif float(snr) < -2.5: #sf10 #color="#ffa500" color="#7a8500" elif float(snr) < -0: #sf9 #color="#ffab40" color="#52ad00" elif float(snr) < 2.5: #sf8 #color="#ffab40" color="#29d600" else: #sf7 color="#15ab00" return color def networkSurveySetLeaflet(useLocal): global useLeafletLocal if True is useLocal: useLeafletLocal=1 else: useLeafletLocal=0 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.js" leaflet+=" \n" leaflet+=" \n" return leaflet def networkSurveySetMapboxApiToken(): global MAPBOXTOKEN return MAPBOXTOKEN def networkSurvey(filename, subId, devEUI = None, fileOutput= True, latestRecords=0): global server global circleOpacity latest=int(latestRecords) start_time = time.time() htmlOutput="\n" htmlOutput+="\n" htmlOutput+="\n" htmlOutput+=" "+server['name']+"\n" htmlOutput+=" \n" htmlOutput+=" \n" htmlOutput+=" \n" htmlOutput+=networkSurveyAddLeaflet() htmlOutput+="\n" htmlOutput+="\n" htmlOutput+="\n" if fileOutput is True: htmlOutput += "

"+filename+" - "+subId+"

" htmlOutput+="
\n" htmlOutput+="\n" htmlOutput+="\n" deltaTime = float(int(100*(time.time() - start_time)))/100 htmlOutput+="

Took: "+str(deltaTime)+" seconds

\n" lastOutput="

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

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

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