2024-07-11 -

This commit is contained in:
Adolfo Delorenzo 2024-07-11 18:35:03 -06:00
parent 0717aed610
commit 61e3683d03
3 changed files with 36 additions and 9 deletions

9
GPS.py
View File

@ -39,6 +39,9 @@ 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
@ -48,12 +51,14 @@ 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, 2)
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)
client.publish("iiot/" + myhost + "/gps", gps_info, 1)
return True
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)

25
coordinates.txt Normal file
View File

@ -0,0 +1,25 @@
Iniciando GPS
AT+CGPS=1,1 ERROR
AT+CGPS=1,1 back: AT+CGPS=1,1
ERROR
AT+CGPSINFO
+CGPSINFO: 0956.397161,N,08406.296290,W,110724,205340.0,1153.2,0.0,
OK
AT+CGPSINFO
+CGPSINFO: 0956.397161,N,08406.296288,W,110724,205342.0,1153.2,0.0,
OK
AT+CGPSINFO
+CGPSINFO: 0956.397165,N,08406.296286,W,110724,205345.0,1153.2,0.0,
OK
AT+CGPSINFO
+CGPSINFO: 0956.397165,N,08406.296287,W,110724,205347.0,1153.2,0.0,
OK

View File

@ -52,11 +52,8 @@ def get_gps_position():
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)
client.publish("iiot/" + myhost + "/gps", gps_info, 2)
return True
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)