How can I reliably detect the end of an HTTPCGET transfer?
There seem to be 3 ways to do this, but each has problems...
a) Doesn't work with HTTP servers which don't support HEAD requests and doesn't work with dynamically generated content which is missing a "Content-Length" HTTP header
- Use AT+SYSMSGFILTERCFG to filter out "\r\nOK\r\n"
- Use AT+HTTPGETSIZE to find out how many bytes to expect
- Use AT+HTTPCGET to receive the expected number of bytes
b) Fails if the received file contains the string "\r\nOK\r\n" (which it always will as I'm transferring the firmware which detects this string from ESP-AT)
- Use AT+HTTPCGET to receive bytes until "\r\nOK\r\n" is seen
c) Fails if the HTTP transfer pauses at the wrong moment
- Use AT+HTTPCGET and timeout when no more bytes are being received, hoping that this is the end of the transfer
Ideally, I would like ESP-AT to either escape/encode certain bytes in the transferred data or to provide a packet like transfer to the host microcontroller telling it how many bytes to expect and whether the transfer is finished.
Downloading binary files with AT+HTTPCGET
Re: Downloading binary files with AT+HTTPCGET
About the second one:
"if the received file contains the string "\r\nOK\r\n""
have you tried to add ^ (which matches the starting position within the string) and $ (Matches the ending position of the string) to the regular syntax.
"if the received file contains the string "\r\nOK\r\n""
have you tried to add ^ (which matches the starting position within the string) and $ (Matches the ending position of the string) to the regular syntax.
Re: Downloading binary files with AT+HTTPCGET
Can you give me the command for this? I'm not sure exactly what you mean?
Do you mean step 5 from https://github.com/espressif/esp-at/blo ... s.rst#L159
Do you mean step 5 from https://github.com/espressif/esp-at/blo ... s.rst#L159
Who is online
Users browsing this forum: No registered users and 13 guests