2024-07-11 -

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

22
GPS.py
View File

@ -21,7 +21,7 @@ rec_buff2 = ''
time_count = 0
def send_at(command,back,timeout):
rec_buff = ''
rec_buff = ''
ser.write((command+'\r\n').encode())
time.sleep(timeout)
if ser.inWaiting():
@ -39,9 +39,6 @@ def send_at(command,back,timeout):
print('GPS no está listo')
return 0
def extract_gps_info(rec_buff):
pass
def get_gps_position():
rec_null = True
answer = 0
@ -51,15 +48,17 @@ def get_gps_position():
time.sleep(2)
while rec_null:
answer = send_at('AT+CGPSINFO','+CGPSINFO: ',1)
client.publish("iiot/"+ myhost +"/gps", answer, 0)
if 1 == answer:
answer = 0
if ',,,,,,' in rec_buff:
gps_info = extract_gps_info(rec_buff)
client.publish("iiot/" + myhost + "/gps", gps_info, 1)
return True
gps_info = extract_gps_info(rec_buff)
client.publish("iiot/" + myhost + "/gps", gps_info, 2)
return True
else:
print('GPS no está listo')
time.sleep(1)
print('GPS no está listo')
rec_null = False
time.sleep(1)
else:
print('error %d'%answer)
rec_buff = ''
@ -67,6 +66,11 @@ def get_gps_position():
return False
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):
print('SIM7600X is starting:')