Skip to content

Commit 1ed8e20

Browse files
authored
Upgrade mongoose (#30)
* upgrade mongoose * upgrade MO-Mongoose
1 parent 0526495 commit 1ed8e20

File tree

5 files changed

+14
-13
lines changed

5 files changed

+14
-13
lines changed

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ add_compile_definitions(
3636
MO_ENABLE_V201=1
3737
MO_ENABLE_MBEDTLS=1
3838
MO_ENABLE_TIMESTAMP_MILLISECONDS=1
39+
MO_MG_USE_VERSION=MO_MG_V715
3940
)
4041

4142
add_executable(mo_simulator ${MO_SIM_SRC} ${MO_SIM_MG_SRC})

lib/mongoose

Submodule mongoose updated 3743 files

src/net_mongoose.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,27 @@ char* toStringPtr(std::string cppString){
2727
return cstr;
2828
}
2929

30-
void http_serve(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
30+
void http_serve(struct mg_connection *c, int ev, void *ev_data) {
3131
if (ev == MG_EV_HTTP_MSG) {
3232
//struct mg_http_message *message_data = (struct mg_http_message *) ev_data;
3333
struct mg_http_message *message_data = reinterpret_cast<struct mg_http_message *>(ev_data);
3434
const char *final_headers = DEFAULT_HEADER CORS_HEADERS;
3535
struct mg_str json = message_data->body;
3636

37-
MO_DBG_VERBOSE("%.*s", 20, message_data->uri.ptr);
37+
MO_DBG_VERBOSE("%.*s", 20, message_data->uri.buf);
3838

3939
MicroOcpp::Method method = MicroOcpp::Method::UNDEFINED;
4040

41-
if (!mg_vcasecmp(&message_data->method, "POST")) {
41+
if (!mg_strcasecmp(message_data->method, mg_str("POST"))) {
4242
method = MicroOcpp::Method::POST;
4343
MO_DBG_VERBOSE("POST");
44-
} else if (!mg_vcasecmp(&message_data->method, "GET")) {
44+
} else if (!mg_strcasecmp(message_data->method, mg_str("GET"))) {
4545
method = MicroOcpp::Method::GET;
4646
MO_DBG_VERBOSE("GET");
4747
}
4848

4949
//start different api endpoints
50-
if(mg_http_match_uri(message_data, "/api/websocket")){
50+
if(mg_match(message_data->uri, mg_str("/api/websocket"), NULL)){
5151
MO_DBG_VERBOSE("query websocket");
5252
auto webSocketPingIntervalInt = MicroOcpp::declareConfiguration<int>("WebSocketPingInterval", 10, MO_WSCONN_FN);
5353
auto reconnectIntervalInt = MicroOcpp::declareConfiguration<int>(MO_CONFIG_EXT_PREFIX "ReconnectInterval", 30, MO_WSCONN_FN);
@@ -91,23 +91,23 @@ void http_serve(struct mg_connection *c, int ev, void *ev_data, void *fn_data) {
9191
serializeJson(doc, serialized);
9292
mg_http_reply(c, 200, final_headers, serialized.c_str());
9393
return;
94-
} else if (strncmp(message_data->uri.ptr, "/api", strlen("api")) == 0) {
94+
} else if (strncmp(message_data->uri.buf, "/api", strlen("api")) == 0) {
9595
#define RESP_BUF_SIZE 1024
9696
char resp_buf [RESP_BUF_SIZE];
9797

9898
//replace endpoint-body separator by null
99-
if (char *c = strchr((char*) message_data->uri.ptr, ' ')) {
99+
if (char *c = strchr((char*) message_data->uri.buf, ' ')) {
100100
*c = '\0';
101101
}
102102

103103
int status = mocpp_api_call(
104-
message_data->uri.ptr + strlen("/api"),
104+
message_data->uri.buf + strlen("/api"),
105105
method,
106-
message_data->body.ptr,
106+
message_data->body.buf,
107107
resp_buf, RESP_BUF_SIZE);
108108

109109
mg_http_reply(c, status, final_headers, resp_buf);
110-
} else if (mg_http_match_uri(message_data, "/")) { //if no specific path is given serve dashboard application file
110+
} else if (mg_match(message_data->uri, mg_str("/"), NULL)) { //if no specific path is given serve dashboard application file
111111
struct mg_http_serve_opts opts;
112112
memset(&opts, 0, sizeof(opts));
113113
opts.root_dir = "./public";

src/net_mongoose.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class MOcppMongooseClient;
1515

1616
void server_initialize(MicroOcpp::MOcppMongooseClient *osock);
1717

18-
void http_serve(struct mg_connection *c, int ev, void *ev_data, void *fn_data);
18+
void http_serve(struct mg_connection *c, int ev, void *ev_data);
1919

2020
#endif //MO_NETLIB == MO_NETLIB_MONGOOSE
2121

0 commit comments

Comments
 (0)