mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-19 19:40:56 +00:00
Tutorials - nits and mqtt client adoption
This commit is contained in:
1 parent
069ab78c02
commit
28e3b347d4
8 files changed
+14
-5
No files matched your search
@@ -17,6 +17,4 @@ flash:
|
||||
cd build && esptool --chip $(ARCH) --baud 460800 --port $(PORT) write-flash @flash_args
|
||||
|
||||
clean:
|
||||
test -d build && (rm -rf build sdkconfig || true)
|
||||
|
||||
.PHONY: build
|
||||
test -d build && $(DOCKER) rm -rf build sdkconfig || true
|
||||
@@ -15,6 +15,7 @@ CFLAGS += -mcpu=cortex-m33+nodsp -mthumb -mfloat-abi=hard -mfpu=fpv5-sp-d16 $(CF
|
||||
LDFLAGS ?= -Tlink.ld -nostdlib -nostartfiles --specs=nano.specs -lc -lgcc -Wl,--gc-sections
|
||||
|
||||
SOURCES = main.c hal.c startup.c flexspi.c flash_config.c $(MGDIR)/mongoose.c
|
||||
SOURCES += $(MGDIR)/tutorials/mqtt/mqtt-client/mongoose_mqtt.c
|
||||
SOURCES += cmsis_rw612/devices/RW612/drivers/fsl_clock.c
|
||||
SOURCES += cmsis_rw612/devices/RW612/drivers/fsl_trng.c
|
||||
SOURCES += cmsis_rw612/devices/RW612/drivers/fsl_reset.c
|
||||
@@ -44,5 +45,8 @@ flash: firmware.bin
|
||||
(echo 'loadfile firmware.elf'; echo 'reset'; echo 'exit';) | JLinkExe -device RW612 -if SWD -speed 4000 -autoconnect 1 -NoGui 1 -ExitOnError 1
|
||||
# JRun --nogui --device RW612 --if SWD firmware.elf
|
||||
|
||||
erase:
|
||||
(echo halt && echo exec EnableEraseAllFlashBanks && echo erase && echo exit) | JLinkExe -device RW612 -if SWD -speed 4000 -autoconnect 1 -NoGui 1 -ExitOnError 1
|
||||
|
||||
clean:
|
||||
rm -rf firmware.* cmsis_* mongoose/mongoose.*
|
||||
@@ -104,6 +104,7 @@ int main(void) {
|
||||
// Start a minimal web server
|
||||
struct mg_mgr mgr;
|
||||
mg_mgr_init(&mgr);
|
||||
mg_mqtt_init(&mgr);
|
||||
mg_http_listen(&mgr, "http://0.0.0.0", http_ev_handler, NULL);
|
||||
mg_http_listen(&mgr, "https://0.0.0.0", http_ev_handler, NULL);
|
||||
|
||||
@@ -113,6 +114,7 @@ int main(void) {
|
||||
|
||||
for (;;) {
|
||||
mg_mgr_poll(&mgr, 0);
|
||||
mg_mqtt_poll(&mgr);
|
||||
blink_task();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@
|
||||
#define MG_ENABLE_CUSTOM_RANDOM 1
|
||||
#define MG_OTA MG_OTA_RW612
|
||||
#define MG_TLS MG_TLS_BUILTIN
|
||||
#define MQTT_CLIENT_ID "rw612" // For tutorials/mqtt/mqtt-client
|
||||
|
||||
#define MG_ENABLE_MDASH 0 // Set to 1 to enable https://mdash.net
|
||||
#define MG_MDASH_KEY "..." // Edit, see https://mdash.net/docs/#mongoose-library
|
||||
#define MG_FIRMWARE_VERSION "1.0.1"
|
||||
#define MG_FIRMWARE_VERSION "rw612.1.0.1"
|
||||
|
||||
// #define MG_DRIVER_MDC_CR 51 // RMII MDC clock divider
|
||||
// #define MG_DRIVER_MDC_HOLDTIME 3 // RMII MDC Holdtime (valid values [0-7])
|
||||
|
||||
@@ -7,7 +7,7 @@ include(pico_sdk_import.cmake)
|
||||
project(firmware)
|
||||
pico_sdk_init()
|
||||
|
||||
add_executable(firmware main.c wifi.c ../../../mongoose.c)
|
||||
add_executable(firmware main.c wifi.c ../../../mongoose.c ../../mqtt/mqtt-client/mongoose_mqtt.c)
|
||||
target_include_directories(firmware PRIVATE ../../.. ./)
|
||||
|
||||
target_link_libraries(firmware pico_stdlib hardware_spi pico_rand pico_cyw43_driver pico_cyw43_arch_none hardware_flash pico_bootrom)
|
||||
|
||||
@@ -65,11 +65,13 @@ static void run_mongoose(void) {
|
||||
struct mg_mgr mgr;
|
||||
mg_log_set_fn(log_fn, NULL);
|
||||
mg_mgr_init(&mgr);
|
||||
mg_mqtt_init(&mgr);
|
||||
mg_http_listen(&mgr, "http://0.0.0.0", http_ev_handler, NULL);
|
||||
mg_http_listen(&mgr, "https://0.0.0.0", http_ev_handler, NULL);
|
||||
|
||||
for (;;) {
|
||||
mg_mgr_poll(&mgr, 1);
|
||||
mg_mqtt_poll(&mgr);
|
||||
blink_task();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#define MG_TLS MG_TLS_BUILTIN
|
||||
#define MG_OTA MG_OTA_PICOSDK
|
||||
#define MG_IO_SIZE 2048
|
||||
#define MQTT_CLIENT_ID "rp" // For tutorials/mqtt/mqtt-client
|
||||
|
||||
#define MG_ENABLE_TCPIP 1
|
||||
#define MG_ENABLE_DRIVER_PICO_W 1
|
||||
|
||||
@@ -259,6 +259,7 @@ void mg_dash_init(struct mg_mgr *mgr) {
|
||||
// Read settings from flash
|
||||
struct mg_dash_user u = {.level = 9}; // Super mega user
|
||||
settings_fn(MG_DASH_READ, &u);
|
||||
s_dash.authenticate = s_enable_login ? authenticate : NULL;
|
||||
|
||||
mg_mem_files = mg_packed_files;
|
||||
mg_http_listen(mgr, MG_HTTP_ADDR, mg_dash_ev_handler, &s_dash);
|
||||
|
||||
Reference in new issue
Block a user