added extra version

This commit is contained in:
Nico Melone
2022-05-10 12:13:03 -05:00
parent dd41db1602
commit 909d2a4fb1
18 changed files with 2682 additions and 0 deletions

Binary file not shown.

View File

@@ -4,6 +4,7 @@ from common.Logger import logger
from quickfaas.remotebus import publish
import re, uuid
from paho.mqtt import client
from mobiuspi_lib.gps import GPS
lwtData = {
"init":False,
@@ -24,10 +25,35 @@ def lwt(mac):
logger.error("LWT DID NOT DO THE THING")
logger.error(e)
def getGPS(mac):
# Create a gps instance
gps = GPS()
# Retrieve GPS information
position_status = gps.get_position_status()
logger.debug("position_status: ")
logger.debug(position_status)
latitude = position_status["latitude"].split(" ")
longitude = position_status["longitude"].split(" ")
lat_dec = int(latitude[0][:-1]) + (float(latitude[1][:-1])/60)
lon_dec = int(longitude[0][:-1]) + (float(longitude[1][:-1])/60)
if latitude[2] == "S":
lat_dec = lat_dec * -1
if longitude[2] == "W":
lon_dec = lon_dec * -1
#lat_dec = round(lat_dec, 7)
#lon_dec = round(lon_dec, 7)
logger.info("HERE IS THE GPS COORDS")
logger.info(f"LATITUDE: {lat_dec}, LONGITUDE: {lon_dec}")
topic = f"meshify/db/194/_/M1/{mac}:00:30/gps"
publish(topic, json.dumps([{"value":f"{lat_dec:.8f},{lon_dec:.8f}"}]), __qos__)
def sendData(message):
#logger.debug(message)
mac = __topic__.split("/")[-1] #':'.join(re.findall('..', '%012x' % uuid.getnode()))
lwt(mac)
getGPS(mac)
for measure in message["measures"]:
try:
logger.debug(measure)