Community news, upcoming events and general discussions
Threads: 36 Posts: 88
Get technical support from the community
Threads: 1416 Posts: 7560
Threads: 18 Posts: 64
Tell us how to make XDK better!
Threads: 36 Posts: 119
Share and discuss community member projects
Threads: 78 Posts: 343
I'm working since a few days with mita. My goal is to send the sensor data to a broker via MQTT. The Connection to WiFi and also MQTT is working already.
Now I want into the payload of the messages next to the sensor value also a timestamp.
While searching how to integrate a the timestamp I found 'this'.
I have copied the code for "systime.h" as described.
Also the right timestamp is printed into the console. Therefore I'm sure the connection to the SNTP-Server is also working.
But now to my Problem, I have no idea how to get the timestamp from the c-file into the mita file.
It would be nice, if someone knows how to declare the timestamp that it is callable in mita.
Thanks in advance!
Here is a description of how to make a function written in native C known to Mita: https://www.eclipse.org/mita/language/foreignfunctioninterface/#native-functions
I've had the same problem like you just some days ago. For me, the easiest way was to build return functions in C, which just return the timestamp saved in a global variable in the sourcefile of your timeSetup() function as a uint32_t. This way, if you call that function in Mita, you receive the return value without any problems.
I hope this helped.