Skip to content

Commit 363b8c7

Browse files
committed
replace std::string in Connection with c-string
1 parent d761742 commit 363b8c7

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/MicroOcppMongooseClient.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void MOcppMongooseClient::loop() {
109109
maintainWsConn();
110110
}
111111

112-
bool MOcppMongooseClient::sendTXT(std::string &out) {
112+
bool MOcppMongooseClient::sendTXT(const char *msg, size_t length) {
113113
if (!websocket || !isConnectionOpen()) {
114114
return false;
115115
}
@@ -119,14 +119,14 @@ bool MOcppMongooseClient::sendTXT(std::string &out) {
119119
sent = 0;
120120
return false;
121121
} else {
122-
mg_send_websocket_frame(websocket, WEBSOCKET_OP_TEXT, out.c_str(), out.length());
123-
sent = out.length();
122+
mg_send_websocket_frame(websocket, WEBSOCKET_OP_TEXT, msg, length);
123+
sent = length;
124124
}
125125
#else
126-
sent = mg_ws_send(websocket, out.c_str(), out.length(), WEBSOCKET_OP_TEXT);
126+
sent = mg_ws_send(websocket, msg, length, WEBSOCKET_OP_TEXT);
127127
#endif
128-
if (sent < out.length()) {
129-
MOCPP_DBG_WARN("mg_ws_send did only accept %zu out of %zu bytes", sent, out.length());
128+
if (sent < length) {
129+
MOCPP_DBG_WARN("mg_ws_send did only accept %zu out of %zu bytes", sent, length);
130130
//flush broken package and wait for next retry
131131
(void)0;
132132
}

src/MicroOcppMongooseClient.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class MOcppMongooseClient : public MicroOcpp::Connection {
7474

7575
void loop() override;
7676

77-
bool sendTXT(std::string &out) override;
77+
bool sendTXT(const char *msg, size_t length) override;
7878

7979
void setReceiveTXTcallback(MicroOcpp::ReceiveTXTcallback &receiveTXT) override {
8080
this->receiveTXTcallback = receiveTXT;

0 commit comments

Comments
 (0)