Skip to content

Commit

Permalink
fix WASM compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
matth-x committed May 23, 2024
1 parent 9145f76 commit 5921bf9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ target_compile_definitions(mo_simulator PUBLIC
add_subdirectory(lib/MicroOcpp)
target_link_libraries(mo_simulator PUBLIC MicroOcpp)

# disable some warnings for MbedTLS which cause compilation errors on WASM
if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
add_compile_options(
-Wno-unused-but-set-variable
-Wno-documentation
)
endif()

# disable MbedTLS unit tests and test suites (not needed for the Simualtor)
option(ENABLE_TESTING "Build mbed TLS tests." OFF)
option(ENABLE_PROGRAMS "Build mbed TLS programs." OFF)
Expand Down
15 changes: 1 addition & 14 deletions src/net_wasm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <MicroOcpp/Core/Connection.h>
#include <MicroOcpp/Core/Configuration.h>
#include <MicroOcpp/Debug.h>
#include "base64.hpp"

#include "api.h"

Expand Down Expand Up @@ -308,19 +307,7 @@ class WasmOcppConnection : public Connection {
}

if (!auth_key.empty()) {
std::string token = cb_id + ":" + auth_key;

MO_DBG_DEBUG("auth Token=%s", token.c_str());

unsigned int base64_length = encode_base64_length(token.length());
std::vector<unsigned char> base64 (base64_length + 1);

// encode_base64() places a null terminator automatically, because the output is a string
base64_length = encode_base64((const unsigned char*) token.c_str(), token.length(), &base64[0]);

MO_DBG_DEBUG("auth64 len=%u, auth64 Token=%s", base64_length, &base64[0]);

basic_auth64 = (const char*) &base64[0];
MO_DBG_WARN("WASM app does not support Securiy Profile 2 yet");
} else {
MO_DBG_DEBUG("no authentication");
(void) 0;
Expand Down

0 comments on commit 5921bf9

Please sign in to comment.