mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-30 12:50:58 +00:00
CS_DISABLE_(STDIO|HEXDUMP) -> CS_ENABLE_$1
PUBLISHED_FROM=9fd0cebfa8df53b5d9574a8d013305ddda5e7a18
This commit is contained in:
1 parent
618bef0eb2
commit
241090a82b
9 files changed
+140
-110
No files matched your search
@@ -6,10 +6,18 @@
|
||||
#ifndef CS_COMMON_CS_DBG_H_
|
||||
#define CS_COMMON_CS_DBG_H_
|
||||
|
||||
#if !CS_DISABLE_STDIO
|
||||
#if CS_ENABLE_STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef CS_ENABLE_DEBUG
|
||||
#define CS_ENABLE_DEBUG 0
|
||||
#endif
|
||||
|
||||
#ifndef CS_LOG_TS_DIFF
|
||||
#define CS_LOG_TS_DIFF 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
@@ -28,7 +36,7 @@ enum cs_log_level {
|
||||
|
||||
void cs_log_set_level(enum cs_log_level level);
|
||||
|
||||
#if !CS_DISABLE_STDIO
|
||||
#if CS_ENABLE_STDIO
|
||||
|
||||
void cs_log_set_file(FILE *file);
|
||||
|
||||
@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
#else /* CS_DISABLE_STDIO */
|
||||
#else /* CS_ENABLE_STDIO */
|
||||
|
||||
#define LOG(l, x)
|
||||
#define DBG(x)
|
||||
|
||||
Executable
+10
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
docker run \
|
||||
--rm -i -v $(realpath ${PWD}/../..):/src \
|
||||
--entrypoint=/bin/bash $(cat sdk.version) -l -c -x '
|
||||
export SDK_PATH=/opt/Espressif/ESP8266_SDK;
|
||||
export BIN_PATH=./bin;
|
||||
cd /src/examples/ESP8266_RTOS &&
|
||||
mkdir -p ./bin && make clean &&
|
||||
make BOOT=none APP=0 SPI_SPEED=40 SPI_MODE=qio SPI_SIZE_MAP=0'
|
||||
@@ -0,0 +1 @@
|
||||
docker.cesanta.com/esp8266-build-rtos:1.4.0-r2
|
||||
@@ -1 +0,0 @@
|
||||
./../../../../common/cs_dbg.h
|
||||
@@ -6,7 +6,6 @@
|
||||
#include "esp_common.h"
|
||||
|
||||
#include "mongoose.h"
|
||||
#include "cs_dbg.h"
|
||||
|
||||
#define AP_SSID "Mongoose"
|
||||
#define AP_PASS "Mongoose"
|
||||
@@ -25,14 +24,13 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) {
|
||||
"Content-Type: text/plain\r\n"
|
||||
"\r\n"
|
||||
"Hello %s\n";
|
||||
LOG(LL_DEBUG, ("conn %p ev %d", nc, 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);
|
||||
LOG(LL_INFO, ("Connection %p from %s", nc, addr));
|
||||
printf("Connection %p from %s\n", nc, addr);
|
||||
break;
|
||||
}
|
||||
case MG_EV_HTTP_REQUEST: {
|
||||
@@ -40,15 +38,14 @@ void ev_handler(struct mg_connection *nc, int ev, void *p) {
|
||||
struct http_message *hm = (struct http_message *) p;
|
||||
mg_sock_addr_to_str(&nc->sa, addr, sizeof(addr),
|
||||
MG_SOCK_STRINGIFY_IP | MG_SOCK_STRINGIFY_PORT);
|
||||
LOG(LL_INFO,
|
||||
("HTTP request from %s: %.*s %.*s", addr, (int) hm->method.len,
|
||||
hm->method.p, (int) hm->uri.len, hm->uri.p));
|
||||
printf("HTTP request from %s: %.*s %.*s\n", addr, (int) hm->method.len,
|
||||
hm->method.p, (int) hm->uri.len, hm->uri.p);
|
||||
mg_printf(nc, reply_fmt, addr);
|
||||
nc->flags |= MG_F_SEND_AND_CLOSE;
|
||||
break;
|
||||
}
|
||||
case MG_EV_CLOSE: {
|
||||
LOG(LL_INFO, ("Connection %p closed", nc));
|
||||
printf("Connection %p closed\n", nc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -71,30 +68,28 @@ void setup_ap(void) {
|
||||
cfg.max_connection = 10;
|
||||
cfg.beacon_interval = 100; /* ms */
|
||||
|
||||
LOG(LL_INFO, ("Setting up AP '%s' on channel %d", cfg.ssid, cfg.channel));
|
||||
printf("Setting up AP '%s' on channel %d\n", cfg.ssid, cfg.channel);
|
||||
wifi_softap_set_config_current(&cfg);
|
||||
wifi_softap_dhcps_stop();
|
||||
wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &off);
|
||||
wifi_softap_dhcps_start();
|
||||
wifi_get_ip_info(SOFTAP_IF, &info);
|
||||
LOG(LL_INFO, ("WiFi AP: SSID %s, channel %d, IP " IPSTR "", cfg.ssid,
|
||||
cfg.channel, IP2STR(&info.ip)));
|
||||
printf("WiFi AP: SSID %s, channel %d, IP " IPSTR "\n", cfg.ssid, cfg.channel,
|
||||
IP2STR(&info.ip));
|
||||
}
|
||||
|
||||
static void mg_task(void *arg) {
|
||||
struct mg_mgr mgr;
|
||||
struct mg_connection *nc;
|
||||
|
||||
cs_log_set_level(LL_INFO);
|
||||
|
||||
LOG(LL_INFO, ("SDK version: %s", system_get_sdk_version()));
|
||||
printf("SDK version: %s\n", system_get_sdk_version());
|
||||
setup_ap();
|
||||
|
||||
mg_mgr_init(&mgr, NULL);
|
||||
|
||||
nc = mg_bind(&mgr, MG_LISTEN_ADDR, ev_handler);
|
||||
if (nc == NULL) {
|
||||
LOG(LL_ERROR, ("Error setting up listener!"));
|
||||
printf("Error setting up listener!\n");
|
||||
return;
|
||||
}
|
||||
mg_set_protocol_http_websocket(nc);
|
||||
|
||||
@@ -6,10 +6,18 @@
|
||||
#ifndef CS_COMMON_CS_DBG_H_
|
||||
#define CS_COMMON_CS_DBG_H_
|
||||
|
||||
#if !CS_DISABLE_STDIO
|
||||
#if CS_ENABLE_STDIO
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#ifndef CS_ENABLE_DEBUG
|
||||
#define CS_ENABLE_DEBUG 0
|
||||
#endif
|
||||
|
||||
#ifndef CS_LOG_TS_DIFF
|
||||
#define CS_LOG_TS_DIFF 0
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
@@ -28,7 +36,7 @@ enum cs_log_level {
|
||||
|
||||
void cs_log_set_level(enum cs_log_level level);
|
||||
|
||||
#if !CS_DISABLE_STDIO
|
||||
#if CS_ENABLE_STDIO
|
||||
|
||||
void cs_log_set_file(FILE *file);
|
||||
|
||||
@@ -56,7 +64,7 @@ void cs_log_printf(const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
||||
#else /* CS_DISABLE_STDIO */
|
||||
#else /* CS_ENABLE_STDIO */
|
||||
|
||||
#define LOG(l, x)
|
||||
#define DBG(x)
|
||||
|
||||
Reference in new issue
Block a user