I’m problem because only send 1 message one time, and never send again, i’m studying mongoos recently but i didn’t found a example whit make this easy.
mos.yml:
config_schema:
# NB: mqtt and mqtt1 must be identical.
- ["mqtt", "o", {title: "MQTT settings"}]
- ["mqtt.enable", "b", true, {title: "Enable MQTT"}]
- ["mqtt.server", "s", "192.168.1.8:1883", {title: "MQTT server"}]
- ["mqtt.client_id", "s", "", {title: "ClientID t send to the broker. Defaults to device.id."}]
- ["mqtt.user", "s", "------", {title: "User name"}]
- ["mqtt.pass", "s", "------", {title: "Password"}]
- ["mqtt.reconnect_timeout_min", "d", 2.0, {title: "Starting reconnect timeout"}]
- ["mqtt.reconnect_timeout_max", "d", 60.0, {title: "Maximum reconnect timeout"}]
- ["mqtt.ssl_cert", "s", "", {title: "Client certificate to present to the server"}]
- ["mqtt.ssl_key", "s", "", {title: "Private key corresponding to the certificate"}]
- ["mqtt.ssl_ca_cert", "s", "", {title: "Verify server certificate using this CA bundle"}]
- ["mqtt.ssl_cipher_suites", "s", "", {title: "Cipher suites to offer to the server"}]
- ["mqtt.ssl_psk_identity", "s", "", {title: "PSK identity (must specify PSK cipher suites)"}]
- ["mqtt.ssl_psk_key", "s", "", {title: "PSK key"}]
- ["mqtt.clean_session", "b", true, {title: "Clean Session"}]
- ["mqtt.keep_alive", "i", 60, {title: "Keep alive interval"}]
- ["mqtt.will_topic", "s", "acaas", {title: "Will topic"}]
- ["mqtt.will_message", "s", "Probamos con otra cosa diferente", {title: "Will message"}]
- ["mqtt.will_retain", "b", false, {title: "Will retain flag"}]
- ["mqtt.max_qos", "i", 2, {title: "Limit QoS of outgoing messages to at most this"}]
- ["mqtt.recv_mbuf_limit", "i", 3072, {title: "Limit recv buffer size"}]
- ["mqtt.require_time", "b", false, {title: "Only connect if (when) wall time is set"}]
- ["mqtt.cloud_events", "b", true, {title: "Trigger cloud events when connected / disconnected"}]
- ["mqtt.max_queue_length", "i", 5, {title: "Maximum queue length for buffering QoS 1+ messages. 0 to disable queue."}]
# Alternative MQTT configuration. If enabled, client will alternate between mqtt and mqtt1
# when unable to connect.
- ["mqtt1", "mqtt", {title: "Backup MQTT settings"}]
- ["mqtt1.enable", true]
- ["mqtt1.server", "192.168.1.8:1883"]
- ["debug.stdout_topic", "s", "", {title: "MQTT topic to publish STDOUT to"}]
- ["debug.stderr_topic", "s", "", {title: "MQTT topic to publish STDERR to"}]
cdefs:
MG_ENABLE_MQTT: 1
tags:
- mqtt
- c
- js
- net
- docs:net:MQTT
libs:
- origin: https://github.com/mongoose-os-libs/core
- origin: https://github.com/mongoose-os-libs/boards
- origin: https://github.com/mongoose-os-libs/ca-bundle
- origin: https://github.com/mongoose-os-libs/http-server
- origin: https://github.com/mongoose-os-libs/mqtt
- origin: https://github.com/mongoose-os-libs/rpc-service-config
- origin: https://github.com/mongoose-os-libs/rpc-service-fs
- origin: https://github.com/mongoose-os-libs/rpc-uart
- origin: https://github.com/mongoose-os-libs/wifi
- origin: https://github.com/mongoose-os-libs/wifi-setup-web-ui
i have this JS(this code never found i don’t now why):
load('api_mqtt.js');
load('api_gpio.js');
let pin = 0, topic = 'acaas2';
GPIO.set_button_handler(pin, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200, function() {
let res = MQTT.pub('acaas2', JSON.stringify({ a: 1, b: 2 }), 1);
print('Published:', res ? 'yes' : 'no');
}, null);
and i have 2 C code, I copied them both https://github.com/mongoose-os-libs/mqtt.git
Mosquitto is in another VM in the same WIFI configurate whit username and password
if any can help me i make me hapy