/* * Copyright (c) 2014-2016 Cesanta Software Limited * All rights reserved */ #include "bleconfig.h" #include "myboard.h" #include "mongoose.h" /* * This is a callback invoked by Mongoose to signal that a poll is needed soon. * Since we're in a tight polling loop anyway (see below), we don't need to do * anything. */ void mg_lwip_mgr_schedule_poll(struct mg_mgr *mgr) { } // Define an event handler function void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { if (ev == MG_EV_POLL) return; /* printf("ev %d\r\n", ev); */ switch (ev) { case MG_EV_ACCEPT: { char addr[32]; mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr), MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT); printf("%p: Connection from %s\r\n", nc, addr); break; } case MG_EV_HTTP_REQUEST: { struct http_message *hm = (struct http_message *) ev_data; char addr[32]; mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr), MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT); printf("%p: %.*s %.*s\r\n", nc, (int) hm->method.len, hm->method.p, (int) hm->uri.len, hm->uri.p); mg_send_response_line(nc, 200, "Content-Type: text/html\r\n" "Connection: close"); mg_printf(nc, "\r\n