You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't know how many native functions I need to add in order to connect to some TCP ports.
You would likely want to find a C or C++ library that handles networking. If you don't already have one in your firmware, I can recommend trying Mongoose. You can then integrate with the Mongoose API using something like the Microvium FFI example library.
Depending on your level of experience, you could wrap Mongoose into a Microvium library for others to use as well. Similar to how the Microvium FFI example library is able to produce C++ code at compile time and then link to it at runtime, a Mongoose wrapper library can "generate" the Mongoose C++ code (i.e. just fs.writeFileSync to dump the Mongoose files to disk) as well as all the JavaScript-to-C++ bindings. I'll probably do this at some point if nobody else does, but since it doesn't require any additional engine capabilities, it's a library that in theory anyone can write (and I'm happy to advise and help with the design).
Having said that, even if you just do basic integration for your own project, I'm happy to help. Just let me know where you get stuck.
@radiocom, it's not really clear what the right abstraction is for your use case, without knowing what it is. Generally, anything that has raw access to TCP sockets needs to do buffering of messages and parsing. This is likely to stress the Microvium heap quite a bit. Exposing higher-level network protocols requires a lot less work in the JavaScript, but more on the integration side. For example, something like MQTT might be exposed as a simple callback for handling an event and a function for publishing to a specific node, so a small amount of JavaScript on the device can drive a lot of policy and not require you to reimplement an efficient C/C++ MQTT client library in interpreted JavaScript.
I don't know how many native functions I need to add in order to connect to some TCP ports.
we need some demos like the ffi module, thanks.
The text was updated successfully, but these errors were encountered: