Thanks Mark,
I test the download with that code :
static const CHAR gen_firm[] = "µH00"; // command to get back the firmware
static const CHAR gen_bmp[] = "µH20"; // command to generate a BMP from the present LCD display content
static const USER_FILE user_files[] = {
{"favicon.ico", (unsigned char *)_favicon, sizeof(_favicon), MIME_ICON, FILE_VISIBLE},
{"index.htm", (unsigned char *)start_page, sizeof(start_page), MIME_HTML, FILE_VISIBLE},
{"LCD.BMP", (unsigned char *)gen_bmp, sizeof(gen_bmp), MIME_HTML, FILE_INVISIBLE},
{"SOFT.BIN", (unsigned char *)gen_firm, sizeof(gen_firm), MIME_HTML, FILE_INVISIBLE}, //MIME_HTML car il faut générer le bin...
{0} // end of list
};
So I can use a web browser to get
http://192.168.167.223/SOFT.BIN if (*ptrBuffer == '0') {
ulong TotalSize = (long)Image$$ER_IROM1$$Length + (long)Image$$RW_IRAM1$$RW$$Length;
int Idx = 0;
LENGTH_CHUNK_COUNT Chunk = (TxLength - 1); // the present chunk reference
http_session->ucDynamicFlags |= GENERATING_DYNAMIC_BINARY; // ensure the HTTP server knows that we are generating binary content
if (Chunk > TotalSize/256) { // after generating all file stop
return 0;
}
*usLengthToSend = 256; // {21}
if (Chunk == (TotalSize/256)) { // signal last chunk to ensure that no padding is added
http_session->ucDynamicFlags |= LAST_DYNAMIC_CONTENT_DATA;
}
cPtr = cValue;
while (Idx < 256) { // {21}
*cPtr++ = * (char *)((long)Image$$ER_IROM1$$Base + (Chunk*256) + Idx);
Idx++;
}
*usLengthToSend = (cPtr - cValue); // length of code to insert*/
return cValue;
}
It works fine, even if I got problem to know exactly the end of the image due to compressed zone on memory. But that's it!
I think I could add
ulCodeLength,
usMagicNumber and
usCRC at the beginning of the transmission, to form the header.
I have only a strange behaviour : when I try to get
SOFT.BIN it does not work.... If I try with
SOFT.BINN or
SOFT.BINOOO, It works !!!!
Is there a detection of
BIN file excepting from
MIME_TYPE ?
Regards