1

Iam working yet with C program on STM32 microproc, what contains a web server, accesible by the user via web gui(HTML and javascript files). The web gui part became more complex, and it needs higher level operations.

The questions: is it possible to embed a node.js program with some node modules? Does it work with the C webserver, or the node program have to make the webserver, and communicate with the C program?
Or there is an other solution what is better in this case?

This question maybe seems dumb, but i didnt find documentation about it.

RPeti
  • 43
  • 1
  • 2
  • 9
  • Hope this [article](https://medium.com/@tarkus/how-to-call-c-c-code-from-node-js-86a773033892) give you intuition about how to interop C and Javascript. – Milind Deore Jan 19 '18 at 09:18
  • @MilindDeore my understand is that he wants to run nodeJS on C based app. Oposite than your article shows. – unalignedmemoryaccess Jan 19 '18 at 10:09
  • Hi @MilindDeore as tilz0R say, the article switch the roles between the prog languages. In my case there is a big and complex C program running on the STM32, and it contains a small JS+HTML part what makes the webgui. I want to change this part to a "smarter" solution. – RPeti Jan 19 '18 at 10:30

1 Answers1

2

After a research I found some solutions:

Node.js for Embedded Systems

The book can then guide you to jerryscript which:

is a lightweight JavaScript engine for resource-constrained devices such as microcontrollers

You can find there that it's also used with the STM32-Discovery board.

Node.js on clientside

This article guides to Browserify which allows to run node on clientside.

Just make it simpler

You could use HTTPD implementation shipped with LwIP. There is a script called makefsdata which allows to convert html, js, css ... files into c-arrays. This implementation also supports POST method.

K. Koovalsky
  • 596
  • 4
  • 17
  • Thank you for the tip, after some reading the github article seems useful, i go further and try to implement it. The simpler solution what you commend, is the yet used solution (LwIP, older version). It works well, but its hard for me to make higher lvl JS logic, and i thought Node.js modules can help me. – RPeti Jan 19 '18 at 10:35