2024-07-11 -
This commit is contained in:
parent
0717aed610
commit
61e3683d03
11
GPS.py
11
GPS.py
@ -21,7 +21,7 @@ rec_buff2 = ''
|
|||||||
time_count = 0
|
time_count = 0
|
||||||
|
|
||||||
def send_at(command,back,timeout):
|
def send_at(command,back,timeout):
|
||||||
rec_buff = ''
|
rec_buff = ''
|
||||||
ser.write((command+'\r\n').encode())
|
ser.write((command+'\r\n').encode())
|
||||||
time.sleep(timeout)
|
time.sleep(timeout)
|
||||||
if ser.inWaiting():
|
if ser.inWaiting():
|
||||||
@ -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
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
|
||||||
|
|
9
gps2.py
9
gps2.py
@ -52,12 +52,9 @@ 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)
|
print('GPS no está listo')
|
||||||
client.publish("iiot/" + myhost + "/gps", gps_info, 2)
|
rec_null = False
|
||||||
return True
|
time.sleep(1)
|
||||||
else:
|
|
||||||
print('GPS no está listo')
|
|
||||||
time.sleep(1)
|
|
||||||
else:
|
else:
|
||||||
print('error %d'%answer)
|
print('error %d'%answer)
|
||||||
rec_buff = ''
|
rec_buff = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user