Downloading binary files with AT+HTTPCGET

tjaffey
Posts: 9
Joined: Thu Feb 29, 2024 11:11 am

Re: Downloading binary files with AT+HTTPCGET

Postby tjaffey » Mon Aug 19, 2024 3:22 pm

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.

esp-at
Posts: 177
Joined: Mon May 09, 2022 3:00 am

Re: Downloading binary files with AT+HTTPCGET

Postby esp-at » Tue Aug 20, 2024 3:24 am

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.

tjaffey
Posts: 9
Joined: Thu Feb 29, 2024 11:11 am

Re: Downloading binary files with AT+HTTPCGET

Postby tjaffey » Tue Aug 20, 2024 7:32 am

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

Who is online

Users browsing this forum: No registered users and 16 guests