Video: https://mongoose.ws/downloads/mongoose_netxduo.mp4
- Load Nx_TCP_Echo_Server example for STM32H573II Add IO retargeting to main.c:
int _write(int fd, unsigned char *buf, int len) {| #include "mongoose.h" | |
| // Public TCP echo server, see https://tcpbin.com/ | |
| #define TCP_SERVER_URL "tcp://tcpbin.com:4242" | |
| // Custom TCP protocol client connection | |
| static struct mg_connection *s_client_conn = NULL; | |
| static void tcp_ev_handler(struct mg_connection *c, int ev, void *ev_data) { | |
| if (ev == MG_EV_OPEN) { |
| // This version measures poll execution time | |
| void run_mongoose(void) { | |
| struct mg_mgr mgr; // Mongoose event manager. Holds all connections | |
| mg_mgr_init(&mgr); // Initialise event manager | |
| mg_http_listen(&mgr, "http://0.0.0.0:80", ev_handler, NULL); | |
| unsigned long counter = 0; | |
| for (;;) { | |
| uint64_t start = mg_millis(); | |
| uint32_t val1 = SysTick->VAL; | |
| mg_mgr_poll(&mgr, 1000); // Infinite event loop |
| // This MQTT client implements device management with | |
| // a device dashboard, remote firmware update and device control over MQTT. | |
| // | |
| // Usage: | |
| // 1. Visit https://mongoose.ws/wizard. Enable MQTT, generate project | |
| // 2. Copy-paste this code into your main.c | |
| // 3. After mongoose_init() call, add initialization: | |
| // struct mongoose_mqtt_handlers mqtt_handlers = { | |
| // my_mqtt_connect, my_mqtt_tls_init, my_mqtt_on_connect, | |
| // my_mqtt_on_message, my_mqtt_on_cmd, |
Video: https://mongoose.ws/downloads/mongoose_netxduo.mp4
int _write(int fd, unsigned char *buf, int len) {| size_t print_entries(void (*out)(char, void *), void *ptr, va_list *ap) { | |
| const char **names = va_arg(*ap, const char **); | |
| size_t i, len = 0; | |
| for (i = 0; names[i] != NULL; i++) { | |
| len += mg_xprintf(out, ptr, "%s%m", | |
| i > 0 ? "," : "", // Comma-separate entries | |
| MG_ESC(names[i])); // JSON-escape string | |
| } | |
| return len; | |
| } |
| // SPDX-FileCopyrightText: 2024 Cesanta Software Limited | |
| // SPDX-License-Identifier: GPL-2.0-only or commercial | |
| // Generated by Mongoose Wizard, https://mongoose.ws/wizard/ | |
| #include "mongoose_glue.h" | |
| #include "wifi.h" | |
| #include "driver/gpio.h" | |
| #include "driver/temperature_sensor.h" | |
| #include "nvs_flash.h" |
| // Source for the https://www.youtube.com/watch?v=pp9AM5A1mDs | |
| // Written & tested on MacOS | |
| // To discuss or report issues, join https://discord.gg/KfR8E6wSds | |
| #include <arpa/inet.h> | |
| #include <errno.h> | |
| #include <fcntl.h> | |
| #include <netinet/in.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> |
| #!/bin/bash | |
| # SWD commands to call rt1060 flash boot rom functions | |
| DEVCALL="curl -su :$VCON_API_KEY https://dash.vcon.io/api/v3/devices/13" | |
| # SWD exec: se COMMANDS. Hex addresses are without leading 0x | |
| se() { $DEVCALL/rpc/swd.exec -d "{\"req\": \"$*\"}" | jq -cr .resp ; } | |
| rm() { se rm,$1 | cut -d, -f2 ; } | |
| dump() { $DEVCALL/rpc/swd.read -d "{\"addr\":$1, \"size\": $2}" | jq -r .data | xxd -r -p | hexdump -C ; } | |
| hex() { node -p "($*).toString(16)"; } |
Example MCU: STM32 H743ZI
| Example | Type | Description |
|---|---|---|
| H | Type | F: mainstream, L: low power, H: high performance, W: wireless |
| 7 | Core | 0: M0, 1: M3, 2: M3, 3: M4, 4: M4, 7: M7 |
| 23 | Line | speed, peripherals, silicon process, … |
| Z | Pin count | F: 20, G: 28, K: 32, T: 36, S: 44, C: 48, R: 64,66, V: 100, Z: 144, I: 176 |
| // Copyright (c) Cesanta Software Limited | |
| // All rights reserved | |
| // SPDX-License-Identifier: MIT | |
| // Usage example (Arduino): | |
| // char buf[100]; | |
| // struct slip slip = {.buf = buf, .size = sizeof(buf) - 1}; | |
| // ... | |
| // unsigned char c = Serial.read(); | |
| // size_t len = slip_recv(c, &slip); |