I have a question for how to call void method with String args. I believe mOS has mg_str
but why it’s not possible to code like arduino. And how I have to do it properly.
If you want to follow an old fart advice, wash your brain from Arduino and learn standard stuff.
There are no strings in C, only arrays of chars that (must) end with a null.
In C, you print using printf(), I suggest you pay a visit to Kernighan and Ritchie’s “The C Programming Language”. mg_str is a proprietary construction in mOS (Mongoose-OS), it is a structure holding a pointer to the array and also its length. There are examples on how to use it in the docs.
C++ has a String type, and afaik (I don’t do C++) you can use stream syntax to print. Don’t know if that works in mOS, it should. (Bjarne Stroustrup’s book is perhaps too involved)
Perhaps the easiest way to print text in mOS is to use the LOG macros, check how examples and libraries do it.
#include "mgos.h"
LOG(LL_INFO, ("This is the text I want to print"));
ok thanks you. I just don’t have much time to learn C.
our production code are quite simple because we dev on arduino compatible. But not dev on Arduino framework. I just have a problem about chip stock shortage so I have to migrate hw and fw into reliable platform like mOS+ESP32.