BC660K - How to download large files using QHTTPREAD?

I’ve successfully implemented the download of a file (22KB) to an SD card, but it does not seem to work for large files. I need to download a 1MB file. How do I get this working?

My current process is as follows:

AT+QSSLCFG=0,0,“seclevel”,0
AT+QSSLCFG=“ssl”,0,0
AT+QHTTPCFG=“responseheader”,0
AT+QHTTPURL=74
… I enter the URL…
AT+QHTTPGET=80

After about 12 seconds I get the response:

+QHTTPGET: 0,200,998000

I then attempt to download the file by repeatedly doing:

AT+QHTTPREAD=1024

This approach works great for my 22KB test file and takes about 11 seconds. This does not, however, work for my 1MB file. It downloads the first ~7KB and then fails. (I have a 30 seconds timeout waiting for QHTTPREAD to respond.)

Does anyone have any guidance on how to handle large file downloads?

I attempted the same with a 60KB file. That returned an “ERROR” and upon retrying the HTTPREAD made the module reset.

I suggest you try it with 2K data, the memory space of the NB module itself is limited and small

We use this to download files up to 100K and it works fine, but we don’t use SSL/TLS. Using BC660KGLAAR01A05_01.200.01.200 firmware.

@rastik could you please share this knowledge with me? :wink:
I ve got BC660KGLAAR01A05_01.202.01.202 firmware and
AT+QHTTPREAD command stuck with ERROR response after ~40KB of downloading… I need to manage how to download files with size ~250KB…

The best solution I’ve found is (on a non-https endpoint):

  1. Open a TCP connection
  2. Initiate a “send” (AT+QISEND=0), this will respond with an input prompt
  3. Build your own HTTP GET header and submit it (ie: GET /myfile.zip HTTP/1.1\r\nHost: www.somehost.com\r\n\r\n”)
  4. The request will respond with the total filesize and start streaming the data down.

BUT…it sometimes fail to download the complete file (I sometimes have to download 1.6MB), so keep track of the total amount of bytes you have already received and repeat steps 1-4, but add “Range:” to your header so that you start again from where the download failed. Keep doing this until you have all the bytes downloaded.

It’s not straight forward, but it works.

Can you please share log of such a communication? Which AT commands are you sending and what’s the response? We don’t transfer such large files, but ~80kB works fine.

Would you like to share AT commands?

  1. Open a TCP connection - at+qiopen=0,1,“TCP”,<URL_ADDRESS> ?
  2. at+qisend=0 ??
  3. Header
  4. Read respond with QHTTPREAD or waiting for QIURC “recv” ?

For now im going with this method:

  • at+qhttpcfg="responseheader",0 (response OK)
  • at+qhttpcfg="contenttype",2 (response OK)
  • at+qhttpurl=<URL_LEN>
  • (response OK)
  • at+qhttpget=80 (response OK than +QHTTPGET: 0,200,248891

after that im starting reading from file 516B packages:
at+qhttpread=516

response is (+QHTTPREAD: 516,248375 (data) OK)

but after some time only answer for +qhttpread is ERROR

@dkubeczek Could you please attach the whole communication log of a failed communication? From port opening to the failure? Because the problem can be somewhere in the details.