mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-23 11:44:53 +00:00
34 lines
868 B
C
34 lines
868 B
C
// Copyright (c) 2022 Cesanta Software Limited
|
|
// All rights reserved
|
|
|
|
#include "mongoose.h"
|
|
|
|
static void t_fn(void *arg) { // Tick periodically
|
|
MG_INFO(("tick"));
|
|
(void) arg;
|
|
}
|
|
|
|
static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
|
if (ev == MG_EV_HTTP_HDRS) {
|
|
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
|
if (mg_match(hm->uri, mg_str("/ota"), NULL)) {
|
|
mg_http_stream_body(c, hm, mg_http_ota_cb, NULL);
|
|
}
|
|
} else if (ev == MG_EV_HTTP_MSG) mg_http_reply(c, 200, "", "hi\n");
|
|
(void) ev_data;
|
|
}
|
|
|
|
static struct mg_mgr mgr;
|
|
|
|
void mgmp_init(void) {
|
|
mg_mgr_init(&mgr); // Mongoose event manager
|
|
mg_log_set(MG_LL_DEBUG); // Set log level
|
|
|
|
mg_timer_add(&mgr, 1000, MG_TIMER_REPEAT, t_fn, &mgr);
|
|
mg_http_listen(&mgr, "http://0.0.0.0:80", fn, &mgr);
|
|
}
|
|
|
|
void mgmp_poll(int t) {
|
|
mg_mgr_poll(&mgr, t);
|
|
}
|