In a C native module, I want to call other jswrap functions and asign my C function as the callback.
How to do that?
jswrap_net_connect(JsVar *options, JsVar *callback, SocketType socketType); // here I want asign mycallback( ) as the callback
You need to do something like this: github.com/espruino/Espruino/blob/master/src/jswrap_promise.c#L83
Note the JSWAT_* enums determine what arguments the function takes. Just use JSWAT_VOID in your case.
Is there a document which explains the usage of jsvLock and jsvUlock?
Or, some documets describe the mechanism of native code?
Not really, no. You'd need to look at other code, or there are some good threads on this forum. Also worth looking at espruino.com/Internals
However, I can't assist you - especially as you're not using one of the official Espruino boards. If you're doing this for a company and they need assistance then I can do consultancy work.
Thanks a lot.
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem