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 ?
nliviu
December 15, 2020, 7:33am
2
If mqtt.enable
is set to true, the mqtt library takes care of connecting with the MQTT broker specified by mqtt.server
.
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 ?
nliviu
December 15, 2020, 7:48pm
4
mgos_sys_config_get_device_id()
- ota-common
- vfs-*
tags:
- c
- core
- docs:core:Core meta-library
config_schema:
- ["device", "o", {title: "Device settings"}]
- ["device.id", "s", {title: "Device ID"}] # Note: Each arch defines a default
- ["device.license", "s", {title: "License code"}]
- ["device.mac", "s", "", {title: "user/custom defined mac address"}]
- ["device.public_key", "s", "", {title: "Key for the restricted access"}]
- ["device.sn", "s", "", {title: "Serial number"}]
- ["debug", "o", {title: "Debug Settings"}]
- ["debug.level", "i", 2, {title: "Debug Level"}]
- ["debug.file_level", "s", "", {title: "Log file level specification: file=level,file=level,...; see cs_log_set_file_level()"}]
- ["debug.event_level", "i", 2, {title: "Max level for which a MGOS_EVENT_LOG is raised"}]
- ["debug.stdout_uart", "i", 0, {title: "STDOUT UART (-1 to disable)"}]
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()”
nliviu
December 16, 2020, 4:39am
6
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()