I noticed something strange with the http get example (at least in my setup).
I am using the http get example from here. I edited the code to make authentication work (see example in Docs).
When I sent the GET request for a small payload such as {"this is": "json"}
it works fine every run. If I request a bigger payload, it will often/always print
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,201,454', 'CONNECT', '{"PicoSleepMin":15,"LongSleepLoop":1,"Datetime":"DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb","Key":"DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb","LONGSTRING":"DJwiofgwqodfouvwbrguj23456743245nuztbewfbae']
INFO: {'response': 'timeout', 'status': 2}
The request however is properly received and returned with status code 201/200
Here’s my code:
import time
from pico_lte.utils.status import Status
from pico_lte.core import PicoLTE
from pico_lte.common import debug
picoLTE = PicoLTE()
picoLTE.network.register_network()
picoLTE.http.set_context_id()
picoLTE.network.get_pdp_ready()
picoLTE.http.set_server_url()
picoLTE.http.set_auth()
debug.set_level(0)
debug.info("Sending a GET request.")
result = picoLTE.http.get()
debug.info(result)
# Read the response after 5 seconds (or 20) does not help...
time.sleep(5)
result = picoLTE.http.read_response()
debug.info(result)
if result["status"] == Status.SUCCESS:
debug.info("Get request succeeded.")
Payload (GET Result)
{
"PicoSleepMin": 15,
"LongSleepLoop": 1,
"Datetime": "DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb",
"Key": "DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb",
"LONGSTRING": "DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb",
"https": {
"username": "DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb",
"password": "DJwiofgwqodfouvwbrguj23456743245nuztbewfbaeioufbeufgibfuiebfiewbgiwb"
}
}
I checked the documentation and set timeout
or input_timeout
to higher values without success. E.g.
picoLTE.http.read_response(timeout=20)