Private MQTT example in c

#1

Currently I am using JS to perform the MQTT (private server) connection
it is working by using the setting in “mos.yml”

config_schema:

  • [“mqtt.server”, “192.168.1.4:1883”]
  • [“mqtt.enable”, true]
  • [“mqtt.max_queue_length”, 10]

libs:

Would like to know any example Application available for MQTT in C code ?
I am able to get WiFi connected by setting parameters in “config_schema”
Any specific code I need to call to start the MQTT server connection ?

#2

If mqtt.enable is set to true, the mqtt library takes care of connecting with the MQTT broker specified by mqtt.server.

#3

It works after I reboot the device again… not sure why not working before.
On a some what related subject.
I try to read back the “device.id” from the config_schema,
the example in JS is simple :
https://mongoose-os.com/docs/mongoose-os/api/core/mgos_sys_config.h.md

load('api_config.js');
Cfg.get('device.id');        // returns a string

But how do I do the same in C API ?

#4

mgos_sys_config_get_device_id()

#5

Thanks for info.
Since I still new to the platform, in general how could I search for available API calls ? other than open
In this case, “mgos_sys_config_get_device_id()”

#6

Configuration infrastructure

#7

Thanks.
If I want to read real time setting of the WiFi, how should I do it ?

I tried the function below but it read back the setting in “config_schema:” only
mgos_sys_config_get_wifi_ap_enable()