Skip to content

Commit

Permalink
clean compilation, prints, and gitignore
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-rabault committed Feb 13, 2024
1 parent 87ccf71 commit 7677e98
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ examples/projects/ESP32/button/sdkconfig.esp32dev
examples/projects/ESP32/led/sdkconfig.esp32dev
tool_services/pipe/WS/ARDUINO/arduinoWebSockets/
mongoose/
examples/projects/browser/**/node_modules/
*.pyc
2 changes: 1 addition & 1 deletion engine/HAL/BROWSER/hal_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

for e in [env, genv]:
# Add the cheerp-wasm target to the compiler flags
e.Append(CCFLAGS=["--target=cheerp-wasm", "-Wno-cheerp", "-cheerp-make-module=commonjs", "-DPUBLIC=__attribute__\(\(cheerp_jsexport\)\)"])
e.Append(CCFLAGS=["--target=cheerp-wasm", "-Wno-cheerp", "-DPUBLIC=__attribute__\(\(cheerp_jsexport\)\)"])

# Add the cheerp-wasm target to the linker flags
e.Append(LINKFLAGS=["--target=cheerp-wasm", "-cheerp-make-module=commonjs", "-cheerp-pretty-code"])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "led.h"
#include <stdlib.h>

#include <cheerp/clientlib.h>

/*******************************************************************************
* Definitions
******************************************************************************/
Expand Down Expand Up @@ -55,12 +57,8 @@ static void Led_MsgHandler(service_t *service, const msg_t *msg);

void clear_screen(void)
{
#ifdef _WIN32
system("cls");
#else
// Assume POSIX
system("clear");
#endif
// clear the console
printf("\x1B[2J\x1B[H");
}

/******************************************************************************
Expand Down
9 changes: 3 additions & 6 deletions network/ws_network/HAL/BROWSER/ws_hal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,17 @@ static const char *s_url = WS_NETWORK_BROKER_ADDR;

[[cheerp::genericjs]] void openEventCallback()
{
console.log("Websocket opened!");
console.log("Websocket opened on", s_url);
}

[[cheerp::genericjs]] void closeEventCallback()
{
console.log("Websocket closed!");
console.log("Websocket closed.");
}

[[cheerp::genericjs]] void errorEventCallback()
{
console.log("Websocket error!");
console.log("Websocket error.");
}

void WsHAL_ReceptionWeb(const std::vector<uint8_t> &data)
Expand All @@ -65,7 +65,6 @@ void WsHAL_ReceptionWeb(const std::vector<uint8_t> &data)

[[cheerp::genericjs]] void WsHAL_InitWeb()
{
console.log("TEST!", s_url);
__asm__("const WebSocket = require('ws')");
clientWebsocket = new WebSocket(s_url);
clientWebsocket->addEventListener(
Expand All @@ -83,7 +82,6 @@ void WsHAL_ReceptionWeb(const std::vector<uint8_t> &data)
cheerp::Callback(
[](MessageEvent *e)
{
console.log("message");
auto *dataArray = (Uint8Array *)e->get_data();
std::vector<uint8_t> wasmData(dataArray->get_length()); // allocate some linear memory
Uint8Array *wasmDataArray = cheerp::MakeTypedArray(wasmData.data(), wasmData.size()); // create a Uint8Array wrapper ove the linear memory held by the vector
Expand All @@ -110,7 +108,6 @@ void WsHAL_Init(void)
* @param None
* @return None
******************************************************************************/
PUBLIC
void WsHAL_Loop(void)
{
// Nothing to do here
Expand Down

0 comments on commit 7677e98

Please sign in to comment.