2024-07-11 -
This commit is contained in:
parent
0717aed610
commit
61e3683d03
9
GPS.py
9
GPS.py
@ -39,6 +39,9 @@ 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
|
||||
@ -48,12 +51,14 @@ def get_gps_position():
|
||||
time.sleep(2)
|
||||
while rec_null:
|
||||
answer = send_at('AT+CGPSINFO','+CGPSINFO: ',1)
|
||||
client.publish("iiot/"+ myhost +"/gps", answer, 2)
|
||||
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
|
||||
else:
|
||||
print('GPS no está listo')
|
||||
rec_null = False
|
||||
time.sleep(1)
|
||||
else:
|
||||
print('error %d'%answer)
|
||||
|
25
coordinates.txt
Normal file
25
coordinates.txt
Normal 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
|
||||
|
5
gps2.py
5
gps2.py
@ -52,11 +52,8 @@ def get_gps_position():
|
||||
if 1 == answer:
|
||||
answer = 0
|
||||
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')
|
||||
rec_null = False
|
||||
time.sleep(1)
|
||||
else:
|
||||
print('error %d'%answer)
|
||||
|
Loading…
Reference in New Issue
Block a user