An archive of community.esquilo.io as of Saturday January 26, 2019.

MQTT client added to the library

Scott_Shumate

We added a MQTT client written in Squirrel to the Esquilo library. You can use the library sync found in the IDE Squirrel menu to automatically download it to your SD card. Below is a simple example using the Mosquitto test server.

dofile("sd:/lib/protocols/mqttc/mqttc.nut");

mqtt <- MQTTC("MyEsquilo", function(topic, payload) {
    local value = payload.readstr(100);
    print(topic + " : " + value + "\n");
});

try {
    mqtt.connect("test.mosquitto.org", 1883, null);
    mqtt.subscribe("temp/random");

    local payload = blob();
    payload.writestr("30");
    mqtt.publish("temp/random", payload);

    while (true) {
        mqtt.receive();
        delay(10);
    }
}
catch (e) {
    print("MQTT Exception: " + e + "\n");
    mqtt.disconnect();
    mqtt = null;
}
sanit_sir

I can't find the protocols folder for mqttc in the lib on the Github. How can I get the MQTT client? Thank you.

Sanit

Scott_Shumate

The github repo should be up to date now. You can also sync the library in the IDE under the Squirrel menu,

sanit_sir

I found the mqttc module. Thank you for your support.