Fixing espfs upload capability
This commit is contained in:
@@ -11,9 +11,10 @@
|
||||
|
||||
|
||||
/*
|
||||
This is a 'captive portal' DNS server: it basically replies with a fixed IP for any and all DNS
|
||||
queries. This can be used to send mobile phones, tablets etc which connect to the ESP in
|
||||
AP mode directly to the internal webserver.
|
||||
This is a 'captive portal' DNS server: it basically replies with a fixed IP (in this case:
|
||||
the one of the SoftAP interface of this ESP module) for any and all DNS queries. This can
|
||||
be used to send mobile phones, tablets etc which connect to the ESP in AP mode directly to
|
||||
the internal webserver.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
@@ -42,15 +42,14 @@ int ICACHE_FLASH_ATTR cgiReadFlash(HttpdConnData *connData) {
|
||||
|
||||
//Cgi that allows the ESPFS image to be replaced via http POST
|
||||
int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) {
|
||||
//Now esphttpd is a lib and doesn't know ESPFS_POS/ESPFS_SIZE, this does not work anymore. ToDo: Find some way
|
||||
//to reinstate it?
|
||||
#if 0
|
||||
const CgiUploadEspfsParams *up=(CgiUploadEspfsParams*)connData->cgiArg;
|
||||
|
||||
if (connData->conn==NULL) {
|
||||
//Connection aborted. Clean up.
|
||||
return HTTPD_CGI_DONE;
|
||||
}
|
||||
|
||||
if(connData->post->len > ESPFS_SIZE){
|
||||
if(connData->post->len > up->espFsSize){
|
||||
// The uploaded file is too large
|
||||
os_printf("ESPFS file too large\n");
|
||||
httpdSend(connData, "HTTP/1.0 500 Internal Server Error\r\nServer: esp8266-httpd/0.3\r\nConnection: close\r\nContent-Type: text/plain\r\nContent-Length: 24\r\n\r\nESPFS image loo large.\r\n", -1);
|
||||
@@ -58,7 +57,7 @@ int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) {
|
||||
}
|
||||
|
||||
// The source should be 4byte aligned, so go ahead and flash whatever we have
|
||||
int address = ESPFS_POS + connData->post->received - connData->post->buffLen;
|
||||
int address = up->espFsPos + connData->post->received - connData->post->buffLen;
|
||||
if(address % SPI_FLASH_SEC_SIZE == 0){
|
||||
// We need to erase this block
|
||||
os_printf("Erasing flash at %d\n", address/SPI_FLASH_SEC_SIZE);
|
||||
@@ -68,7 +67,6 @@ int ICACHE_FLASH_ATTR cgiUploadEspfs(HttpdConnData *connData) {
|
||||
os_printf("Writing at: 0x%x\n", address);
|
||||
spi_flash_write(address, (uint32 *)connData->post->buff, connData->post->buffLen);
|
||||
os_printf("Wrote %d bytes (%dB of %d)\n", connData->post->buffSize, connData->post->received, connData->post->len);//&connData->postBuff));
|
||||
#endif
|
||||
|
||||
if (connData->post->received == connData->post->len){
|
||||
httpdSend(connData, "Finished uploading", -1);
|
||||
|
||||
Reference in New Issue
Block a user