2024-07-11 -
This commit is contained in:
parent
61e3683d03
commit
0733127ea0
12
GPS.py
12
GPS.py
@ -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,14 +48,16 @@ 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)
|
||||
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)
|
||||
@ -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:')
|
||||
|
Loading…
Reference in New Issue
Block a user