I’m trying to do an HTTP get of the current time as a way of keeping the system clock updated. My code is pretty much right out of the example. I can see the json results displayed in the debug but I cannot retrieve the datetime. See debug code below the code.
import time
from pico_lte.utils.status import Status
from pico_lte.core import PicoLTE
from pico_lte.common import debug
debug.set_level(0)
picoLTE = PicoLTE()
picoLTE.network.register_network()
picoLTE.http.set_context_id()
picoLTE.network.get_pdp_ready()
picoLTE.http.set_server_url()
debug.info("Sending a GET request.")
result = picoLTE.http.get()
debug.info(result)
# Read the response after 5 seconds.
time.sleep(5)
result = picoLTE.http.read_response()
debug.info(result)
if result["status"] == Status.SUCCESS:
debug.info("Get request succeeded.")
DEBUG Below
DEBUG: Processed: ['+CGACT: 1,1', '+CGACT: 2,0', 'OK']
DEBUG: Desired: +CGACT: 1,1
DEBUG: check_pdp_context_status : {'response': ['+CGACT: 1,1', '+CGACT: 2,0', 'OK'], 'status': 0}
DEBUG: success : {'response': ['+CGACT: 1,1', '+CGACT: 2,0', 'OK'], 'status': 0}
DEBUG: Processed: ['CONNECT']
DEBUG: Response: ['\r\nOK\r\n']
DEBUG: Processed: ['OK']
INFO: Sending a GET request.
DEBUG: Response: ['\r\nOK\r\n']
DEBUG: Processed: ['OK']
DEBUG: Response: ['\r\nOK\r\n']
DEBUG: Processed: ['OK']
INFO: {'response': ['OK'], 'status': 0}
DEBUG: Processed: ['+QHTTPGET: 0,200,349', 'CONNECT', '{"utc_offset":"-05:00","timezone":"America/New_York","day_of_week":3,"day_of_year":1,"datetime":"2025-01-01T18:28:56.367500-05:00","utc_datetime":"2025-01-01T23:28:56.367500+00:00","unixtime":1735774136,"raw_offset":-18000,"week_number":1,"dst":false,"a']
{'response': 'timeout', 'status': 2}
INFO: {'response': 'timeout', 'status': 2}
time= {'response': 'timeout', 'status': 2}