2024-07-11 -

This commit is contained in:
Adolfo Delorenzo 2024-07-11 18:55:04 -06:00
parent 61e3683d03
commit 0733127ea0

12
GPS.py
View File

@ -39,9 +39,6 @@ def send_at(command,back,timeout):
print('GPS no está listo') print('GPS no está listo')
return 0 return 0
def extract_gps_info(rec_buff):
pass
def get_gps_position(): def get_gps_position():
rec_null = True rec_null = True
answer = 0 answer = 0
@ -51,14 +48,16 @@ def get_gps_position():
time.sleep(2) time.sleep(2)
while rec_null: while rec_null:
answer = send_at('AT+CGPSINFO','+CGPSINFO: ',1) answer = send_at('AT+CGPSINFO','+CGPSINFO: ',1)
client.publish("iiot/"+ myhost +"/gps", answer, 0)
if 1 == answer: if 1 == answer:
answer = 0 answer = 0
if ',,,,,,' in rec_buff: if ',,,,,,' in rec_buff:
gps_info = extract_gps_info(rec_buff) gps_info = extract_gps_info(rec_buff)
client.publish("iiot/" + myhost + "/gps", gps_info, 1) client.publish("iiot/" + myhost + "/gps", gps_info, 2)
return True return True
else: else:
print('GPS no está listo') print('GPS no está listo')
rec_null = False
time.sleep(1) time.sleep(1)
else: else:
print('error %d'%answer) print('error %d'%answer)
@ -67,6 +66,11 @@ def get_gps_position():
return False return False
time.sleep(1.5) time.sleep(1.5)
def extract_gps_info(rec_buff):
# Implement this function based on the format of rec_buff
# Example: gps_info = rec_buff.split(',')[2]
return gps_info
def power_on(power_key): def power_on(power_key):
print('SIM7600X is starting:') print('SIM7600X is starting:')