Closed cpq closed 2 months ago
MG_ENABLE_POSIX_FS
now that it is used in the user code?glue_file_open_xxx()
wraps fopen()
with #if MG_ENABLE_POSIX_FS
, but glue_file_write_xxx()
and glue_file_close_xxx()
do not wrap the posix calls. This should be consistent. eg
#if MG_ENABLE_POSIX_FS
return fclose(fp) == 0;
#else
return true;
#endif
and
#if MG_ENABLE_POSIX_FS
return fwrite(buf, 1, len, fp) == len;
#else
return true;
#endif
glue_file_open_xxx()
, glue_file_write_xxx()
and glue_file_close_xxx()
casting fp
(void*)
to (FILE*)
mg_ota_xxx()
functions must be created for the project to compile. On the ESP32 platform (and possible others where MG_OTA_CUSTOM
is set?) these functions do not exist. It would be a convenience if stubbed out copies of these functions were placed in main.c (or glue?) to allow the project to build. Alternatively, setting MG_OTA_NONE
instead of MG_OTA_CUSTOM
would achieve this and prevent the compilation failure, leaving it to the user to implement the mg_ota_xxx()
functions.mongoose_impl.c
, mqtt_event_handler()
prints a closing message MG_DEBUG(("%lu Closing"));
with no supplied parameter. This should have a parameter as follows: MG_DEBUG(("%lu Closing", c->id));
// Catch uploaded file data for both MG_EV_READ and MG_EV_HTTP_HDRS
if (us->marker == 'U' && (ev == MG_EV_HTTP_HDRS || ev == MG_EV_READ) &&
us->expected > 0 && c->recv.len > 0) {
bool ok = us->fn_write(us->fp, c->recv.buf, c->recv.len);
us->received += c->recv.len;
MG_DEBUG(("%lu chunk: %lu bytes, %lu so far, %lu total, ok: %d", c->id,
c->recv.len, us->received, us->expected, ok));
c->recv.len = 0; // Delete received data
if (ok == false) {
mg_http_reply(c, 400, "", "Upload error\n");
c->is_draining = 1; // Close connection when response it sent
} else if (us->received >= us->expected) {
// Uploaded everything. Send response back
MG_INFO(("%lu done, %lu bytes", c->id, us->received));
mg_http_reply(c, 200, NULL, "%lu ok\n", us->received);
c->is_draining = 1; // Close connection when response is sent <<< ADD THIS LINE
}
}