Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Next issues #5

Closed
14 tasks done
cpq opened this issue May 16, 2024 · 2 comments
Closed
14 tasks done

Next issues #5

cpq opened this issue May 16, 2024 · 2 comments

Comments

@cpq
Copy link
Member

cpq commented May 16, 2024

  • Header files should have CPP header guards so functions can be called from CPP - mongoose_glue.h specifically should have this
  • Maybe mongoose_config.h should specify a value for MG_ENABLE_POSIX_FS now that it is used in the user code?
  • In mongoose_glue.c, 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
  // 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
    }
  }
@cpq
Copy link
Member Author

cpq commented May 16, 2024

mg_ota functions: those are user-defined, and generated project must ensure that they exist. Either dummy, or built-in, or generated. In case of ESP32, mongoose_config should set #define MG_OTA MG_OTA_ESP32 - a mongoose built-in support.

@cpq
Copy link
Member Author

cpq commented May 16, 2024

"Generating (or subscribing to?) the mqtt rx" - cannot reproduce that. If I just enable MQTT in a default config, works fine (uses non-empty device_id expansion). If I use a non-existent variable, works too. Let me know the way to reproduce, please!

@cpq cpq closed this as completed May 16, 2024
@cpq cpq reopened this May 16, 2024
@cpq cpq closed this as completed Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant