# Mongoose Wizard Project

This project is generated by Mongoose Wizard, https://mongoose.ws/wizard/
Mongoose Wizard is a visual Web dashboard builder for embedded devices.

Mongoose is a production-grade embedded web server and networking library for
STM32, NXP, RP2350, ESP32, and other Cortex-M and RISC-V microcontrollers. It
provides HTTP, WebSocket, TLS/HTTPS, MQTT, and OTA firmware updates in a
compact two-file C library that runs on bare metal or RTOS, enabling secure
device dashboards, cloud connectivity, and remote management.

## How to integrate Mongoose to an existing firmware

In order to move this functionality to some existing firmware code, perform
the following steps:

1. Generate new wizard project with your target architecture
2. Copy / link the `mongoose/` folder from wizard project to your existing project
3. Edit the `mongoose/mongoose_config.h` if necessary
4. Add `mongoose/` to your include paths, and `mongoose/*.c` to source files. This depends on your IDE
5. On ARMs with built-in Ethernet, disable CPU cache
6. Add the following to your main C file:

```c
#include "mongoose_glue.h"
// #include "mongoose_hal.h"  // A helper micro-HAL for your platform

...

// Uncomment if required
//
// uint64_t mg_millis(void) {
//   return HAL_GetTick();
// }
//
// bool mg_random(void *buf, size_t len) {
//   for (size_t n = 0; n < len; n += 4) {
//     uint32_t r = hal_rng_read();
//     memcpy((char *) buf + n, &r, n + 4 > len ? len - n : 4);
//   }
//   return true;
// }
//
// int _write(int fd, char *buf, unsigned int len) {
//   if (fd == 1) hal_uart_write_buf(HAL_DEBUG_UART, buf, (size_t) len);
//   return len;
// }


  // Add to the end of main(). Uncomment what needs to be initialized.
  //
  // hal_clock_init();
  // hal_uart_init(HAL_DEBUG_UART, 115200);
  // hal_rng_init();
  // hal_leds_init();
  // hal_ethernet_init();
  //
  // You may need to include a specific section for Ethernet RAM
  // Example for the STM32H723:
  // - add in mongoose_config.h redefine the macro MG_ETH_RAM:
  // #define MG_ETH_RAM __attribute__((section(".eth_ram")))
  // - edit your linker script to include a .eth_ram section:
  //
  // MEMORY
  // {
  //  RAM_D2(rwx): ORIGIN = 0x30000000, LENGTH = 32K
  //  ...
  // }
  //
  //  .eth_ram : { *(.eth_ram .eth_ram*) } > RAM_D2 AT > ROM
  mongoose_init();

  // Event loop. mongoose_poll() does not block.
  // Add it into your existing barememetal superloop,
  // or start as a separate RTOS task with minimum of 8k stack
  for (;;) {
    mongoose_poll();
  }

```

## Guides and Tutorials

- [Video Guides](https://www.youtube.com/@mongoose-networking-library/videos)
- [Ethernet hardware](https://mongoose.ws/documentation/tutorials/hardware/)
- [Firmware OTA updates](https://mongoose.ws/documentation/tutorials/firmware-update/)
- [Mongoose User Guide](https://mongoose.ws/documentation/)
