Mita with Sntp and MQTT
Antwort
13.08.19 06:23

Hello community,

 

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!

Felix

0 (0 Stimmen)
RE: Mita with Sntp and MQTT
Antwort
13.08.19 07:46 als Antwort auf Felix Kühn.

Hi Felilx,

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

regards

Saeid

0 (0 Stimmen)
RE: Mita with Sntp and MQTT
Antwort
16.09.19 11:07 als Antwort auf Saeid Kajlar.

Hi Felix,

 

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.

0 (0 Stimmen)