mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-23 18:49:01 +08:00
commit
1f481cbe54
@ -21,4 +21,4 @@ CONFIG_IDLE_STACK_SIZE=1024
|
||||
|
||||
CONFIG_MINIMAL_LIBC=y
|
||||
CONFIG_MINIMAL_LIBC_RAND=y
|
||||
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=32768
|
||||
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32768
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "mongoose.h"
|
||||
#include "net.h"
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
// Zephyr: Define a semaphore and network management callback to be able to wait
|
||||
// until our IP address is ready. The main function will start and block on this
|
||||
|
@ -1,4 +1,3 @@
|
||||
#define MG_ARCH MG_ARCH_ZEPHYR
|
||||
|
||||
#define MG_ENABLE_PACKED_FS 1
|
||||
#define MG_TLS MG_TLS_MBED
|
||||
|
@ -20,13 +20,16 @@ CONFIG_IDLE_STACK_SIZE=1024
|
||||
CONFIG_MBEDTLS=y
|
||||
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=4096
|
||||
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
|
||||
CONFIG_MBEDTLS_ECDH_C=y
|
||||
CONFIG_MBEDTLS_ECDSA_C=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
|
||||
CONFIG_MBEDTLS_ECP_C=y
|
||||
CONFIG_MBEDTLS_ECP_ALL_ENABLED=y
|
||||
CONFIG_MBEDTLS_TLS_VERSION_1_2=y
|
||||
|
||||
CONFIG_MINIMAL_LIBC=y
|
||||
CONFIG_MINIMAL_LIBC_RAND=y
|
||||
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=131072
|
||||
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072
|
||||
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_MBEDTLS_DEBUG=y
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "certs.h"
|
||||
#include "mongoose.h"
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
static time_t s_boot_timestamp = 0;
|
||||
static struct mg_connection *s_sntp_conn = NULL;
|
||||
|
@ -20,9 +20,13 @@ CONFIG_IDLE_STACK_SIZE=1024
|
||||
CONFIG_MBEDTLS=y
|
||||
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048
|
||||
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
|
||||
CONFIG_MBEDTLS_ECDH_C=y
|
||||
CONFIG_MBEDTLS_ECDSA_C=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
|
||||
CONFIG_MBEDTLS_ECP_C=y
|
||||
CONFIG_MBEDTLS_ECP_ALL_ENABLED=y
|
||||
CONFIG_MBEDTLS_TLS_VERSION_1_2=y
|
||||
|
||||
CONFIG_MINIMAL_LIBC=y
|
||||
CONFIG_MINIMAL_LIBC_RAND=y
|
||||
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=32756
|
||||
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32756
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "certs.h"
|
||||
#include "mongoose.h"
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
static const char *s_web_dir = "/";
|
||||
static const char *s_http_addr = "http://0.0.0.0:8000";
|
||||
@ -13,7 +14,7 @@ static struct mg_connection *s_sntp_conn = NULL;
|
||||
// Event handler for the listening HTTP/HTTPS connection.
|
||||
static void wcb(struct mg_connection *c, int ev, void *ev_data) {
|
||||
if (ev == MG_EV_ACCEPT && c->fn_data != NULL) {
|
||||
struct mg_tls_opts opts = {.cert = s_ssl_cert, .key = s_ssl_key};
|
||||
struct mg_tls_opts opts = {.cert = (char *) s_ssl_cert, .key = (char *) s_ssl_key};
|
||||
mg_tls_init(c, &opts);
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = ev_data;
|
||||
@ -85,9 +86,8 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
struct mg_mgr mgr;
|
||||
|
||||
mg_log_set(MG_LL_DEBUG);
|
||||
|
||||
mg_mgr_init(&mgr);
|
||||
mg_log_set(MG_LL_DEBUG);
|
||||
mg_http_listen(&mgr, s_http_addr, wcb, NULL);
|
||||
mg_http_listen(&mgr, s_https_addr, wcb, &mgr);
|
||||
|
||||
|
@ -20,13 +20,16 @@ CONFIG_IDLE_STACK_SIZE=1024
|
||||
CONFIG_MBEDTLS=y
|
||||
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=8192
|
||||
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
|
||||
CONFIG_MBEDTLS_ECDH_C=y
|
||||
CONFIG_MBEDTLS_ECDSA_C=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
|
||||
CONFIG_MBEDTLS_ECP_C=y
|
||||
CONFIG_MBEDTLS_ECP_ALL_ENABLED=y
|
||||
CONFIG_MBEDTLS_TLS_VERSION_1_2=y
|
||||
|
||||
CONFIG_MINIMAL_LIBC=y
|
||||
CONFIG_MINIMAL_LIBC_RAND=y
|
||||
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=131072
|
||||
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=131072
|
||||
|
||||
CONFIG_PRINTK=y
|
||||
CONFIG_MBEDTLS_DEBUG=y
|
||||
|
@ -3,13 +3,13 @@
|
||||
|
||||
#include "certs.h"
|
||||
#include "mongoose.h"
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
struct mg_mgr mgr;
|
||||
|
||||
static time_t s_boot_timestamp = 0;
|
||||
static struct mg_connection *s_sntp_conn = NULL;
|
||||
static const char *s_url =
|
||||
"mqtts://a3nkain3cvvy7l-ats.iot.us-east-1.amazonaws.com";
|
||||
static const char *s_url = "mqtts://a3nkain3cvvy7l-ats.iot.us-east-1.amazonaws.com";
|
||||
|
||||
static const char *s_rx_topic = "d/rx";
|
||||
static const char *s_tx_topic = "d/tx";
|
||||
@ -24,7 +24,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
MG_ERROR(("%p %s", c->fd, (char *) ev_data));
|
||||
} else if (ev == MG_EV_CONNECT) {
|
||||
// Set up 2-way TLS that is required by AWS IoT
|
||||
struct mg_tls_opts opts = {.ca = s_ca, .cert = s_cert, .key = s_key};
|
||||
struct mg_tls_opts opts = {.ca = (char *) s_ca, .cert = (char *) s_cert, .key = (char *) s_key};
|
||||
mg_tls_init(c, &opts);
|
||||
} else if (ev == MG_EV_MQTT_OPEN) {
|
||||
// MQTT connect is successful
|
||||
|
@ -20,9 +20,13 @@ CONFIG_IDLE_STACK_SIZE=1024
|
||||
CONFIG_MBEDTLS=y
|
||||
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=2048
|
||||
CONFIG_MBEDTLS_PEM_CERTIFICATE_FORMAT=y
|
||||
CONFIG_MBEDTLS_ECDH_C=y
|
||||
CONFIG_MBEDTLS_ECDSA_C=y
|
||||
CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED=y
|
||||
CONFIG_MBEDTLS_ECP_C=y
|
||||
CONFIG_MBEDTLS_ECP_ALL_ENABLED=y
|
||||
CONFIG_MBEDTLS_TLS_VERSION_1_2=y
|
||||
|
||||
CONFIG_MINIMAL_LIBC=y
|
||||
CONFIG_MINIMAL_LIBC_RAND=y
|
||||
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=32756
|
||||
CONFIG_COMMON_LIBC_MALLOC_ARENA_SIZE=32756
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "certs.h"
|
||||
#include "mongoose.h"
|
||||
#include <zephyr/net/net_mgmt.h>
|
||||
|
||||
static const char *s_web_dir = "/";
|
||||
static const char *s_ws_addr = "ws://0.0.0.0:8000";
|
||||
@ -17,7 +18,7 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) {
|
||||
if (ev == MG_EV_OPEN) {
|
||||
c->is_hexdumping = 1;
|
||||
} else if (ev == MG_EV_ACCEPT && c->fn_data != NULL) {
|
||||
struct mg_tls_opts opts = {.cert = s_ssl_cert, .key = s_ssl_key};
|
||||
struct mg_tls_opts opts = {.cert = (char *) s_ssl_cert, .key = (char *) s_ssl_key};
|
||||
mg_tls_init(c, &opts);
|
||||
} else if (ev == MG_EV_HTTP_MSG) {
|
||||
struct mg_http_message *hm = (struct mg_http_message *) ev_data;
|
||||
|
Loading…
Reference in New Issue
Block a user